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

Incrementing EndpointSlice generation when labels change #99750

Merged
merged 1 commit into from Mar 4, 2021

Conversation

robscott
Copy link
Member

@robscott robscott commented Mar 4, 2021

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

EndpointSlice labels can be quite meaningful. They are used to indicate the controller they are managed by and the Service they are associated with. Changing these labels can have significant effects on how the EndpointSlice is consumed so incrementing generation seems appropriate.

Special notes for your reviewer:

This is especially relevant to #99345 where we updated the EndpointSlice controller to track EndpointSlice generations. This change to strategy was suggested by @wojtek-t in #99345 (comment).

Does this PR introduce a user-facing change?

EndpointSlice generation is now incremented when labels change.

/sig network
/triage accepted
/priority important-soon
/cc @wojtek-t @aojea
/assign @liggitt

EndpointSlice labels can be quite meaningful. They are used to indicate
the controller they are managed by and the Service they are associated
with. Changing these labels can have significant affects on how the
EndpointSlice is consumed so incrementing generation seems appropriate.
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Mar 4, 2021
@k8s-ci-robot k8s-ci-robot added sig/network Categorizes an issue or PR as relevant to SIG Network. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 4, 2021
@@ -65,7 +65,7 @@ func (endpointSliceStrategy) PrepareForUpdate(ctx context.Context, obj, old runt
newEPS.ObjectMeta = v1.ObjectMeta{}
oldEPS.ObjectMeta = v1.ObjectMeta{}

if !apiequality.Semantic.DeepEqual(newEPS, oldEPS) {
if !apiequality.Semantic.DeepEqual(newEPS, oldEPS) || !apiequality.Semantic.DeepEqual(ogNewMeta.Labels, ogOldMeta.Labels) {
Copy link
Member

Choose a reason for hiding this comment

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

I was actually suggesting going even step further and adding:

else {
  ogNewMeta.Generation = og.OldMeta.Generation
}

But I would like to hear Jordan`s opinion (if that doesn't violate some conventions, backward compatibility, etc.)

Copy link
Member

Choose a reason for hiding this comment

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

rest.BeforeUpdate already resets generation to the current value before calling strategy.PrepareForUpdate:

objectMeta.SetGeneration(oldMeta.GetGeneration())
// Ensure managedFields state is removed unless ServerSideApply is enabled
if !utilfeature.DefaultFeatureGate.Enabled(features.ServerSideApply) {
oldMeta.SetManagedFields(nil)
objectMeta.SetManagedFields(nil)
}
strategy.PrepareForUpdate(ctx, obj, old)

Copy link
Member

Choose a reason for hiding this comment

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

Good point - I missed that thanks.

@liggitt
Copy link
Member

liggitt commented Mar 4, 2021

there's precedent from deployments for considering specific fields outside spec in computing generation:

if !apiequality.Semantic.DeepEqual(newDeployment.Spec, oldDeployment.Spec) ||
!apiequality.Semantic.DeepEqual(newDeployment.Annotations, oldDeployment.Annotations) {
newDeployment.Generation = oldDeployment.Generation + 1
}

this seems reasonable to me, but will defer final ack to @thockin who has more context on the endpointslice API bits

/unassign
/assign @thockin

@k8s-ci-robot k8s-ci-robot assigned thockin and unassigned liggitt Mar 4, 2021
@liggitt liggitt added this to Assigned in API Reviews Mar 4, 2021
Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

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

Thanks!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 4, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: robscott, thockin

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 4, 2021
@k8s-ci-robot k8s-ci-robot merged commit 76f2a4d into kubernetes:master Mar 4, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Mar 4, 2021
@wojtek-t
Copy link
Member

wojtek-t commented Mar 4, 2021

For posterity - LGTM too.

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/network Categorizes an issue or PR as relevant to SIG Network. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Status: API review completed, 1.21
Development

Successfully merging this pull request may close these issues.

None yet

5 participants