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: mirroring of last-applied-configuration annotation in EndpointSlices #102731

Conversation

sharmarajdaksh
Copy link
Contributor

@sharmarajdaksh sharmarajdaksh commented Jun 9, 2021

What type of PR is this?

/kind bug

What this PR does / why we need it:

Fixes the Issue reported in #102684

Which issue(s) this PR fixes:

Fixes #102684

Does this PR introduce a user-facing change?

Endpoint slices mirroring controller no longer mirrors the last-applied-configuration annotation created by kubectl to updated endpoint slices

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 9, 2021
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 9, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @sharmarajdaksh!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @sharmarajdaksh. Thanks for your PR.

I'm waiting for a kubernetes 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.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jun 9, 2021
@k8s-ci-robot k8s-ci-robot added sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/network Categorizes an issue or PR as relevant to SIG Network. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 9, 2021
@aojea
Copy link
Member

aojea commented Jun 11, 2021

/ok-to-test
@sharmarajdaksh if you don't ping us this goes unnoticed 😄
/assign @robscott @aojea

@k8s-ci-robot k8s-ci-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 Jun 11, 2021
@BenTheElder
Copy link
Member

@aojea perhaps time to update owners for endpointslice? https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/endpointslice/OWNERS

@BenTheElder BenTheElder added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Jun 11, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jun 11, 2021
@BenTheElder BenTheElder removed the sig/apps Categorizes an issue or PR as relevant to SIG Apps. label Jun 11, 2021
@sharmarajdaksh
Copy link
Contributor Author

@aojea I'm sorry I didn't know for sure where to ping/mention this PR!

Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this @sharmarajdaksh!

ObjectMeta: metav1.ObjectMeta{
Name: "test-ep-1",
Annotations: map[string]string{
corev1.LastAppliedConfigAnnotation: "{\"apiVersion\":\"v1\",\"kind\":\"Endpoints\",\"metadata\":{\"annotations\":{},\"name\":\"ep-test\",\"namespace\":\"default\"},\"subsets\":[{\"addresses\":[{\"ip\":\"193.99.144.80\"}],\"notReadyAddresses\":[{\"ip\":\"195.54.164.39\"}],\"ports\":[{\"name\":\"http\",\"port\":80,\"protocol\":\"TCP\"},{\"name\":\"https\",\"port\":443,\"protocol\":\"TCP\"}]}]}",
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this is the primary issue you want to be testing here. If I'm understanding this correctly, it ensures that an EndpointSlice that has this annotation will have it removed after a mirroring sync has occurred. That's helpful for cleanup, but what I think we actually need to test is that an Endpoints resource with this annotation is not translated to a mirrored EndpointSlice resource.

Copy link
Member

Choose a reason for hiding this comment

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

agreed

Copy link
Member

Choose a reason for hiding this comment

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

so, let's test:

  1. endpoint with corev1.LastAppliedConfigAnnotation: "_data_here" is notmirrored
  2. endpoint with corev1.LastAppliedConfigAnnotation: empty is notmirrored
  3. endpoint with 2 annotations: corev1.LastAppliedConfigAnnotation: "_data_here" and foo:bar only mirrors foo bar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good

@@ -837,6 +947,8 @@ func TestReconcile(t *testing.T) {
expectMetrics(t, *tc.expectedMetrics)
}

expectAnnotations(t, endpoints, tc.existingEndpointSlices)
Copy link
Member

Choose a reason for hiding this comment

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

This is not actually what you want here. You're comparing the two test inputs (Endpoints and EndpointSlices that exist before controller syncs), not the actual output (fetched below).

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I think you could just expand expectEndpointSlices to always expect this annotation to be unset. This would be similar to how it always expects the service name label to be set: https://github.com/kubernetes/kubernetes/blob/576457ac2508d2e06782805f9b3cb27dbbcf7324/pkg/controller/endpointslicemirroring/reconciler_test.go#L988-L991.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see my mistake. Thank you for the pointers. I'll update my PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@robscott
If i understand you correctly, all that should be needed at the line you specified inside reconciler_test.go is:

if epSlice.Annotations[corev1.LastAppliedConfigAnnotation] != "" {
        t.Errorf("Expected LastAppliedConfig Annotation to be unser, got %s", epSlice.Annotations[corev1.LastAppliedConfigAnnotation])
}

Copy link
Member

Choose a reason for hiding this comment

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

Yep, exactly something like that. We'd also need some way for a test case to actually set that annotation on the original Endpoints and EndpointSlice resources as well. You've already got the EndpointSlice use case covered, but it will be a bit more difficult to do the same for the Endpoints in the test case since we just have a subsets object instead of the full resource. Maybe just add a new endpointsAnnotations struct to the testCase struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, a map[string]string should work for that, I believe?

Copy link
Member

Choose a reason for hiding this comment

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

Yep, that sounds ideal.

@k8s-ci-robot k8s-ci-robot removed the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 11, 2021
@aojea
Copy link
Member

aojea commented Jun 14, 2021

/lgtm
@sharmarajdaksh please add a release note. something like

endpointslices mirroring controller no longer mirrors the endpoint annotation created by kubectl with the "last-applied-configuration"

defer approval to RobScott

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jun 14, 2021
@sharmarajdaksh
Copy link
Contributor Author

Added the release note

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

/remove-sig cluster-lifecycle
/remove-area kubeadm

@k8s-ci-robot k8s-ci-robot removed sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. area/kubeadm labels Jun 14, 2021
@ehashman
Copy link
Member

/remove-sig node instrumentaton
/remove-area kubelet

@k8s-ci-robot k8s-ci-robot removed sig/node Categorizes an issue or PR as relevant to SIG Node. area/kubelet labels Jun 14, 2021
@k8s-ci-robot
Copy link
Contributor

@ehashman: Those labels are not set on the issue: sig/instrumentaton

In response to this:

/remove-sig node instrumentaton
/remove-area kubelet

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.

@ehashman
Copy link
Member

/remove-sig instrumentation

@k8s-ci-robot k8s-ci-robot removed the sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. label Jun 14, 2021
Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this @sharmarajdaksh! Just a couple tiny nits, otherwise LGTM.

}, {
testName: "Annotation mirroring when LastAppliedConfigAnnotation is set",
epAnnotations: map[string]string{
corev1.LastAppliedConfigAnnotation: "{\"apiVersion\":\"v1\",\"kind\":\"Endpoints\",\"metadata\":{\"annotations\":{},\"name\":\"ep-test\",\"namespace\":\"default\"},\"subsets\":[{\"addresses\":[{\"ip\":\"193.99.144.80\"}],\"notReadyAddresses\":[{\"ip\":\"195.54.164.39\"}],\"ports\":[{\"name\":\"http\",\"port\":80,\"protocol\":\"TCP\"},{\"name\":\"https\",\"port\":443,\"protocol\":\"TCP\"}]}]}",
Copy link
Member

Choose a reason for hiding this comment

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

This is a tiny nit, but could this annotation be a bit shorter? I don't think it needs to be very long, and a shorter one would make editing this test slightly easier in the future.

}, {
testName: "Annotation mirroring when multiple annotations are set",
epAnnotations: map[string]string{
corev1.LastAppliedConfigAnnotation: "{\"apiVersion\":\"v1\",\"kind\":\"Endpoints\",\"metadata\":{\"annotations\":{},\"name\":\"ep-test\",\"namespace\":\"default\"},\"subsets\":[{\"addresses\":[{\"ip\":\"193.99.144.80\"}],\"notReadyAddresses\":[{\"ip\":\"195.54.164.39\"}],\"ports\":[{\"name\":\"http\",\"port\":80,\"protocol\":\"TCP\"},{\"name\":\"https\",\"port\":443,\"protocol\":\"TCP\"}]}]}",
Copy link
Member

Choose a reason for hiding this comment

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

Same comment about annotation length.

Hostname: "pod-1",
}},
}},
existingEndpointSlices: []*discovery.EndpointSlice{},
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test case to ensure that an existing slice with this annotation has it cleared out? I think you may have had that test case covered earlier in this PR.

@sharmarajdaksh
Copy link
Contributor Author

Sure no problem, I'll sort the issues you mentioned

@sharmarajdaksh sharmarajdaksh force-pushed the lastappliedconfig-annotation-no-mirror branch from b8b1767 to 3feb01a Compare June 15, 2021 15:48
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 15, 2021
@sharmarajdaksh sharmarajdaksh force-pushed the lastappliedconfig-annotation-no-mirror branch from 3feb01a to 4b4e435 Compare June 15, 2021 16:33
@sharmarajdaksh
Copy link
Contributor Author

@robscott lmk if it looks good now!

expectedClientActions: 1,
expectedMetrics: &expectedMetrics{addedPerSync: 1, numCreated: 1, desiredEndpoints: 1, desiredSlices: 1, actualSlices: 1},
}, {
testName: "Annotation mirroring and updation when the last-applied-configuration annotation is present on an existing endpoint slice",
Copy link
Member

Choose a reason for hiding this comment

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

Test name is confusing to me, maybe something like this:

Suggested change
testName: "Annotation mirroring and updation when the last-applied-configuration annotation is present on an existing endpoint slice",
testName: "Annotation mirroring should remove last-applied-configuration annotation from existing endpoint slice",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, actually now that you mention it I think the test names for all the tests I added could be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Handles incorrect mirroring of endpoint annotations to created endpoint
slices, specifically the last-applied-config. Also updates tests
and adds test cases for the same
@sharmarajdaksh sharmarajdaksh force-pushed the lastappliedconfig-annotation-no-mirror branch from 4b4e435 to 211485c Compare June 15, 2021 17:02
@sharmarajdaksh
Copy link
Contributor Author

/retest

@robscott
Copy link
Member

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 Jun 15, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Jun 15, 2021
@k8s-ci-robot k8s-ci-robot merged commit 81aaeee into kubernetes:master Jun 15, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone Jun 15, 2021
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/apiserver area/cloudprovider area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/ipvs area/provider/gcp Issues or PRs related to gcp provider area/release-eng Issues or PRs related to the Release Engineering subproject area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/release Categorizes an issue or PR as relevant to SIG Release. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Endpoint slice mirroring controller mirrors kubectl kubectl.kubernetes.io/last-applied-configuration
9 participants