这是indexloc提供的服务,不要输入任何密码
Skip to content

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

Conversation

markusthoemmes
Copy link
Contributor

@markusthoemmes markusthoemmes commented Sep 10, 2020

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

The absence of autoscaling annotations in both Service and Configuration's top-level metadata is now validated. This gives users an actionable error message but might potentially cause old (faulty) YAML to start to fail to be accepted now.

/assign @mattmoor @dprotaso

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Sep 10, 2020
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/API API objects and controllers labels Sep 10, 2020
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a 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

/assign @mattmoor @dprotaso

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.

@knative-prow-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 10, 2020
func ValidateHasNoAutoscalingAnnotation(annotations map[string]string) *apis.FieldError {
for key := range annotations {
if strings.HasPrefix(key, autoscaling.GroupName) {
return apis.ErrGeneric(noAutoscalingMsg, apis.CurrentField)
Copy link
Contributor

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.

@markusthoemmes
Copy link
Contributor Author

Reworked, error message now looks like this:

Error from server (BadRequest): error when creating "STDIN": admission webhook "validation.webhook.serving.knative.dev" denied the request: validation failed: invalid key name "autoscaling.knative.dev/class": metadata.annotations
autoscaling annotations must be put under "spec.template.metadata.annotations" to work

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`)
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

missed that, sorry 😂

Copy link
Contributor

@vagababov vagababov left a 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",
Copy link
Contributor

Choose a reason for hiding this comment

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

several bad annotations case?

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 10, 2020
@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 10, 2020
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/serving/metadata_validation.go 98.4% 98.5% 0.1

Copy link
Member

@julz julz left a 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

@markusthoemmes
Copy link
Contributor Author

@julz hmm, fair point. We might want to only apply this on create for that reason 🤔

@vagababov
Copy link
Contributor

Yeah, it's easy to check if we're in update or not for a few versions.

@vagababov
Copy link
Contributor

And probably log warning in case of update.

@julz
Copy link
Member

julz commented Sep 14, 2020

I think this may already only apply on update due to the if !apis.IsInStatusUpdate(ctx) { (?), but it still (imo) warrants a release note -- even if it only applies on create, it means existing local yaml files that worked before (e.g. sample apps, gitops configs) may cause an error when applied to a new cluster.

@markusthoemmes
Copy link
Contributor Author

@julz added a release note.

@julz
Copy link
Member

julz commented Sep 16, 2020

/lgtm

Copy link
Member

@mattmoor mattmoor left a 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

@markusthoemmes
Copy link
Contributor Author

I'm not as concerned about route as I've never seen a user try to add autoscaling annotations there 😂

@mattmoor
Copy link
Member

/lgtm
/unhold

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 16, 2020
@dprotaso
Copy link
Member

/retest

1 similar comment
@mattmoor
Copy link
Member

/retest

@knative-test-reporter-robot

The following jobs failed:

Test name Triggers Retries
pull-knative-serving-integration-tests 2020-09-16 17:57:34.987 +0000 UTC
2020-09-16 18:21:34.946 +0000 UTC
2020-09-16 18:41:05.12 +0000 UTC
2020-09-16 19:08:05.097 +0000 UTC
2020-09-16 21:57:35.25 +0000 UTC
2020-09-16 22:22:05.256 +0000 UTC
3/3
pull-knative-serving-upgrade-tests 2020-09-16 17:47:35.171 +0000 UTC
2020-09-16 17:59:35.086 +0000 UTC
2020-09-16 18:11:35.222 +0000 UTC
2020-09-16 18:34:05.13 +0000 UTC
3/3

Job pull-knative-serving-integration-tests expended all 3 retries without success.

@dprotaso
Copy link
Member

Is installing istio broken?
/tmp/tmp.qT9nj7tHbj/third_party/istio-stable/install-istio.sh: line 20: return: can only return' from a function or sourced script`

@markusthoemmes
Copy link
Contributor Author

/retest

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/API API objects and controllers cla: yes Indicates the PR's author has signed the CLA. lgtm 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.

9 participants