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

Enhance error msg when trying to change .spec.seedName by patching a shoot #9294

Merged
merged 3 commits into from
Mar 1, 2024

Conversation

plkokanov
Copy link
Contributor

@plkokanov plkokanov commented Feb 29, 2024

How to categorize this PR?

/area usability
/kind enhancement

What this PR does / why we need it:
This PR enhances the validation error which is shown when trying to change a shoot's .spec.seedName without using the shoots/binding subresource. The new error message will also display the old and new .spec.seedNames to show that a change attempt was actually made. If one of the .spec.seedName fields are nil it will print 'nil' in the error message. You can check the following examples:

Error from server (Forbidden): error when replacing "example/provider-local/shoot.yaml": shoots.core.gardener.cloud "local" is forbidden: spec.seedName 'local' cannot be changed to 'nil' by patching the shoot, please use the shoots/binding subresource
Error from server (Forbidden): error when replacing "example/provider-local/shoot.yaml": shoots.core.gardener.cloud "local" is forbidden: spec.seedName 'local' cannot be changed to 'new-local' by patching the shoot, please use the shoots/binding subresource

Which issue(s) this PR fixes:
Fixes #9186

Special notes for your reviewer:

Release note:

The validation error shown when a user tries to change the `.spec.seedName` field of a Shoot will now also display the old and new values to better indicate that a change was attempted.

@gardener-prow gardener-prow bot added area/usability Usability related kind/enhancement Enhancement, improvement, extension cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 29, 2024
@@ -761,7 +761,7 @@ var _ = Describe("validator", func() {
err := admissionHandler.Admit(ctx, attrs, nil)

Expect(err).To(BeForbiddenError())
Expect(err).To(MatchError(ContainSubstring("spec.seedName cannot be changed by patching the shoot, please use the shoots/binding subresource")))
Expect(err).To(MatchError(ContainSubstring("spec.seedName 'seed' cannot be changed to 'nil' by patching the shoot, please use the shoots/binding subresource")))
Copy link
Contributor

Choose a reason for hiding this comment

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

seedName cannot be set to nil once set, right? So maybe we print that it cannot be nil at all, even with the binding resource.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was wondering about that as well, but decided to leave that error for the binding subresource validation so as to keep the current "behaviour".

Otherwise I could potentially print two errors depending on whether the new .spec.seedName is nil or not:

When it is not nil:

spec.seedName 'seed-name' cannot be changed to 'new-seed' by patching the shoot, please use the shoots/binding subresource

When it is nil:

spec.seedName is already set to `seed-name` and cannot be changed to 'nil'

Copy link
Contributor

@shafeeqes shafeeqes Feb 29, 2024

Choose a reason for hiding this comment

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

I would prefer the two error approach.
In binding, we print similar error for the nil case but a different message, you could use this error there too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@ScheererJ ScheererJ left a comment

Choose a reason for hiding this comment

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

/approve

@gardener-prow gardener-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 29, 2024
@gardener-prow gardener-prow bot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Feb 29, 2024
@gardener-prow gardener-prow bot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Feb 29, 2024
Copy link
Contributor

@shafeeqes shafeeqes left a comment

Choose a reason for hiding this comment

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

Thanks!
/lgtm

@gardener-prow gardener-prow bot added the lgtm Indicates that a PR is ready to be merged. label Mar 1, 2024
Copy link
Contributor

gardener-prow bot commented Mar 1, 2024

LGTM label has been added.

Git tree hash: 1327bb09392b5417993cb02a578923ec9c5e648a

Copy link
Contributor

gardener-prow bot commented Mar 1, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ScheererJ, shafeeqes

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:
  • OWNERS [ScheererJ,shafeeqes]

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

@shafeeqes
Copy link
Contributor

/retest

@shafeeqes
Copy link
Contributor

/test pull-gardener-e2e-kind-ha-single-zone

@gardener-prow gardener-prow bot merged commit 12e8f78 into gardener:master Mar 1, 2024
17 checks passed
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. area/usability Usability related cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. kind/enhancement Enhancement, improvement, extension lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected error during PUT: spec.seedName cannot be changed by patching the shoot
4 participants