Skip to content

Commit

Permalink
OCM-10438 | ci: Enhance account-roles list due to a known issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwang-RH committed Aug 19, 2024
1 parent f9de39b commit 2bde52e
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tests/utils/profilehandler/data_preparation.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,22 @@ func PrepareAccountRoles(client *rosacli.Client,
if err != nil {
return
}
accRoleList, output, err := client.OCMResource.ListAccountRole()
if err != nil {
err = fmt.Errorf("error happens when list account-roles, %s", output.String())
return
var accoutRoles *rosacli.AccountRolesUnit
maxRetries := 3
for i := 0; i < maxRetries; i++ {
accRoleList, output, err := client.OCMResource.ListAccountRole()
if err != nil && strings.Contains(err.Error(), "cannot be found") {
log.Logger.Infof("Some IAM role cannot be found, Retrying... (%d/%d)\n", i+1, maxRetries)
continue
} else if err != nil && !strings.Contains(err.Error(), "cannot be found") {
err = fmt.Errorf("error happens when list account-roles, %s", output.String())
return &rosacli.AccountRolesUnit{}, err
} else {
accoutRoles = accRoleList.DigAccountRoles(namePrefix, hcp)
break
}
}
roleDig := accRoleList.DigAccountRoles(namePrefix, hcp)

return roleDig, nil
return accoutRoles, nil

}

Expand Down

0 comments on commit 2bde52e

Please sign in to comment.