Skip to content

Preserve Annotation to Prevent GC#8614

Merged
knative-prow-robot merged 1 commit intoknative:masterfrom
MIBc:annotation
Jul 15, 2020
Merged

Preserve Annotation to Prevent GC#8614
knative-prow-robot merged 1 commit intoknative:masterfrom
MIBc:annotation

Conversation

@MIBc
Copy link
Copy Markdown
Contributor

@MIBc MIBc commented Jul 13, 2020

Fixes #8571

Proposed Changes

  • Add preserve annotation to prevent GC from automatically deleting the revision.

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 13, 2020
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 13, 2020
@knative-prow-robot
Copy link
Copy Markdown
Contributor

Hi @MIBc. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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 area/API API objects and controllers needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features labels Jul 13, 2020
@MIBc
Copy link
Copy Markdown
Contributor Author

MIBc commented Jul 13, 2020

/assign @whaught

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

whaught commented Jul 13, 2020

/ok-to-test

@knative-prow-robot knative-prow-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 13, 2020
Copy link
Copy Markdown
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.

There's probably a problem where we validate revision annotations to be in the specific set.

Comment on lines +36 to +39
// RevisionPreservedAnnotationKey is the annotation key used for preventing garbage collector
// from automatically deleting the revision.
RevisionPreservedAnnotationKey = GroupName + "/preserved"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd go more towards exclude-gc or no-gc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no-gc is fine.

Comment thread pkg/reconciler/gc/v2/gc.go Outdated
})

for _, rev := range revs[gcSkipOffset:] {
if _, ok := rev.ObjectMeta.Annotations[serving.RevisionPreservedAnnotationKey]; ok {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we check that value is non-empty? I guess the name (as it is) asks for a bool value. So preserve=false, means GC is possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread pkg/reconciler/gc/v2/gc_test.go
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 14, 2020
Copy link
Copy Markdown
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)

Comment thread pkg/reconciler/gc/v2/gc.go Outdated
@whaught
Copy link
Copy Markdown
Contributor

whaught commented Jul 14, 2020

There's probably a problem where we validate revision annotations to be in the specific set.

allowedAnnotations = sets.NewString(

I think we'll want to add this annotation here.

Comment thread pkg/reconciler/gc/v2/gc.go Outdated
Comment thread pkg/reconciler/gc/v2/gc.go Outdated
Comment on lines +64 to +67
preserve := rev.ObjectMeta.Annotations[serving.RevisionPreservedAnnotationKey]
if preserve == "true" {
continue
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here an in interesting question is: should we first filter than apply gcSkipOffset limit, since this counts as a revision for minRevision to retain as well?
cc @dprotaso @mattmoor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we want it to not count towards the min/max (and treat it as if it were an actively referenced revision even if it is not). The settings for automatic-gc say to the user "how many extra should we keep automatically keep around" for potential rollback, I don't think we'd want it to cut into that if the user is choosing to manage these manually - they could set min to 0 if, for example, they intend to manage everything manually.

I intend for the code layout to change a little bit as we integrate the new v2 settings which might give it a more clear place to live and gets rid of the offset: #8621

Copy link
Copy Markdown
Contributor Author

@MIBc MIBc Jul 15, 2020

Choose a reason for hiding this comment

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

We need to make some more meaningful settings like whaught said to solve this question.

Fixes knative#8571

* Add preserve annotation to prevent GC from automatically deleting the revision.
@knative-metrics-robot
Copy link
Copy Markdown

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/reconciler/gc/v2/gc.go 97.4% 97.6% 0.1

@whaught
Copy link
Copy Markdown
Contributor

whaught commented Jul 15, 2020

/lgtm

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

whaught commented Jul 15, 2020

/assign @vagababov @dprotaso

Copy link
Copy Markdown
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

@dprotaso
Copy link
Copy Markdown
Member

/lgtm
/approve

@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, MIBc

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 Jul 15, 2020
@knative-prow-robot knative-prow-robot merged commit 78c81f8 into knative:master Jul 15, 2020
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/test-and-release It flags unit/e2e/conformance/perf test issues for product features cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve Annotation to Prevent GC

8 participants