Update Error in Snapshot Status#284
Conversation
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
| } | ||
| if content.Status.Error.Message != nil { | ||
| msg := *content.Status.Error.Message | ||
| volumeSnapshotErr.Message = &msg |
There was a problem hiding this comment.
@xing-yang Dont we have to record this event once we set it on the VolumeSnapshot object?
There was a problem hiding this comment.
We don't automatically record an event when updating the status. There's a separate call that does this when needed.
|
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 { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Yes, makes sense.
There was a problem hiding this comment.
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?
| 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) { |
There was a problem hiding this comment.
new status should be updated unconditionally? so that we can clear any error in the volume snapshot object?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| readyToUse = *content.Status.ReadyToUse | ||
| } | ||
| var volumeSnapshotErr *crdv1.VolumeSnapshotError | ||
| if content.Status != nil && content.Status.Error != nil { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
i.e., here could be simply:
newStats.Error = content.Status.Error.DeepCopy()?
| 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) { |
There was a problem hiding this comment.
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?
f909fcb to
976ec81
Compare
|
Review comments addressed. |
| expectSuccess: true, | ||
| test: testSyncSnapshot, | ||
| }, | ||
| { |
There was a problem hiding this comment.
Thinking of some more test cases:
- vs object status == nil, vs content object status error != nil -> error expected in volume snapshot object error status.
- vs object status == nil, vs content object status error == nil, no change expected in volume snapshot object error status.
There was a problem hiding this comment.
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.
saikat-royc
left a comment
There was a problem hiding this comment.
The changes looks good to me. Added a comment for couple of new test cases.
|
/lgtm |
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?: