rbac: improve 'create-for-rbac'#1499
Conversation
b72f7ff to
62a6c4a
Compare
|
//cc: @derekbekoe @tjprescott |
| def _create_role_assignment(role, assignee, resource_group_name=None, scope=None, | ||
| ocp_aad_session_key=None): | ||
| def _create_role_assignment(role, assignee, resource_group_name=None, scope=None, #pylint: disable=too-many-arguments | ||
| ocp_aad_session_key=None, resolve_assignee=True): |
There was a problem hiding this comment.
Should we have help for this parameter?
There was a problem hiding this comment.
this is an internal method which is not exposed as a command
| return _create_service_principal(identifier) | ||
|
|
||
| def _create_service_principal(identifier, retain_raw_response=False): | ||
| def _create_service_principal(identifier, retain_raw_response=False, resolve_app=True): |
There was a problem hiding this comment.
Same like my previous comment
| import time | ||
| graph_client = _graph_client_factory() | ||
| role_client = _auth_client_factory().role_assignments | ||
| role = role or 'contributor' |
There was a problem hiding this comment.
The parameter default is Contributor. Does the casing matter?
Actually, do you need this or statement if there is a default set at the top?
There was a problem hiding this comment.
Casing doesn't matter, but yes this code is redundant as we have a default set at the top
| time.sleep(5) | ||
| else: | ||
| logger.warning("Creating service principal failed for appid '%s'. Trace followed:\n%s", | ||
| name, ex.response.headers) #pylint: disable=no-member |
There was a problem hiding this comment.
Should we log the detailed trace to logger.debug and then raise CLIError("Creating service principal failed for appid '%s'.").
It appears that logging a warning and then calling raise would print the full stacktrace to the console?
There was a problem hiding this comment.
Let us do it later.
For now, logging as a warn by default will display the correlation id to give it to the service team to investigate. Using --debug changes the timing and hence it becomes hard to reproduce.
| except Exception as ex: #pylint: disable=broad-except | ||
| #pylint: disable=line-too-long | ||
| if 'The appId of the service principal does not reference a valid application object' in str(ex): | ||
| time.sleep(5) |
There was a problem hiding this comment.
Consider: Add logger.warning message indicating that it is retrying something and what retry number you're currently on e.g. (Retry 3/12).
| break | ||
| except Exception as ex: | ||
| if ' does not exist in the directory ' in str(ex): | ||
| time.sleep(5) |
There was a problem hiding this comment.
Again, suggest retry warning messages so user is informed.
|
@derekbekoe, please take another look. |
|
@yugangw-msft Have the changes been pushed here? |
|
@derekbekoe, sorry, I just now pushed. |
* replace sdks * new sdk * some hacks for recording files and python sdk * fix version * add param for storage account id * finish BYOS for app insight * finish link LA to AI * replace new sdk * change the python sdk * replase new sdk * change to latest sdk * support public access * fux * add history * fix style * has not been fixed in server * fix
Fix #1190, Fix #1332
Includes:
//cc: @colemickens, @ahmetalpbalkan