Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some logging #205

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions runner/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,8 @@ func (r *basePoolManager) retryFailedInstancesForOnePool(ctx context.Context, po

g, errCtx := errgroup.WithContext(ctx)
for _, instance := range existingInstances {
instance := instance

if instance.Status != commonParams.InstanceError {
continue
}
Expand All @@ -1267,9 +1269,11 @@ func (r *basePoolManager) retryFailedInstancesForOnePool(ctx context.Context, po
continue
}

instance := instance
g.Go(func() error {
defer r.keyMux.Unlock(instance.Name, false)
slog.DebugContext(
ctx, "attempting to clean up any previous instance",
"runner_name", instance.Name)
// NOTE(gabriel-samfira): this is done in parallel. If there are many failed instances
// this has the potential to create many API requests to the target provider.
// TODO(gabriel-samfira): implement request throttling.
Expand All @@ -1286,7 +1290,9 @@ func (r *basePoolManager) retryFailedInstancesForOnePool(ctx context.Context, po
// which we would rather avoid.
return err
}

slog.DebugContext(
ctx, "cleanup of previously failed instance complete",
"runner_name", instance.Name)
// TODO(gabriel-samfira): Incrementing CreateAttempt should be done within a transaction.
// It's fairly safe to do here (for now), as there should be no other code path that updates
// an instance in this state.
Expand Down Expand Up @@ -1397,6 +1403,11 @@ func (r *basePoolManager) deleteInstanceFromProvider(ctx context.Context, instan
identifier = instance.Name
}

slog.DebugContext(
ctx, "calling delete instance on provider",
"runner_name", instance.Name,
"provider_id", identifier)

if err := provider.DeleteInstance(ctx, identifier); err != nil {
return errors.Wrap(err, "removing instance")
}
Expand Down Expand Up @@ -1534,15 +1545,17 @@ func (r *basePoolManager) addPendingInstances() error {
"pool_id", instance.PoolID)
if err := r.addInstanceToProvider(instance); err != nil {
slog.With(slog.Any("error", err)).ErrorContext(
r.ctx, "failed to add instance to provider")
r.ctx, "failed to add instance to provider",
"runner_name", instance.Name)
errAsBytes := []byte(err.Error())
if _, statusErr := r.setInstanceStatus(instance.Name, commonParams.InstanceError, errAsBytes); statusErr != nil {
slog.With(slog.Any("error", statusErr)).ErrorContext(
r.ctx, "failed to update runner status",
"runner_name", instance.Name)
}
slog.With(slog.Any("error", err)).ErrorContext(
r.ctx, "failed to create instance in provider")
r.ctx, "failed to create instance in provider",
"runner_name", instance.Name)
}
}(instance)
}
Expand Down
Loading