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

Move validation of autoscaling.knative.dev/metric to RevisionTemplateSpec #5412

Merged
merged 2 commits into from
Sep 7, 2019

Conversation

savitaashture
Copy link
Contributor

Proposed Changes

  • Moved autoscaling.knative.dev/metric annotation validation from PodAutoscaler to RevisionTemplateSpec

Actual:
Create service with Invalid value of autoscaling.knative.dev/metric annotation gives error message in the revision status

  Type     Reason         Age                From                 Message
  ----     ------         ----               ----                 -------
  Warning  InternalError  11s (x2 over 11s)  revision-controller  Operation cannot be fulfilled on deployments.apps "hello-4rzwr-deployment": the object has been modified; please apply your changes to the latest version and try again
  Warning  InternalError  4s (x10 over 12s)  revision-controller  admission webhook "webhook.serving.knative.dev" denied the request: mutation failed: invalid value: cpu1: annotations.autoscaling.knative.dev/metric

Expected:
service create/update should fail with invalid autoscaling.knative.dev/metric annotation

kubectl create -f service.yaml 
Error from server (BadRequest): error when creating "service1.yaml": admission webhook "webhook.serving.knative.dev" denied the request: mutation failed: invalid value: cpu1: spec.template.metadata.annotations.autoscaling.knative.dev/metric

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Sep 6, 2019
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 6, 2019
@knative-prow-robot knative-prow-robot added area/API API objects and controllers area/autoscale labels Sep 6, 2019
"knative.dev/serving/pkg/apis/serving"
)

func (pa *PodAutoscaler) Validate(ctx context.Context) *apis.FieldError {
errs := serving.ValidateObjectMetadata(pa.GetObjectMeta()).ViaField("metadata")
errs = errs.Also(pa.validateMetric())
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we might still want to keep this around, for backward compatibility for existing services that have already been created before this and had invalid metric annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Existing services means?
Even if service created that service won't be created successfully

// Leave other classes of PodAutoscaler alone.
return nil
}
return apis.ErrInvalidValue(metric, MetricAnnotationKey)
Copy link
Contributor

Choose a reason for hiding this comment

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

so this is unreachable now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No its not unreachable
When MetricAnnotationKey is invalid for class HPA and KPA it will execute that line

@knative-metrics-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/apis/autoscaling/v1alpha1/pa_validation.go 93.8% 100.0% 6.2

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
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 6, 2019
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: savitaashture, vagababov

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 6, 2019
@savitaashture
Copy link
Contributor Author

/retest

@knative-prow-robot knative-prow-robot merged commit e10622f into knative:master Sep 7, 2019
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 area/autoscale 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.

6 participants