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

fix: Fix autoscaling annotations in Service metadata #1021

Merged

Conversation

dsimansk
Copy link
Contributor

Description

This fix should mitigate usage of autoscaling annotations in Service's metadata.Annotations field.

Related to split annotation flag mentioned in #1014.

Changes

  • UpdateAnnotations can distinguish autoscaling annotations and add them to template only

Reference

Fixes #1020

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Sep 18, 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.

@dsimansk: 0 warnings.

In response to this:

Description

This fix should mitigate usage of autoscaling annotations in Service's metadata.Annotations field.

Related to split annotation flag mentioned in #1014.

Changes

  • UpdateAnnotations can distinguish autoscaling annotations and add them to template only

Reference

Fixes #1020

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 knative-prow-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 18, 2020
@dsimansk
Copy link
Contributor Author

For the reviewers, going though the code I'd add definitely add some test cases with such annotations, unit and e2e.

Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

Looking forward to the tests. Will do thorough review when added. Thanks for contribution.

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 21, 2020
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.

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -name '*.pb.go' -prune -o -type f -name '*.go' -print)
goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party | grep -v .pb.go | grep -v wire_gen.go)

Copy link
Collaborator

@navidshaikh navidshaikh left a comment

Choose a reason for hiding this comment

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

PTAL comment about checking the annotations type at the caller level and the utils just doing the update task.


err = servinglib.UpdateAnnotations(service, template, annotationsMap, []string{})
err = servinglib.UpdateRevisionTemplateAnnotation(template, autoscaling.InitialScaleAnnotationKey, strconv.Itoa(p.ScaleInit))
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO, we should have two utils

  • UpdateRevisionAnnotations
  • UpdateServiceAnnotations
    Each taking respective object, toUpdate and toRemove map.
    The callers of these utils can then decide if the given annotations should be set on either or both (explaining why in comments).

Copy link
Contributor Author

@dsimansk dsimansk Sep 21, 2020

Choose a reason for hiding this comment

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

In the current codebase there's only one place that UpdateAnnotations is used and needs to be changed to filter autoscaling annotations. I tried to aim for quick win to unblock CI etc. However, I do agree that separate Update* util methods are likely better solution to expose filtering logic at caller level. I'll update the PR shortly. 😉

@knative-metrics-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/kn/commands/service/configuration_edit_flags.go 83.2% 83.2% 0.0
pkg/serving/config_changes.go 76.7% 76.2% -0.5

@dsimansk
Copy link
Contributor Author

/retest

Copy link
Collaborator

@navidshaikh navidshaikh 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

thank you!

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dsimansk, navidshaikh

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 22, 2020
@knative-prow-robot knative-prow-robot merged commit 719269e into knative:master Sep 22, 2020
rhuss pushed a commit to rhuss/knative-client that referenced this pull request Oct 5, 2020
* fix: Fix autoscaling annotations in Service metadata

* chore: Add test cases

* fix: Rerun codegen

* chore: Split UpdateAnnotations to dedicated functions
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. 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.

autoscaling annotations must be put under "spec.template.metadata.annotations" to work
7 participants