mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-15 11:28:09 +00:00
handle delayed AAD resources in deployments (#585)
This commit is contained in:
@ -384,6 +384,13 @@ class Client:
|
|||||||
mode=DeploymentMode.incremental, template=template, parameters=params
|
mode=DeploymentMode.incremental, template=template, parameters=params
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
count = 0
|
||||||
|
tries = 10
|
||||||
|
error: Optional[Exception] = None
|
||||||
|
while count < tries:
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
try:
|
||||||
result = client.deployments.create_or_update(
|
result = client.deployments.create_or_update(
|
||||||
self.resource_group, gen_guid(), deployment
|
self.resource_group, gen_guid(), deployment
|
||||||
).result()
|
).result()
|
||||||
@ -394,6 +401,23 @@ class Client:
|
|||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
self.results["deploy"] = result.properties.outputs
|
self.results["deploy"] = result.properties.outputs
|
||||||
|
return
|
||||||
|
except Exception as err:
|
||||||
|
error = err
|
||||||
|
as_repr = repr(err)
|
||||||
|
# Modeled after Azure-CLI. See:
|
||||||
|
# https://github.com/Azure/azure-cli/blob/
|
||||||
|
# 3a2f6009cff788fde3b0170823c9129f187b2812/src/azure-cli-core/
|
||||||
|
# azure/cli/core/commands/arm.py#L1086
|
||||||
|
if (
|
||||||
|
"PrincipalNotFound" in as_repr
|
||||||
|
and "does not exist in the directory" in as_repr
|
||||||
|
):
|
||||||
|
logging.info("application principal not available in AAD yet")
|
||||||
|
if error:
|
||||||
|
raise error
|
||||||
|
else:
|
||||||
|
raise Exception("unknown error deploying")
|
||||||
|
|
||||||
def assign_scaleset_identity_role(self) -> None:
|
def assign_scaleset_identity_role(self) -> None:
|
||||||
if self.upgrade:
|
if self.upgrade:
|
||||||
|
@ -235,6 +235,14 @@ def add_application_password(app_object_id: UUID) -> Tuple[str, str]:
|
|||||||
return add_application_password_impl(app_object_id)
|
return add_application_password_impl(app_object_id)
|
||||||
except GraphQueryError as err:
|
except GraphQueryError as err:
|
||||||
error = err
|
error = err
|
||||||
|
# modeled after AZ-CLI's handling of missing application
|
||||||
|
# See: https://github.com/Azure/azure-cli/blob/
|
||||||
|
# e015d5bcba0c2d21dc42189daa43dc1eb82d2485/src/azure-cli/
|
||||||
|
# azure/cli/command_modules/util/tests/
|
||||||
|
# latest/test_rest.py#L191-L192
|
||||||
|
if "Request_ResourceNotFound" in repr(err):
|
||||||
|
logging.info("app unavailable in AAD, unable to create password yet")
|
||||||
|
else:
|
||||||
logging.warning("unable to create app password: %s", err.message)
|
logging.warning("unable to create app password: %s", err.message)
|
||||||
time.sleep(wait_duration)
|
time.sleep(wait_duration)
|
||||||
if error:
|
if error:
|
||||||
|
Reference in New Issue
Block a user