Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change status to ReadyToUse to true for VolumeSnapshot #752

Merged
merged 7 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions pkg/kube/snapshot/snapshot_alpha.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,21 @@ func (sna *SnapshotAlpha) CreateFromSource(ctx context.Context, source *Source,
if !waitForReady {
return nil
}
if source.Driver == "csi-vxflexos.dellemc.com" {
bathina2 marked this conversation as resolved.
Show resolved Hide resolved
us, err := sna.dynCli.Resource(v1alpha1.VolSnapGVR).Namespace(namespace).Get(ctx, snap.GetName(), metav1.GetOptions{})
if err != nil {
return err
}
status, ok := us.Object["status"].(map[string]interface{})
if !ok {
errors.Errorf("Failed to convert status to map, Volumesnapshot: %s, Status: %v", snap.GetName(), status)
}
status["readyToUse"] = true
us.Object["status"] = status
if _, err := sna.dynCli.Resource(v1alpha1.VolSnapGVR).Namespace(namespace).UpdateStatus(ctx, us, metav1.UpdateOptions{}); err != nil {
Copy link

Choose a reason for hiding this comment

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

Can we use Patch here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont think you can patch a status. That why UpdateStatus does a PUT internally to replace the whole object

Copy link

Choose a reason for hiding this comment

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

Got it - sounds good.

return errors.Errorf("Failed to update status, Volumesnapshot: %s, Error: %v", snap.GetName(), err)
}
}

return sna.WaitOnReadyToUse(ctx, snapshotName, namespace)
}
Expand Down
16 changes: 15 additions & 1 deletion pkg/kube/snapshot/snapshot_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,21 @@ func (sna *SnapshotBeta) CreateFromSource(ctx context.Context, source *Source, s
if !waitForReady {
return nil
}

if source.Driver == "csi-vxflexos.dellemc.com" {
us, err := sna.dynCli.Resource(v1beta1.VolSnapGVR).Namespace(namespace).Get(ctx, snap.GetName(), metav1.GetOptions{})
if err != nil {
return err
}
status, ok := us.Object["status"].(map[string]interface{})
if !ok {
errors.Errorf("Failed to convert status to map, Volumesnapshot: %s, Status: %v", snap.GetName(), status)
}
status["readyToUse"] = true
us.Object["status"] = status
if _, err := sna.dynCli.Resource(v1beta1.VolSnapGVR).Namespace(namespace).UpdateStatus(ctx, us, metav1.UpdateOptions{}); err != nil {
return errors.Errorf("Failed to update status, Volumesnapshot: %s, Error: %v", snap.GetName(), err)
}
}
err = sna.WaitOnReadyToUse(ctx, snapshotName, namespace)
return err
}
Expand Down