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

fix: handle more gracefully watcher error #6316

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pkg/runner/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (s *service) recover(ctx context.Context) (err error) {

for _, exec := range executions {
go func(environmentId string, executionId string) {
err := s.runner.Monitor(ctx, s.proContext.OrgID, environmentId, executionId)
err := s.runner.Monitor(context.Background(), s.proContext.OrgID, environmentId, executionId)
if err == nil {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ func WatchInstrumentedPod(parentCtx context.Context, clientSet kubernetes.Interf
}

notifier.Align(watcher.State())

if ctx.Err() != nil {
log.DefaultLogger.Warnw("canceled watching execution", "executionId", watcher.State().ResourceId(), "err", ctx.Err(), "debug", watcher.State().Debug())
close(notifier.ch)
return
}

if !watcher.State().Completed() {
log.DefaultLogger.Warnw("execution was not detected as complete", "executionId", watcher.State().ResourceId(), "err", ctx.Err(), "debug", watcher.State().Debug())
close(notifier.ch)
return
}

notifier.End()
ctxCancel()
close(notifier.ch)
Expand Down Expand Up @@ -85,12 +98,14 @@ func WatchInstrumentedPod(parentCtx context.Context, clientSet kubernetes.Interf
// Handle the case when it has been complete without pod start
if !watcher.State().PodStarted() && (watcher.State().Completed() || opts.DisableFollow) {
notifier.Align(watcher.State())
log.DefaultLogger.Warnw("execution complete without pod start", "executionId", watcher.State().ResourceId(), "debug", watcher.State().Debug())
return
}

// Load the pod information
if watcher.State().EstimatedPodStartTimestamp().IsZero() {
notifier.Error(fmt.Errorf("cannot estimate Pod start"))
log.DefaultLogger.Warnw("cannot estimate execution pod start", "executionId", watcher.State().ResourceId(), "debug", watcher.State().Debug())
return
}

Expand All @@ -100,6 +115,7 @@ func WatchInstrumentedPod(parentCtx context.Context, clientSet kubernetes.Interf
actions, err := watcher.State().ActionGroups()
if err != nil {
notifier.Error(fmt.Errorf("cannot read execution instructions: %v", err))
log.DefaultLogger.Warnw("cannot read execution instructions", "executionId", watcher.State().ResourceId(), "debug", watcher.State().Debug())
return
}
refs, endRefs := ExtractRefsFromActionGroup(actions)
Expand Down
Loading