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

Ignore reconcile errors that occur because a pod is being terminated #1233

Merged
Merged
Changes from 2 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
10 changes: 7 additions & 3 deletions controllers/opentelemetrycollector_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers
import (
"context"
"fmt"
"strings"

"github.com/go-logr/logr"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -168,9 +169,12 @@ 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 {
r.log.Error(err, fmt.Sprintf("failed to reconcile %s", task.Name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How often does this logline occur when a pod is terminated?

Copy link
Member Author

@kevinearls kevinearls Nov 9, 2022

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to end the reconciling with by returing nil if the reason is a terminating pod? That way the user gets informed that something did not work and we would get rid of all the unnecessary log lines?

if task.BailOnError {
return err
// Ignore errors that occur because a pod is being terminated
if !apierrors.IsForbidden(err) || !strings.Contains(err.Error(), "because it is being terminated") {
r.log.Error(err, fmt.Sprintf("failed to reconcile %s", task.Name))
if task.BailOnError {
return err
}
}
}
}
Expand Down