-
Notifications
You must be signed in to change notification settings - Fork 452
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
Ignore reconcile errors that occur because a pod is being terminated #1233
Changes from 6 commits
aa9ab2d
77fc4a9
0896ae9
7b0267e
189dcd6
c43dd28
ff5b12c
0af9e90
cd7d18e
cd56efd
81c2657
e9743b6
1213f7b
63f0ecf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,6 +18,7 @@ package controllers | |||||
import ( | ||||||
"context" | ||||||
"fmt" | ||||||
"strings" | ||||||
|
||||||
"github.com/go-logr/logr" | ||||||
appsv1 "k8s.io/api/apps/v1" | ||||||
|
@@ -168,6 +169,11 @@ func (r *OpenTelemetryCollectorReconciler) Reconcile(ctx context.Context, req ct | |||||
func (r *OpenTelemetryCollectorReconciler) RunTasks(ctx context.Context, params reconcile.Params) error { | ||||||
for _, task := range r.tasks { | ||||||
if err := task.Do(ctx, params); err != nil { | ||||||
// If we get an error that occur because a pod is being terminated then exit this loop | ||||||
if apierrors.IsForbidden(err) && strings.Contains(err.Error(), "because it is being terminated") { | ||||||
r.log.V(2).Info("Exiting reconcile loop because namespace", params.Instance.Namespace, "is being terminated") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(see https://pkg.go.dev/github.com/go-logr/logr#Logger.Info) |
||||||
return nil | ||||||
} | ||||||
r.log.Error(err, fmt.Sprintf("failed to reconcile %s", task.Name)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How often does this logline occur when a pod is terminated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many. :-). Like for everything the reconciler touches. To be honest, it's not that big a deal, and probably something that will only be seen when running kuttl tests. But I found it very annoying, so I submitted the PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to end the reconciling with by returing |
||||||
if task.BailOnError { | ||||||
return err | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one last thing, should we print the termination logline before? And maybe an extra hint, that we cancel the reconciliation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frzifus what log level should I print that at?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i thought maybe:
And maybe an additional line that says that the reconciliation will be canceled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit skeptical about checking the string
because it is being terminated"
. This could easily change in the futureThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might be able to check for
v1.NamespaceTerminatingCause
in the error: https://github.com/kubernetes/apiserver/blob/v0.26.0-rc.0/pkg/admission/plugin/namespace/lifecycle/admission.go#L177There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damemi Thanks!