mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-20 21:35:42 +00:00
Adding error message to catch Model HttpResponseError. (#2384)
* Adding error message to catch Model HttpResponseError. * Changing error message. * Formatting.
This commit is contained in:
committed by
GitHub
parent
f22dee18df
commit
4f1ac523da
@ -106,6 +106,17 @@ def resize_vmss(name: UUID, capacity: int) -> None:
|
|||||||
capacity,
|
capacity,
|
||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
|
except HttpResponseError as err:
|
||||||
|
if (
|
||||||
|
"models that may be referenced by one or more"
|
||||||
|
+ " VMs belonging to the Virtual Machine Scale Set"
|
||||||
|
in str(err)
|
||||||
|
):
|
||||||
|
logging.error(
|
||||||
|
"unable to resize scaleset due to model error. name: %s - err:%s",
|
||||||
|
name,
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@retry_on_auth_failure()
|
@retry_on_auth_failure()
|
||||||
@ -206,6 +217,18 @@ def update_scale_in_protection(
|
|||||||
% instance_id
|
% instance_id
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
if (
|
||||||
|
"models that may be referenced by one or more"
|
||||||
|
+ " VMs belonging to the Virtual Machine Scale Set"
|
||||||
|
in str(err)
|
||||||
|
):
|
||||||
|
logging.error(
|
||||||
|
"unable to resize scaleset due to model error. name: %s - err:%s",
|
||||||
|
name,
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
|
||||||
return Error(
|
return Error(
|
||||||
code=ErrorCode.UNABLE_TO_UPDATE,
|
code=ErrorCode.UNABLE_TO_UPDATE,
|
||||||
errors=["unable to set protection policy on: %s:%s" % (vm_id, instance_id)],
|
errors=["unable to set protection policy on: %s:%s" % (vm_id, instance_id)],
|
||||||
@ -302,12 +325,28 @@ def update_extensions(name: UUID, extensions: List[Any]) -> None:
|
|||||||
resource_group = get_base_resource_group()
|
resource_group = get_base_resource_group()
|
||||||
logging.info("updating VM extensions: %s", name)
|
logging.info("updating VM extensions: %s", name)
|
||||||
compute_client = get_compute_client()
|
compute_client = get_compute_client()
|
||||||
|
try:
|
||||||
compute_client.virtual_machine_scale_sets.begin_update(
|
compute_client.virtual_machine_scale_sets.begin_update(
|
||||||
resource_group,
|
resource_group,
|
||||||
str(name),
|
str(name),
|
||||||
{"virtual_machine_profile": {"extension_profile": {"extensions": extensions}}},
|
{
|
||||||
|
"virtual_machine_profile": {
|
||||||
|
"extension_profile": {"extensions": extensions}
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
logging.info("VM extensions updated: %s", name)
|
logging.info("VM extensions updated: %s", name)
|
||||||
|
except HttpResponseError as err:
|
||||||
|
if (
|
||||||
|
"models that may be referenced by one or more"
|
||||||
|
+ " VMs belonging to the Virtual Machine Scale Set"
|
||||||
|
in str(err)
|
||||||
|
):
|
||||||
|
logging.error(
|
||||||
|
"unable to resize scaleset due to model error. name: %s - err:%s",
|
||||||
|
name,
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@retry_on_auth_failure()
|
@retry_on_auth_failure()
|
||||||
|
Reference in New Issue
Block a user