-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Validate autoscaling annotations on Services and Configs. #9358
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
Validate autoscaling annotations on Services and Configs. #9358
Conversation
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.
@markusthoemmes: 0 warnings.
In response to this:
Proposed Changes
This validates that no autoscaling annotations are put onto top-level metadata in Services and Configurations. Further, it adds advice into the error message to guide users to put the annotations into the right spot.
Despite explicitly documenting this, we're still seeing users continuously struggling here. This is an attempt to frontload the error determination.
Happy to bin this if i'm completely off, haven't discussed this with anybody before cooking it up 😅
Release Note
NONE
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.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: markusthoemmes 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 |
func ValidateHasNoAutoscalingAnnotation(annotations map[string]string) *apis.FieldError { | ||
for key := range annotations { | ||
if strings.HasPrefix(key, autoscaling.GroupName) { | ||
return apis.ErrGeneric(noAutoscalingMsg, apis.CurrentField) |
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.
I wish we had warnings
-- it's not really an error to set them here, it's just they are useless.
Reworked, error message now looks like this:
|
for key := range annotations { | ||
if strings.HasPrefix(key, autoscaling.GroupName) { | ||
return apis.ErrGeneric(noAutoscalingMsg, apis.CurrentField) | ||
return apis.ErrInvalidKeyName(key, apis.CurrentField, `autoscaling annotations must be put under "spec.template.metadata.annotations" to work`) |
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.
well if we're not going to aggregate them with Also
, then errs
is not required.
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.
missed that, sorry 😂
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.
/lgtm
/hold
I'll defer to Matt for final lgtm.
name: "no offender", | ||
annotation: map[string]string{"foo": "bar"}, | ||
}, { | ||
name: "only offender", |
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.
several bad annotations case?
The following is the coverage report on the affected files.
|
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.
Probably should add something to the release note section in the description for this one to make super sure we remember to add a warning, since existing valid yaml may become invalid (eg if you put annotations in both places) after this
@julz hmm, fair point. We might want to only apply this on create for that reason 🤔 |
Yeah, it's easy to check if we're in update or not for a few versions. |
And probably log warning in case of update. |
I think this may already only apply on update due to the |
@julz added a release note. |
/lgtm |
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.
Should we also do Route?
Otherwise LGTM
I'm not as concerned about route as I've never seen a user try to add autoscaling annotations there 😂 |
/lgtm |
/retest |
1 similar comment
/retest |
The following jobs failed:
Job pull-knative-serving-integration-tests expended all 3 retries without success. |
Is installing istio broken? |
/retest |
Proposed Changes
This validates that no autoscaling annotations are put onto top-level metadata in Services and Configurations. Further, it adds advice into the error message to guide users to put the annotations into the right spot.
Despite explicitly documenting this, we're still seeing users continuously struggling here. This is an attempt to frontload the error determination.
Happy to bin this if i'm completely off, haven't discussed this with anybody before cooking it up 😅
Release Note
/assign @mattmoor @dprotaso