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 resolution note to SSA conflict message #2235

Merged
merged 1 commit into from Nov 17, 2022

Conversation

lblackstone
Copy link
Member

For SSA conflicts, add a note about using the "patchForce" annotation to overwrite the existing resource values

Proposed changes

Fix #2157

Here's an example of the updated error message

Diagnostics:
  kubernetes:apps/v1:DeploymentPatch (example):
    error: resource default/foo was not successfully created by the Kubernetes API server : use the "pulumi.com/patchForce" annotation if you want to overwrite the existing values: Apply failed with 1 conflict: conflict with "kubectl-client-side-apply" using apps/v1: .spec.template.spec.containers[name="nginx"].image

Related issues (optional)

For SSA conflicts, add a note about using the "patchForce" annotation to overwrite the existing resource values
@github-actions
Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Copy link
Contributor

@squaremo squaremo left a comment

Choose a reason for hiding this comment

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

Nice and simple, like it :-D
Worth a test case though?

@@ -196,6 +196,10 @@ func Creation(c CreateConfig) (*unstructured.Unstructured, error) {
}
outputs, err = client.Patch(
c.Context, c.Inputs.GetName(), types.ApplyPatchType, objYAML, options)

if errors.IsConflict(err) {
err = fmt.Errorf(`use the "pulumi.com/patchForce" annotation if you want to overwrite the existing values: %w`, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I initially wondered if it would read better with the advice at the end; but, I think it's better to have it as you'd done, with the important information ("there's a problem, here's how to fix it") first.

@lblackstone
Copy link
Member Author

Worth a test case though?

I don't usually add tests for stuff like this. What kind of test coverage would you say is valuable for error messages?

@lblackstone lblackstone merged commit 201bb40 into master Nov 17, 2022
@pulumi-bot pulumi-bot deleted the lblackstone/conflict-hint branch November 17, 2022 17:40
@squaremo
Copy link
Contributor

I don't usually add tests for stuff like this. What kind of test coverage would you say is valuable for error messages?

In general, I draw the line somewhere short of testing for specific error messages and log messages. However, the change here is to give advice in a specific situation, which happens to be when reporting an error. Providing evidence that it really does give that advice in that stuation helps make the case for including the change.

Writing down the steps to try it out would work OK, but a test case would also act as an alarm if assumptions decay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve the error message when forcePatching
2 participants