Skip to content

Commit

Permalink
wait DRPC to be deleted
Browse files Browse the repository at this point in the history
Signed-off-by: jacklu <jilu@redhat.com>
  • Loading branch information
jacklu authored and ShyamsundarR committed May 17, 2024
1 parent 54f59d5 commit 24b60ac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions e2e/dractions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func DisableProtection(w workloads.Workload, d deployers.Deployer) error {
return err
}

if err := waitDRPCDeleted(client, namespace, drpcName); err != nil {
return err
}

util.Ctx.Log.Info("get placement " + placementName)

placement, err := getPlacement(client, namespace, placementName)
Expand Down
25 changes: 25 additions & 0 deletions e2e/dractions/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

ramen "github.com/ramendr/ramen/api/v1alpha1"
"github.com/ramendr/ramen/e2e/util"
"k8s.io/apimachinery/pkg/api/errors"
"open-cluster-management.io/api/cluster/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -173,3 +174,27 @@ func waitDRPC(client client.Client, namespace, name, expectedPhase string) error
// then check Conditions
return waitDRPCReady(client, namespace, name)
}

func waitDRPCDeleted(client client.Client, namespace string, name string) error {
startTime := time.Now()

for {
_, err := getDRPC(client, namespace, name)
if err != nil {
if errors.IsNotFound(err) {
util.Ctx.Log.Info("drpc " + name + " is deleted")

return nil
}

util.Ctx.Log.Info(fmt.Sprintf("error to get drpc %s: %v", name, err))
}

if time.Since(startTime) > time.Second*time.Duration(util.Timeout) {
return fmt.Errorf(fmt.Sprintf("drpc %s is not deleted yet before timeout of %v", name, util.Timeout))
}

util.Ctx.Log.Info(fmt.Sprintf("drpc %s is not deleted yet, retry in %v seconds", name, util.TimeInterval))
time.Sleep(time.Second * time.Duration(util.TimeInterval))
}
}

0 comments on commit 24b60ac

Please sign in to comment.