Skip to content

Commit

Permalink
ibmcloud: wait condition for ssh deletion
Browse files Browse the repository at this point in the history
- Add code to wait and check for the SSH key to be deleted to
avoid errors in later delete steps
- Wait for up to 5mins and return an error if the delete hasn't
completed

Fixes: confidential-containers#1303

Signed-off-by: Sudharshan Muralidharan <[email protected]>
  • Loading branch information
sudharshanibm3 authored and stevenhorsman committed Aug 10, 2023
1 parent e466e53 commit aedfc75
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/provisioner/provision_ibmcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"time"

"crypto/sha256"

"sigs.k8s.io/e2e-framework/pkg/envconf"

"github.com/confidential-containers/cloud-api-adaptor/test/utils"
Expand Down Expand Up @@ -479,8 +480,22 @@ func deleteSshKey() error {
if err != nil {
return err
}
log.Infof("SSH Key %s with ID %s is deleted.", IBMCloudProps.SshKeyName, IBMCloudProps.SshKeyID)
return nil
waitMinutes := 5
log.Infof("Waiting for SSH key %s to be removed...", IBMCloudProps.SshKeyID)
for i := 0; i <= waitMinutes; i++ {
foundSsh, err := findSshKey(IBMCloudProps.SshKeyID)
if foundSsh == nil {
log.Infof("SSH Key %s with ID %s is deleted.", IBMCloudProps.SshKeyName, IBMCloudProps.SshKeyID)
return nil
}
if err != nil {
return err
}
log.Infof("Waiting for SSH %s to be removed.", *foundSsh.Name)
log.Infof("Waited %d minutes...", i)
time.Sleep(60 * time.Second)
}
return errors.New("Failed to Delete SSH Key")
}

func isClusterReady(clrName string) (bool, error) {
Expand Down

0 comments on commit aedfc75

Please sign in to comment.