Skip to content

Return VolumeSnapshotContent from various functions instead of nil#527

Merged
k8s-ci-robot merged 1 commit intokubernetes-csi:masterfrom
ggriffiths:removeannvs_beingcreated_returncontent
Jun 17, 2021
Merged

Return VolumeSnapshotContent from various functions instead of nil#527
k8s-ci-robot merged 1 commit intokubernetes-csi:masterfrom
ggriffiths:removeannvs_beingcreated_returncontent

Conversation

@ggriffiths
Copy link
Contributor

@ggriffiths ggriffiths commented May 27, 2021

Signed-off-by: Grant Griffiths ggriffiths@purestorage.com

What type of PR is this?
/kind bug

What this PR does / why we need it:
When removeAnnVolumeSnapshotBeingCreated fails, updatedContent is not returned.

Which issue(s) this PR fixes:
Part of #525

Special notes for your reviewer:
This does not completely fix the problem, but it does seem to lower the count.

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 May 27, 2021
@k8s-ci-robot k8s-ci-robot requested review from j-griffith and pohly May 27, 2021 18:56
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 27, 2021
@ggriffiths ggriffiths changed the title WIP: Return VolumeSnapshotContent from removeAnnVolumeSnapshotBeingCreated Return VolumeSnapshotContent from removeAnnVolumeSnapshotBeingCreated May 27, 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 May 27, 2021
@ggriffiths ggriffiths force-pushed the removeannvs_beingcreated_returncontent branch from ae12aef to f7ed895 Compare May 27, 2021 20:59
@ggriffiths
Copy link
Contributor Author

@jsafrane I have fixed the issue you mentioned with removeAnnVolumeSnapshotBeingCreated. Let me know what you think.

This seems to lower the "object has been modified" count a bit, but it's still not consistently low yet. Either way, I think this is probably heading the right direction.

@jsafrane
Copy link
Contributor

It's a step in the right direction. Every time the sidecar issues Update / UpdateStatus against the API server, it must use the returned objects (with updated ResourceVersion) in all subsequent Update / UpdateStatus calls.

  • setAnnVolumeSnapshotBeingCreated must return content it got from the API server
  • Whole createSnapshotWrapper should not return nil, but some content.
  • When it calls createSnapshotWrapper, it should use the returned object in subsequent updateContentErrorStatusWithEvent and not the original one, i.e. use contentObj instead of content in both these places:

And please check all error paths for returning nil from createSnapshotWrapper / checkandUpdateContentStatusOperation.

@ggriffiths
Copy link
Contributor Author

Ok, I plan to update this PR soon with the above feedback.

@ggriffiths ggriffiths force-pushed the removeannvs_beingcreated_returncontent branch from f7ed895 to bc01c49 Compare June 9, 2021 20:14
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 9, 2021
@ggriffiths ggriffiths changed the title Return VolumeSnapshotContent from removeAnnVolumeSnapshotBeingCreated Return VolumeSnapshotContent from various functions instead of nil Jun 9, 2021
@ggriffiths ggriffiths force-pushed the removeannvs_beingcreated_returncontent branch from bc01c49 to d3aa290 Compare June 9, 2021 21:46
@ggriffiths ggriffiths force-pushed the removeannvs_beingcreated_returncontent branch from d3aa290 to 55b7f3a Compare June 9, 2021 23:17
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 9, 2021
@ggriffiths ggriffiths force-pushed the removeannvs_beingcreated_returncontent branch 2 times, most recently from 796376e to 1f4c62d Compare June 9, 2021 23:35
@ggriffiths
Copy link
Contributor Author

@jsafrane ready for re-review, I've addressed your comments above.

I've also done the following:

  • Searched for return nil, and added a content/snapshot object if possible
  • Searched for all Update/UpdateStatus calls and made sure we were returning the updated objects.

I still see around the same number "object has been modified" error count in our PR tests, but I think these changes are good to do regardless.

@xing-yang
Copy link
Collaborator

@ggriffiths are you saying we don't see the "object has been modified" count getting reduced at all with changes in this PR?

@ggriffiths
Copy link
Contributor Author

ggriffiths commented Jun 10, 2021

@xing-yang I wrote that comment before the final build ran. Up until then, the error count seemed to not be lowered after each commit.

However, with the most recent commit, it seems to be lowered:

1.18 - 10 occurrences of object has been modified - link
1.19 - 28 occurrences of object has been modified - link
1.20 - 42 occurrences of object has been modified - link
1.21 - 26 occurrences of object has been modified - link

if isCSIFinalError(err) {
if removeAnnotationErr := ctrl.removeAnnVolumeSnapshotBeingCreated(content); removeAnnotationErr != nil {
return nil, fmt.Errorf("failed to remove VolumeSnapshotBeingCreated annotation from the content %s: %s", content.Name, removeAnnotationErr)
if content, removeAnnotationErr := ctrl.removeAnnVolumeSnapshotBeingCreated(content); removeAnnotationErr != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

This declares a new variable content, shadowing the existing one. return at line 310 below therefore returns the old content.

With following code, I don't see any "the object has been modified":

var removeAnnotationErr error
if content, removeAnnotationErr = ctrl.removeAnnVolumeSnapshotBeingCreated(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, let me address this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed this

@jsafrane
Copy link
Contributor

I found one issue in the PR, but the rest looks good to me and it reduces nr. of conflicts, at least in my test case (taking snapshot of a non-existing CSI hostpath volume - the driver constantly returns NotFound).

Signed-off-by: Grant Griffiths <ggriffiths@purestorage.com>
@ggriffiths ggriffiths force-pushed the removeannvs_beingcreated_returncontent branch from 1f4c62d to 5cf92fc Compare June 14, 2021 17:47
@ggriffiths ggriffiths requested a review from jsafrane June 14, 2021 22:08
@jsafrane
Copy link
Contributor

/lgtm
Thanks a lot for this PR!

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

/assign @xing-yang

@jsafrane
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ggriffiths, jsafrane

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

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. release-note-none Denotes a PR that doesn't merit a release note. 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.

4 participants