Skip to content

Update Error in Snapshot Status#284

Merged
k8s-ci-robot merged 1 commit intokubernetes-csi:masterfrom
xing-yang:error_status
Jul 22, 2020
Merged

Update Error in Snapshot Status#284
k8s-ci-robot merged 1 commit intokubernetes-csi:masterfrom
xing-yang:error_status

Conversation

@xing-yang
Copy link
Collaborator

@xing-yang xing-yang commented Apr 1, 2020

What type of PR is this?
/kind bug

What this PR does / why we need it:
This PR updates the Error field in the snapshot status based on the status of the content.

Which issue(s) this PR fixes:
Partial fix for #333

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Updates Error field in the snapshot status based on the status of the content.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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 Apr 1, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xing-yang

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 requested review from lpabon and saad-ali April 1, 2020 04:37
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 1, 2020
}
if content.Status.Error.Message != nil {
msg := *content.Status.Error.Message
volumeSnapshotErr.Message = &msg
Copy link
Contributor

Choose a reason for hiding this comment

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

@xing-yang Dont we have to record this event once we set it on the VolumeSnapshot object?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't automatically record an event when updating the status. There's a separate call that does this when needed.

@humblec
Copy link
Contributor

humblec commented May 15, 2020

This looks good to me, however, got a question on the event submission.

readyToUse = *content.Status.ReadyToUse
}
var volumeSnapshotErr *crdv1.VolumeSnapshotError
if content.Status != nil && content.Status.Error != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

To use this change for #333 we need to clear the error in the volume snapshot object, if the content has been created or bound successfully.

volumeSnapshotErr := &crdv1.VolumeSnapshotError{}
if content.status != nil && content.Status.Error != nil {
   // update the error time and message
}

Thoughts @xing-yang ?

Copy link
Collaborator Author

@xing-yang xing-yang Jul 15, 2020

Choose a reason for hiding this comment

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

Yes, makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm, isn't the following sufficient?
volumeSnapshotErr = content.Status.Error.DeepCopy()
I'd say just do it in the code blocks where assignment really happens and delete this whole block. WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure.

newStatus.RestoreSize = resource.NewQuantity(*size, resource.BinarySI)
updated = true
}
if (newStatus.Error == nil && volumeSnapshotErr != nil) || (newStatus.Error != nil && volumeSnapshotErr != nil && newStatus.Error.Time != nil && volumeSnapshotErr.Time != nil && &newStatus.Error.Time != &volumeSnapshotErr.Time) {
Copy link
Contributor

Choose a reason for hiding this comment

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

new status should be updated unconditionally? so that we can clear any error in the volume snapshot object?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure I understand this if statement here: "&newStatus.Error.Time != &volumeSnapshotErr.Time"
and what if newStats.Error != nil but volumeSnapshotErr is nil? in this case, should newStatus.Error be updated to nil as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the Error in both objects are identical, we don't want to make an API update call, but the logic to clear up the error is missing.

@xing-yang xing-yang changed the title WIP: Update Error in Snapshot Status Update Error in Snapshot Status Jul 15, 2020
@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 Jul 15, 2020
readyToUse = *content.Status.ReadyToUse
}
var volumeSnapshotErr *crdv1.VolumeSnapshotError
if content.Status != nil && content.Status.Error != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm, isn't the following sufficient?
volumeSnapshotErr = content.Status.Error.DeepCopy()
I'd say just do it in the code blocks where assignment really happens and delete this whole block. WDYT?

if size != nil {
newStatus.RestoreSize = resource.NewQuantity(*size, resource.BinarySI)
}
if volumeSnapshotErr != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

i.e., here could be simply:
newStats.Error = content.Status.Error.DeepCopy()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure

newStatus.RestoreSize = resource.NewQuantity(*size, resource.BinarySI)
updated = true
}
if (newStatus.Error == nil && volumeSnapshotErr != nil) || (newStatus.Error != nil && volumeSnapshotErr != nil && newStatus.Error.Time != nil && volumeSnapshotErr.Time != nil && &newStatus.Error.Time != &volumeSnapshotErr.Time) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure I understand this if statement here: "&newStatus.Error.Time != &volumeSnapshotErr.Time"
and what if newStats.Error != nil but volumeSnapshotErr is nil? in this case, should newStatus.Error be updated to nil as well?

@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 Jul 18, 2020
@xing-yang xing-yang force-pushed the error_status branch 2 times, most recently from f909fcb to 976ec81 Compare July 21, 2020 02:54
@xing-yang
Copy link
Collaborator Author

Review comments addressed.

expectSuccess: true,
test: testSyncSnapshot,
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking of some more test cases:

  1. vs object status == nil, vs content object status error != nil -> error expected in volume snapshot object error status.
  2. vs object status == nil, vs content object status error == nil, no change expected in volume snapshot object error status.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added two new test cases.
Test case 2 behaves like this: When both statuses are nil, updateSnapshotStatus will create an Status and set boundContentName and set readyToUse to false.

Copy link
Contributor

@saikat-royc saikat-royc left a comment

Choose a reason for hiding this comment

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

The changes looks good to me. Added a comment for couple of new test cases.

@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 Jul 22, 2020
@saikat-royc
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 22, 2020
@k8s-ci-robot k8s-ci-robot merged commit 0c5b535 into kubernetes-csi:master Jul 22, 2020
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 Denotes a PR that will be considered when it comes time to generate release notes. 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.

5 participants