-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Bug: Fix Certificate's AdditionalOutputFormat in admission within Webhook #4814
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
Bug: Fix Certificate's AdditionalOutputFormat in admission within Webhook #4814
Conversation
@JoshVanL owner of feature in controller. Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
feature set Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
webhook set. Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
|
|
||
| // Ensure the set of output formats is unique, keyed on "Type". | ||
| aofSet := sets.NewString() | ||
| for _, val := range crt.AdditionalOutputFormats { |
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.
May just be me, but does this read easier if we switch it around to be:
func validateAdditionalOutputFormats(crt *internalcmapi.CertificateSpec, fldPath *field.Path) field.ErrorList {
if utilfeature.DefaultFeatureGate.Enabled(feature.AdditionalCertificateOutputFormats) {
var el field.ErrorList
// .. perform new validation code .. //
return el
} else if len(crt.AdditionalOutputFormats) > 0 {
// .. return forbidden .. //
return el
}
}
It took me a little while to realise that we'd not validate the Type field if the feature gate is disabled. Perhaps one instance where an else in Go is useful? (or maybe I just need to read more carefully 😄
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.
This was actually intentional. I wanted to have the feature gate check to be the "first" thing in the function- both so it is clear that check doesn't get lost or mangled in other logic, and when/if the feature is graduated we only need to delete that one code block above.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JoshVanL, munnerz 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 |
|
This also needs cherrypicking to v1.7 right? |
|
/lgtm |
|
/hold feel free to unhold when you're ready |
@munnerz Indeed, I wasn't sure what the current process was for cherry picking, but vaguely remember that it was better for someone other than the author to do the command (?). Not sure why.. will do the command myself anyways. /cherry-pick v1.7 Note to reader: this |
|
@JoshVanL: once the present PR merges, I will cherry-pick it on top of v1.7 in a new PR and assign it to you. In response to this:
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. |
|
@JoshVanL: cannot checkout In response to this:
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. |
|
/cherry-pick release-1.7 |
|
@JoshVanL: new pull request created: #4816 In response to this:
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. |
|
This is a breaking change, right? I feel like we should notify people that are using |
This PR fixes a bug where the Certificate's
additionalOutputFormats' field was only ever being validated by the webhook at admission time if theprivateKey` on the Certificate field was also set. The webhook was also incorrectly using the controllers feature set.->
This PR should be backported, and a patch released published.
I'll leave the cherry-pick command for another maintainer.
/kind bug
/priority critical-urgent
/milestone v1.8