Skip to content

🐛 Remove generated names from error messages to reduce reconciliation #5971

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

Merged

Conversation

killianmuldoon
Copy link
Contributor

Signed-off-by: killianmuldoon [email protected]

Sanitize error messages in the topology controller to prevent reported errors from causing reconciliation.

This is a Work In Progress and should not be merged.

Fixes #5945

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 21, 2022
@@ -269,7 +269,7 @@ func (r *Reconciler) reconcileMachineHealthCheck(ctx context.Context, current, d

log.Infof("Creating %s", tlog.KObj{Obj: desired})
if err := r.Client.Create(ctx, desired); err != nil {
return errors.Wrapf(err, "failed to create %s", tlog.KObj{Obj: desired})
return createError(err, desired)
Copy link
Member

Choose a reason for hiding this comment

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

for sake of consistency, should this be

Suggested change
return createError(err, desired)
errors.Wrapf(err, "failed to create %s", desired.Kind)

same below/in other places where we are returning createError without wrapping

Copy link
Member

@sbueringer sbueringer Jan 24, 2022

Choose a reason for hiding this comment

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

I think we have to decide if we want to add the "failed to create" here or in the func.

I think it could be better to do it here (as we can provide additional context which is needed in some cases). But then the createError/apiErrorWithoutObjectName should focus on sanitizing the StatusError and not also wrap it with failed to create ....

P.S. for additional context I made some proposals here: #5945 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now I'd prefer to keep the create specific information here - I don't think this is more than a single-use function. The additional info can be added by wrapping errors I think - e.g. where the MachineDeployment object kind is added.

Copy link
Member

@sbueringer sbueringer Jan 24, 2022

Choose a reason for hiding this comment

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

Sure, give it a try.

@@ -269,7 +269,7 @@ func (r *Reconciler) reconcileMachineHealthCheck(ctx context.Context, current, d

log.Infof("Creating %s", tlog.KObj{Obj: desired})
if err := r.Client.Create(ctx, desired); err != nil {
return errors.Wrapf(err, "failed to create %s", tlog.KObj{Obj: desired})
return createError(err, desired)
Copy link
Member

@sbueringer sbueringer Jan 24, 2022

Choose a reason for hiding this comment

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

I think we have to decide if we want to add the "failed to create" here or in the func.

I think it could be better to do it here (as we can provide additional context which is needed in some cases). But then the createError/apiErrorWithoutObjectName should focus on sanitizing the StatusError and not also wrap it with failed to create ....

P.S. for additional context I made some proposals here: #5945 (comment)

@killianmuldoon killianmuldoon force-pushed the fix/error-reporting branch 5 times, most recently from 93c74f0 to 4a72596 Compare January 24, 2022 18:41
@killianmuldoon killianmuldoon changed the title 🐛 [WIP] Remove generated names from error messages to reduce reconciliation 🐛 Remove generated names from error messages to reduce reconciliation Jan 24, 2022
}

// Replace the statusError message with the constructed message.
statusError.ErrStatus.Message = fmt.Sprintf("failed to create %s", out)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
statusError.ErrStatus.Message = fmt.Sprintf("failed to create %s", out)
statusError.ErrStatus.Message = fmt.Sprintf("failed to create: %s", out)

nit, usually errors are concatenated with a colon as separator

Copy link
Member

Choose a reason for hiding this comment

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

Should we only add out if it's not empty? Currently the error would have a trailing space in that case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If out is empty at this point the error isn't going to be make any sense regardless I think - should we instead return the error on L750 if there's nothing in out?

Copy link
Member

Choose a reason for hiding this comment

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

Yes!

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 25, 2022
@killianmuldoon killianmuldoon force-pushed the fix/error-reporting branch 2 times, most recently from 9423b3b to bb599a0 Compare January 25, 2022 16:25
@fabriziopandini
Copy link
Member

Thanks @killianmuldoon for sorting out this problem
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 25, 2022
@sbueringer
Copy link
Member

@killianmuldoon
Thank you!
also for fixing related error propagation issues

/lgtm

@sbueringer
Copy link
Member

/cherry-pick release-1.1

As it's a problematic bug we should include it in the v1.1 release

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.1 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.1

As it's a problematic bug we should include it in the v1.1 release

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@fabriziopandini
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 25, 2022
@k8s-ci-robot k8s-ci-robot merged commit 5d126b1 into kubernetes-sigs:main Jan 25, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.2 milestone Jan 25, 2022
@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #5992

In response to this:

/cherry-pick release-1.1

As it's a problematic bug we should include it in the v1.1 release

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reconciliation error doesn't result in exponential backoff
5 participants