Skip to content

Commit

Permalink
supress confirmation for asm upgrade rollback command with --yes para…
Browse files Browse the repository at this point in the history
…meter
  • Loading branch information
deveshdama committed Apr 16, 2024
1 parent 3de4ab4 commit 7cbbe3e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,15 @@ def load_arguments(self, _):
"revision", validator=validate_azure_service_mesh_revision, required=True
)

with self.argument_context("aks mesh upgrade rollback") as c:
c.argument(
"yes",
options_list=["--yes", "-y"],
help="Do not prompt for confirmation.",
action="store_true",
required=False
)

with self.argument_context("aks approuting enable") as c:
c.argument("enable_kv", action="store_true")
c.argument("keyvault_id", options_list=["--attach-kv"])
Expand Down
6 changes: 4 additions & 2 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3039,13 +3039,15 @@ def aks_mesh_upgrade_rollback(
cmd,
client,
resource_group_name,
name
name,
yes
):
return _aks_mesh_update(
cmd,
client,
resource_group_name,
name,
yes=yes,
mesh_upgrade_command=CONST_AZURE_SERVICE_MESH_UPGRADE_COMMAND_ROLLBACK)


Expand All @@ -3068,6 +3070,7 @@ def _aks_mesh_update(
enable_egress_gateway=None,
disable_egress_gateway=None,
revision=None,
yes=False,
mesh_upgrade_command=None,
):
raw_parameters = locals()
Expand All @@ -3081,7 +3084,6 @@ def _aks_mesh_update(
raw_parameters=raw_parameters,
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
)

try:
mc = aks_update_decorator.fetch_mc()
mc = aks_update_decorator.update_azure_service_mesh_profile(mc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2123,6 +2123,7 @@ def get_initial_service_mesh_profile(self) -> ServiceMeshProfile:

def _handle_upgrade_asm(self, new_profile: ServiceMeshProfile) -> Tuple[ServiceMeshProfile, bool]:
mesh_upgrade_command = self.raw_param.get("mesh_upgrade_command", None)
supress_confirmation = self.raw_param.get("yes", False)
updated = False

# deal with mesh upgrade commands
Expand Down Expand Up @@ -2152,9 +2153,10 @@ def _handle_upgrade_asm(self, new_profile: ServiceMeshProfile) -> Tuple[ServiceM
f"Please ensure all data plane workloads have been rolled over to revision {revision_to_keep} "
"so that they are still part of the mesh.\nAre you sure you want to proceed?"
)
if prompt_y_n(msg, default="y"):
new_profile.istio.revisions.remove(revision_to_remove)
updated = True
if not supress_confirmation and not prompt_y_n(msg, default="n"):
raise DecoratorEarlyExitException()
new_profile.istio.revisions.remove(revision_to_remove)
updated = True
elif (
mesh_upgrade_command == CONST_AZURE_SERVICE_MESH_UPGRADE_COMMAND_START and
requested_revision is not None
Expand Down

0 comments on commit 7cbbe3e

Please sign in to comment.