Skip to content

Automated cherry pick of #67562: Prevent resourceVersion updates for custom resources on no-op writes#67616

Merged
k8s-github-robot merged 1 commit intokubernetes:release-1.11from
nikhita:automated-cherry-pick-of-#67562-upstream-release-1.11
Aug 28, 2018
Merged

Automated cherry pick of #67562: Prevent resourceVersion updates for custom resources on no-op writes#67616
k8s-github-robot merged 1 commit intokubernetes:release-1.11from
nikhita:automated-cherry-pick-of-#67562-upstream-release-1.11

Conversation

@nikhita
Copy link
Copy Markdown
Member

@nikhita nikhita commented Aug 20, 2018

Cherry pick of #67562 on release-1.11.

#67562: Prevent resourceVersion updates for custom resources on no-op writes

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 20, 2018
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 20, 2018
@k8s-github-robot k8s-github-robot added the do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. label Aug 20, 2018
@nikhita
Copy link
Copy Markdown
Member Author

nikhita commented Aug 20, 2018

/uncc @david-mcmahon
/cc @liggitt

/assign @sttts @liggitt

@k8s-ci-robot k8s-ci-robot requested review from liggitt and removed request for david-mcmahon August 20, 2018 19:37
@nikhita
Copy link
Copy Markdown
Member Author

nikhita commented Aug 20, 2018

Currently, resourceVersion is incremented even for no-op writes for custom resources. This occurs because metadata accessors for Unstructured objects do not respect omitempty semantics for ObjectMeta fields.

Combined with ObjetMeta pruning (which respects omitempty semantics), this led to different bytes each time a custom resource was written to. Due to different bytes, resourceVersion was incremented.

Instead of updating the accessors (which could be a breaking change), we are making sure that we don't set the fields in BeforeUpdate and BeforeCreate if they have zero values. I updated the accessors in another PR against master: #67635.

More details in #67562, #67541 (comment).

/assign @foxish
for cherry-pick approval

@nikhita
Copy link
Copy Markdown
Member Author

nikhita commented Aug 20, 2018

/sig api-machinery
/kind bug
/area custom-resources

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. kind/bug Categorizes issue or PR as related to a bug. area/custom-resources labels Aug 20, 2018
@nikhita
Copy link
Copy Markdown
Member Author

nikhita commented Aug 20, 2018

/hold
until #67562 is merged

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 20, 2018
@nikhita nikhita force-pushed the automated-cherry-pick-of-#67562-upstream-release-1.11 branch from d06f88e to 854a01d Compare August 20, 2018 20:33
@nikhita
Copy link
Copy Markdown
Member Author

nikhita commented Aug 20, 2018

Updated to reflect changes in #67562.

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Aug 20, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 20, 2018
@nikhita nikhita changed the title Automated cherry pick of #67562: Prevent resource version to custom resource on no-op writes Automated cherry pick of #67562: Prevent resourceVersion updates for custom resources on no-op writes Aug 20, 2018
For ObjectMeta pruning, we round trip through marshalling and
unmarshalling. If the ObjectMeta contained any strings with "" (or other
fields with empty values) _and_ the respective fields are omitempty,
those fields will be lost in the round trip process.

This makes ObjectMeta after the no-op write different from the one
before the write.

Resource version is incremented every time data is written to etcd.
Writes to etcd short-circuit if the bytes being written are identical
to the bytes already present. So this ends up incrementing the
resourceVersion even on no-op writes.

The zero values are set in BeforeCreate and BeforeUpdate. This commit
updates BeforeUpdate such that zero values are only set when the
object does not have a zero value for the respective field.
@nikhita nikhita force-pushed the automated-cherry-pick-of-#67562-upstream-release-1.11 branch from 854a01d to 4f3bdcd Compare August 21, 2018 10:55
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 21, 2018
@sttts
Copy link
Copy Markdown
Contributor

sttts commented Aug 21, 2018

/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 Aug 21, 2018
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, nikhita, sttts

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 21, 2018
@nikhita
Copy link
Copy Markdown
Member Author

nikhita commented Aug 21, 2018

/hold cancel
#67562 has merged

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 21, 2018
@foxish foxish added cherrypick-candidate cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. and removed do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. labels Aug 25, 2018
@k8s-github-robot k8s-github-robot added the do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. label Aug 26, 2018
@k8s-github-robot
Copy link
Copy Markdown

This PR is not for the master branch but does not have the cherrypick-approved label. Adding the do-not-merge/cherry-pick-not-approved label.

@nikhita
Copy link
Copy Markdown
Member Author

nikhita commented Aug 26, 2018

The labels are messed up because of kubernetes/test-infra#9128. We need a prow bump to fix this.

@nikhita
Copy link
Copy Markdown
Member Author

nikhita commented Aug 27, 2018

Closing and opening the PR to trigger prow to remove the do-not-merge/cherry-pick-not-approved label.

@nikhita nikhita closed this Aug 27, 2018
@nikhita nikhita reopened this Aug 27, 2018
@cjwagner
Copy link
Copy Markdown
Member

Take 2 now that the plugin is actually enabled.
/assign
/close

@cjwagner
Copy link
Copy Markdown
Member

/reopen

@k8s-ci-robot k8s-ci-robot reopened this Aug 27, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. label Aug 27, 2018
@cjwagner
Copy link
Copy Markdown
Member

Woohoo!
/unassign

@k8s-github-robot
Copy link
Copy Markdown

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link
Copy Markdown

Automatic merge from submit-queue.

@k8s-github-robot k8s-github-robot merged commit bd57e24 into kubernetes:release-1.11 Aug 28, 2018
@nikhita nikhita deleted the automated-cherry-pick-of-#67562-upstream-release-1.11 branch August 28, 2018 07:35
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/custom-resources cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. 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. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants