Skip to content

Commit

Permalink
fix graph error handling in az-aro command module (Azure#3093)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitoku authored and ventifus committed Feb 7, 2024
1 parent 2c996b9 commit 447445d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python/az/aro/azext_aro/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def aro_delete(cmd, client, resource_group_name, resource_name, no_wait=False):
if not rp_client_sp_id:
raise ResourceNotFoundError("RP service principal not found.")
except GraphError as e:
logger.info(e.message)
logger.info(e)

# Customers frequently remove the Cluster or RP's service principal permissions.
# Attempt to fix this before performing any action against the cluster
Expand Down Expand Up @@ -560,9 +560,9 @@ def cluster_application_update(cli_ctx,
raise ResourceNotFoundError("RP service principal not found.")
except GraphError as e:
if fail:
logger.error(e.message)
logger.error(e)
raise
logger.info(e.message)
logger.info(e)

# refresh_cluster_credentials refreshes cluster SP application.
# At firsts it tries to re-use existing application and generate new password.
Expand All @@ -579,17 +579,17 @@ def cluster_application_update(cli_ctx,
else:
client_secret = aad.add_password(app)
except GraphError as e:
logger.error(e.message)
logger.error(e)
raise

# attempt to get/create SP if one was not found.
try:
client_sp_id = aad.get_service_principal_id(client_id or oc.service_principal_profile.client_id)
except GraphError as e:
if fail:
logger.error(e.message)
logger.error(e)
raise
logger.info(e.message)
logger.info(e)

if fail and not client_sp_id:
client_sp_id = aad.create_service_principal(client_id or oc.service_principal_profile.client_id)
Expand Down

0 comments on commit 447445d

Please sign in to comment.