vendor update sched-ops
@@ -2,8 +2,12 @@ package stork
import (
"context"
+ "fmt"
+ "time"
storkv1alpha1 "github.com/libopenstorage/stork/pkg/apis/stork/v1alpha1"
+ "github.com/portworx/sched-ops/k8s/errors"
+ "github.com/portworx/sched-ops/task"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@@ -19,6 +23,8 @@ type ResourceTransformOps interface {
UpdateResourceTransformation(*storkv1alpha1.ResourceTransformation) (*storkv1alpha1.ResourceTransformation, error)
// DeleteResourceTransformation deletes the ResourceTransformation
DeleteResourceTransformation(string, string) error
+ // ValidateResourceTransformation validates resource transformation status
+ ValidateResourceTransformation(string, string, time.Duration, time.Duration) error
}
// CreateResourceTransformation creates the ResourceTransformation
@@ -70,3 +76,38 @@ func (c *Client) DeleteResourceTransformation(name string, namespace string) err
PropagationPolicy: &deleteForegroundPolicy,
})
}
+
+// ValidateResourceTransformation validates ResourceTransformation CR status
+func (c *Client) ValidateResourceTransformation(name string, namespace string, timeout, retryInterval time.Duration) error {
+ if err := c.initClient(); err != nil {
+ return err
+ }
+ t := func() (interface{}, bool, error) {
+ transform, err := c.GetResourceTransformation(name, namespace)
+ if err != nil {
+ return "", true, err
+ }
+
+ if transform.Status.Status == storkv1alpha1.ResourceTransformationStatusReady {
+ return "", false, nil
+ } else if transform.Status.Status == storkv1alpha1.ResourceTransformationStatusFailed {
+ return "", true, &errors.ErrFailedToValidateCustomSpec{
+ Name: name,
+ Cause: fmt.Sprintf("Status: %v \t Resource Spec: %v", transform.Status.Status, transform.Status.Resources),
+ Type: transform,
+ }
+ }
+
+ return "", true, &errors.ErrFailedToValidateCustomSpec{
+ Name: name,
+ Cause: fmt.Sprintf("Status: %v", transform.Status.Status),
+ Type: transform,
+ }
+ }
+
+ if _, err := task.DoRetryWithTimeout(t, timeout, retryInterval); err != nil {
+ return err
+ }
+
+ return nil
+}
