Skip to content

Commit

Permalink
Add WaitUntilVolumeSnapshotReady
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Feb 9, 2024
1 parent 88a3ed3 commit dce29bf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions volumesnapshot/v1/volumesnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1

import (
"context"
"time"

jsonpatch "github.com/evanphx/json-patch/v5"
api "github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumesnapshot/v1"
Expand Down Expand Up @@ -99,3 +100,12 @@ func TryUpdateVolumeSnapshot(ctx context.Context, c cs.Interface, meta metav1.Ob
}
return
}

func WaitUntilVolumeSnapshotReady(c cs.Interface, meta types.NamespacedName) error {
return wait.PollUntilContextTimeout(context.TODO(), kutil.RetryInterval, 2*time.Hour, true, func(ctx context.Context) (bool, error) {
if obj, err := c.SnapshotV1().VolumeSnapshots(meta.Namespace).Get(context.TODO(), meta.Name, metav1.GetOptions{}); err == nil {
return obj.Status != nil && obj.Status.ReadyToUse != nil && *obj.Status.ReadyToUse, nil
}
return false, nil
})
}

0 comments on commit dce29bf

Please sign in to comment.