Skip to content

Switch from update to patch for VolumeSnapshot and Content#480

Closed
ggriffiths wants to merge 1 commit intokubernetes-csi:masterfrom
ggriffiths:UsePatchInsteadUpdate_2
Closed

Switch from update to patch for VolumeSnapshot and Content#480
ggriffiths wants to merge 1 commit intokubernetes-csi:masterfrom
ggriffiths:UsePatchInsteadUpdate_2

Conversation

@ggriffiths
Copy link
Contributor

@ggriffiths ggriffiths commented Mar 10, 2021

What type of PR is this?
/kind bug

What this PR does / why we need it:
Switches to use patch instead of update

Which issue(s) this PR fixes:
Fixes #368

Special notes for your reviewer:
n/a

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 10, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ggriffiths
To complete the pull request process, please assign lpabon after the PR has been reviewed.
You can assign the PR to them by writing /assign @lpabon in a comment when ready.

The full list of commands accepted by this bot can be found 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 10, 2021
@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch from b0326c4 to 9d99874 Compare March 11, 2021 01:23
@ggriffiths ggriffiths changed the title WIP: Switch from update to patch for VolumeSnapshot and Content Switch from update to patch for VolumeSnapshot and Content Mar 11, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 11, 2021
@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch from 9d99874 to 1f2c2e7 Compare March 11, 2021 01:41
@ggriffiths ggriffiths changed the title Switch from update to patch for VolumeSnapshot and Content WIP: Switch from update to patch for VolumeSnapshot and Content Mar 11, 2021
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 11, 2021
@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch 5 times, most recently from 7eab1e5 to e4db6cb Compare March 12, 2021 23:01
@ggriffiths
Copy link
Contributor Author

Discovered that stategicmergepatch is not supported for CRs. Working now on an alternative

@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch from e4db6cb to 34d67d2 Compare March 30, 2021 19:28
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 2, 2021
@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch from 462b834 to 85e6ef1 Compare April 2, 2021 00:40
@ggriffiths ggriffiths changed the title WIP: Switch from update to patch for VolumeSnapshot and Content Switch from update to patch for VolumeSnapshot and Content Apr 2, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 2, 2021
@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch 2 times, most recently from e8d7316 to 70cc311 Compare April 2, 2021 01:19
@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch from 70cc311 to 77923a9 Compare April 2, 2021 01:23
@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch from 77923a9 to 237d909 Compare April 2, 2021 06:25
@ggriffiths ggriffiths requested a review from xing-yang April 2, 2021 06:26
@ggriffiths
Copy link
Contributor Author

Addressed comments, ready for re-review @xing-yang

@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch from 237d909 to b78eb40 Compare April 2, 2021 18:18
contentClone.Status.RestoreSize = nil
}
newContent, err := ctrl.clientset.SnapshotV1().VolumeSnapshotContents().UpdateStatus(context.TODO(), content, metav1.UpdateOptions{})
newContent, err := utils.PatchVolumeSnapshotContent(content, contentClone, ctrl.clientset, "status")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This string "status" is used in multiple places. Can you make it a constant?

@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch from b78eb40 to afbea95 Compare April 5, 2021 05:58
@ggriffiths ggriffiths requested a review from xing-yang April 5, 2021 16:29
@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch from afbea95 to cbf8dca Compare April 5, 2021 19:12
@ggriffiths
Copy link
Contributor Author

ggriffiths commented Apr 5, 2021

/retest

Comparing snapshot-controller logs with other PRs to see if we're seeing less the object has been modified errors.

@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch 3 times, most recently from 46aff65 to 55d6555 Compare April 6, 2021 01:45
Signed-off-by: Grant Griffiths <ggriffiths@purestorage.com>
@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch from 55d6555 to acb00fb Compare April 6, 2021 04:47
}

return newSnapshot, nil
return updatedSnapshot, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought "newSnapshot" is the latest one returned from API server? Why returning "updatedSnapshot"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was a test commit - I was trying to see if this reduced the 'modified object' error count.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverting the above change as it did not lower the error count.

Copy link
Collaborator

@xing-yang xing-yang Apr 8, 2021

Choose a reason for hiding this comment

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

Can you take a look of the logs and see if you can tell why we got the "modified object" error? For example, is it because there's another API update happened before the patch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Asked SIG API machinery per your suggestion to try and find out. I'll also check the logs to see under what scenarios we face this. The error counts are fairly consistent.

@ggriffiths ggriffiths force-pushed the UsePatchInsteadUpdate_2 branch from e08f7c7 to acb00fb Compare April 7, 2021 17:29
@ggriffiths
Copy link
Contributor Author

Still investigating ways to lower the error count. merge patch alone with this implementation does not seem to lower the error count.
/hold

@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 Apr 15, 2021
@ggriffiths
Copy link
Contributor Author

Findings so far:

  1. Strategicmergepatch is not supported for CRDs. Moving to mergepatch via json-patch does not lower error count (~250 error count)
  2. Removing addResourceVersion from implementation does not lower error count (error count: 240)
  3. Performing a "Get" before every "Patch" lowered error count to 24 total, but is expensive.

@k8s-ci-robot
Copy link
Contributor

@ggriffiths: PR needs rebase.

Details

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 the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 22, 2021
@ggriffiths
Copy link
Contributor Author

ggriffiths commented May 21, 2021

As this PR did not actually decrease the "object has been modified" error count (see earlier comments), I am closing this for now.

I still plan to investigate how this "object has been modified" problem can be solved. It may involve some controller changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/bug Categorizes issue or PR as related to a bug. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use patch instead of update

3 participants