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 bugs when copying deployment annotations to replicaSet if value is empty #94858

Merged
merged 1 commit into from Dec 23, 2020

Conversation

waynepeking348
Copy link
Contributor

@waynepeking348 waynepeking348 commented Sep 17, 2020

What type of PR is this?

/kind bug

What this PR does / why we need it:
In our production environment, we relay on annotations to identify deployment with certain types; in some cases, we may set the annotation value with empty string, which may lead to unexpected problems if a rollout action is trigged.

  1. deployment created with annotation deployment.test.kubernetes.io: ""; replicaSet1 will not copy this key from deployment since map (in Golang) will return empty string if the given key doesn't exist (just as this belong logic)
    if skipCopyAnnotation(k) || rs.Annotations[k] == v {
        continue
    }
  1. upgrade deployment with a new image and then rollout the the previous version, then deployment is recreated from replicaSet1 (which doesn't have annotation deployment.test.kubernetes.io), then this deployment is unexpected because it lost the identification in its annotations.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

Copy annotations with empty value when deployment rolls back

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Sep 17, 2020
@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. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 17, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @waynepeking348. 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 sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 17, 2020
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 17, 2020
@waynepeking348
Copy link
Contributor Author

/assign deads2k sig-apps-reviewers cheftako

@k8s-ci-robot
Copy link
Contributor

@waynepeking348: GitHub didn't allow me to assign the following users: sig-apps-reviewers.

Note that only kubernetes members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign deads2k sig-apps-reviewers cheftako

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.

@cheftako
Copy link
Member

/ok-to-test

@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 Sep 17, 2020
@cheftako
Copy link
Member

The fix looks correct to me. However I'm a little worried about backward compatibility. Just because no one should have been relying on this behavior doesn't mean they aren't. At a minimum we should probably have a release note for this change. Interested to hear @deads2k thoughts.

@waynepeking348
Copy link
Contributor Author

/test pull-kubernetes-bazel-test

@waynepeking348
Copy link
Contributor Author

The fix looks correct to me. However I'm a little worried about backward compatibility. Just because no one should have been relying on this behavior doesn't mean they aren't. At a minimum we should probably have a release note for this change. Interested to hear @deads2k thoughts.

according to current logic, deployment will copy those annotations to the latest replicaSet, it won't affect others; I also think a release note is reasonable. would you please have a look at this fix @deads2k ?

@waynepeking348
Copy link
Contributor Author

@kow3ns @deads2k @mortent could you please have a look up at this fix?

@waynepeking348
Copy link
Contributor Author

/retest

@waynepeking348
Copy link
Contributor Author

any thought /assign @cheftako

The fix looks correct to me. However I'm a little worried about backward compatibility. Just because no one should have been relying on this behavior doesn't mean they aren't. At a minimum we should probably have a release note for this change. Interested to hear @deads2k thoughts.

according to current logic, deployment will copy those annotations to the latest replicaSet, it won't affect others; I also think a release note is reasonable. would you please have a look at this fix @deads2k ?

any thought? /assign @cheftako

@cheftako
Copy link
Member

/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 Dec 22, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheftako, waynepeking348

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Dec 22, 2020
@k8s-ci-robot k8s-ci-robot merged commit f11c3b4 into kubernetes:master Dec 23, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Dec 23, 2020
@MikeSpreitzer
Copy link
Member

@waynepeking348 , @cheftako , @deads2k : BTW, where is it documented that the metadata.annotations of a Deployment object are copied to the metadata.annotations of its owned ReplicaSet objects? And, why is this a good idea?

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/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/apps Categorizes an issue or PR as relevant to SIG Apps. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants