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

Add serviceUID/configUID labels to pods & deployments, serviceUID label to configs #10539

Merged
merged 1 commit into from
Jan 16, 2021

Conversation

duglin
Copy link

@duglin duglin commented Jan 13, 2021

This will allow people to find all pods for a service w/o running into the
problem of finding pods associated with an old ksvc that just happens to
share the same name. With this the user can search for pods by the ksvc UID
via the new label.

Rather than having the code go and lookup the ksvc from the revision, I
decided to just add this label to the config as well. If people would prefer
to not have this extra label on the config (and do it via a ksvc lookup)
I can look into that change.

Signed-off-by: Doug Davis [email protected]

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Jan 13, 2021
@knative-prow-robot knative-prow-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. area/API API objects and controllers labels Jan 13, 2021
@vagababov
Copy link
Contributor

Why would there be pods from previous incarnation? Or this is about race condition while old one is still being deleted and new ones already online?
This seems to be a problem in a different fashion as well, where we create lots of resources with the same name, that probably won't be created (e.g. deployment) and deployment will probably own those pods too due to service label. No?

@duglin
Copy link
Author

duglin commented Jan 13, 2021

Yes exactly. If the old pods are in Terminating state a query for all pods related to a ksvc will return both sets of pods because all we can query on (in a single query) is the ksvc name (or config name). By adding the serviceUID we can ensure we get just the pods for the correct ksvc.

@duglin
Copy link
Author

duglin commented Jan 13, 2021

/retest

@@ -78,6 +78,7 @@ func TestMakeRevisions(t *testing.T) {
serving.ConfigurationLabelKey: "build",
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't seem to have any positive tests here.

Copy link
Author

Choose a reason for hiding this comment

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

yep - on my todo list - wanted to get the core of this out there for review ASAP. Coming soon...

Copy link
Author

Choose a reason for hiding this comment

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

done

@@ -41,7 +41,7 @@ func TestConfigurationSpec(t *testing.T) {
}
expectOwnerReferencesSetCorrectly(t, c.OwnerReferences)

if got, want := c.Labels, map[string]string{serving.ServiceLabelKey: testServiceName}; !cmp.Equal(got, want) {
if got, want := c.Labels, map[string]string{serving.ServiceLabelKey: testServiceName, serving.ServiceUIDLabelKey: ""}; !cmp.Equal(got, want) {

This comment was marked as resolved.

Copy link
Author

Choose a reason for hiding this comment

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

done

pkg/apis/serving/register.go Show resolved Hide resolved
@knative-prow-robot knative-prow-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 15, 2021
This will allow people to find all pods for a service w/o running into the
problem of finding pods associated with an old ksvc that just happens to
share the same name. With this the user can search for pods by the ksvc UID
via the new label.

Rather than having the code go and lookup the ksvc from the revision, I
decided to just add this label to the config as well. If people would prefer
to not have this extra label on the config (and do it via a ksvc lookup)
I can look into that change.

Signed-off-by: Doug Davis <[email protected]>
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 15, 2021
@codecov
Copy link

codecov bot commented Jan 15, 2021

Codecov Report

Merging #10539 (57232dc) into master (80321c4) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10539      +/-   ##
==========================================
- Coverage   88.09%   88.08%   -0.02%     
==========================================
  Files         186      186              
  Lines        8831     8839       +8     
==========================================
+ Hits         7780     7786       +6     
- Misses        810      811       +1     
- Partials      241      242       +1     
Impacted Files Coverage Δ
pkg/apis/serving/v1/revision_validation.go 88.42% <ø> (ø)
pkg/apis/serving/v1/configuration_validation.go 100.00% <100.00%> (ø)
pkg/reconciler/configuration/resources/revision.go 88.63% <100.00%> (+1.79%) ⬆️
pkg/reconciler/service/resources/configuration.go 100.00% <100.00%> (ø)
pkg/reconciler/autoscaling/kpa/scaler.go 88.57% <0.00%> (-1.43%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80321c4...ba4938a. Read the comment docs.

@duglin duglin requested a review from dprotaso January 15, 2021 19:39
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

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 15, 2021
@dprotaso
Copy link
Member

/approve

/hold can you update the title to reflect what's happening now - ie. service & config uid added to revision/deployment

@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 Jan 15, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Jan 15, 2021
@duglin duglin changed the title Add a serviceUID label to ksvc (and implicitly to config) Add serviceUID/configUID labels to pods & deployments, serviceUID label to configs Jan 15, 2021
@duglin
Copy link
Author

duglin commented Jan 15, 2021

@dprotaso done!

@dprotaso
Copy link
Member

/hold cancel

@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 Jan 15, 2021
@duglin
Copy link
Author

duglin commented Jan 15, 2021

/retest

@knative-prow-robot knative-prow-robot merged commit 3177cc7 into knative:master Jan 16, 2021
navidshaikh added a commit to navidshaikh/client that referenced this pull request Jan 19, 2021
 While exporting the service using `service export` command, ignore
 the service labels with keys 'configUID' and `configUID`
 see knative/serving#10539 for further details.
navidshaikh added a commit to navidshaikh/client that referenced this pull request Jan 19, 2021
 While exporting the service using `service export` command, ignore
 the service labels with keys 'configUID' and `configUID`
 see knative/serving#10539 for further details.
knative-prow-robot pushed a commit to knative/client that referenced this pull request Jan 20, 2021
…#1194)

* Ignore serviceUID and configUID labels in service export result

 While exporting the service using `service export` command, ignore
 the service labels with keys 'configUID' and `configUID`
 see knative/serving#10539 for further details.

* Fix the var names per golint recommendation

* Ignore the serviceUID and configUID labels from revision labels

* Add e2e for verifying configUID and serviceUID labels are absent

* Add CHANGELOG
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. 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.

4 participants