mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-16 11:58:09 +00:00
Update deploy to set all settings at once (#2325)
This commit is contained in:
@ -1115,25 +1115,39 @@ class Client:
|
|||||||
map(expand_agent, self.enable_dotnet)
|
map(expand_agent, self.enable_dotnet)
|
||||||
)
|
)
|
||||||
|
|
||||||
func = shutil.which("az")
|
python_settings = []
|
||||||
assert func is not None
|
dotnet_settings = []
|
||||||
|
|
||||||
for function_name in enable_dotnet:
|
for function_name in enable_dotnet:
|
||||||
format_name = function_name.split("_")
|
format_name = function_name.split("_")
|
||||||
dotnet_name = "".join(x.title() for x in format_name)
|
dotnet_name = "".join(x.title() for x in format_name)
|
||||||
error: Optional[subprocess.CalledProcessError] = None
|
|
||||||
max_tries = 5
|
|
||||||
for i in range(max_tries):
|
|
||||||
try:
|
|
||||||
# keep the python versions of http function to allow the service to be backward compatible
|
# keep the python versions of http function to allow the service to be backward compatible
|
||||||
# with older version of the CLI and the agents
|
# with older version of the CLI and the agents
|
||||||
if function_name.startswith(
|
if function_name.startswith("queue_") or function_name.startswith(
|
||||||
"queue_"
|
"timer_"
|
||||||
) or function_name.startswith("timer_"):
|
):
|
||||||
logger.info(f"disabling PYTHON function: {function_name}")
|
logger.info(f"disabling PYTHON function: {function_name}")
|
||||||
disable_python = "1"
|
disable_python = "1"
|
||||||
else:
|
else:
|
||||||
logger.info(f"enabling PYTHON function: {function_name}")
|
logger.info(f"enabling PYTHON function: {function_name}")
|
||||||
disable_python = "0"
|
disable_python = "0"
|
||||||
|
|
||||||
|
python_settings.append(
|
||||||
|
f"AzureWebJobs.{function_name}.Disabled={disable_python}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# enable dotnet function
|
||||||
|
logger.info(f"enabling DOTNET function: {dotnet_name}")
|
||||||
|
dotnet_settings.append(f"AzureWebJobs.{dotnet_name}.Disabled=0")
|
||||||
|
|
||||||
|
func = shutil.which("az")
|
||||||
|
assert func is not None
|
||||||
|
|
||||||
|
max_tries = 5
|
||||||
|
error: Optional[subprocess.CalledProcessError] = None
|
||||||
|
for i in range(max_tries):
|
||||||
|
try:
|
||||||
|
logger.info("updating Python settings")
|
||||||
subprocess.check_output(
|
subprocess.check_output(
|
||||||
[
|
[
|
||||||
func,
|
func,
|
||||||
@ -1146,13 +1160,11 @@ class Client:
|
|||||||
"--resource-group",
|
"--resource-group",
|
||||||
self.application_name,
|
self.application_name,
|
||||||
"--settings",
|
"--settings",
|
||||||
f"AzureWebJobs.{function_name}.Disabled={disable_python}",
|
]
|
||||||
],
|
+ python_settings,
|
||||||
env=dict(os.environ, CLI_DEBUG="1"),
|
env=dict(os.environ, CLI_DEBUG="1"),
|
||||||
)
|
)
|
||||||
|
logger.info("updating .NET settings")
|
||||||
# enable dotnet function
|
|
||||||
logger.info(f"enabling DOTNET function: {dotnet_name}")
|
|
||||||
subprocess.check_output(
|
subprocess.check_output(
|
||||||
[
|
[
|
||||||
func,
|
func,
|
||||||
@ -1165,8 +1177,8 @@ class Client:
|
|||||||
"--resource-group",
|
"--resource-group",
|
||||||
self.application_name,
|
self.application_name,
|
||||||
"--settings",
|
"--settings",
|
||||||
f"AzureWebJobs.{dotnet_name}.Disabled=0",
|
]
|
||||||
],
|
+ dotnet_settings,
|
||||||
env=dict(os.environ, CLI_DEBUG="1"),
|
env=dict(os.environ, CLI_DEBUG="1"),
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
@ -1175,11 +1187,10 @@ class Client:
|
|||||||
if i + 1 < max_tries:
|
if i + 1 < max_tries:
|
||||||
logger.debug("func failure error: %s", err)
|
logger.debug("func failure error: %s", err)
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"{function_name} function didn't respond to "
|
"unable to update settings, waiting 60 seconds and trying again"
|
||||||
"status change request, waiting 60 seconds "
|
|
||||||
"and trying again"
|
|
||||||
)
|
)
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
|
|
||||||
if error is not None:
|
if error is not None:
|
||||||
raise error
|
raise error
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user