Skip to content

Commit

Permalink
skip deletion if rolename is not present (#197)
Browse files Browse the repository at this point in the history
Signed-off-by: Yu Jiang <[email protected]>
Co-authored-by: Yu Jiang <[email protected]>
  • Loading branch information
carlyjiang and Yu Jiang authored Mar 29, 2024
1 parent 1d6c5e5 commit 0c3ca58
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/controllers/iamrole_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ func (r *IamroleReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
iamRole.Status.RetryCount = iamRole.Status.RetryCount + 1
}
log.Info("Iamrole delete request")
if iamRole.Status.State != iammanagerv1alpha1.PolicyNotAllowed {

// If PolicyNotAllowed, we should not have any role created.
// If RoleNameNotAvailable, the role should be deleted.
if iamRole.Status.State != iammanagerv1alpha1.PolicyNotAllowed && iamRole.Status.RoleName != "" {
//Get the roleName from status
roleName := iamRole.Status.RoleName
if err := r.IAMClient.DeleteRole(ctx, roleName); err != nil {
Expand Down

0 comments on commit 0c3ca58

Please sign in to comment.