Skip to content

Commit

Permalink
[AKS] support --yes for az aks mesh upgrade commands. (#7508)
Browse files Browse the repository at this point in the history
  • Loading branch information
deveshdama authored Apr 24, 2024
1 parent 897b5ed commit 5498d0e
Show file tree
Hide file tree
Showing 7 changed files with 3,542 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ To release a new version, please select a new version number (usually plus 1 to

Pending
+++++++

3.0.0b7
+++++++
* Support `--yes` for `az aks mesh upgrade rollback` and `az aks mesh upgrade complete` commands.
* Correct the property disable_outbound_nat in windows_profile and add UT.
* Minimise the roles needed to introduce for Elastic SAN for enabling Azure Container Storage with elasticSan storagepool type.

Expand Down
16 changes: 16 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,22 @@ 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"
)

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

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
11 changes: 8 additions & 3 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3033,26 +3033,31 @@ def aks_mesh_upgrade_complete(
cmd,
client,
resource_group_name,
name):
name,
yes=False
):
return _aks_mesh_update(
cmd,
client,
resource_group_name,
name,
yes=yes,
mesh_upgrade_command=CONST_AZURE_SERVICE_MESH_UPGRADE_COMMAND_COMPLETE)


def aks_mesh_upgrade_rollback(
cmd,
client,
resource_group_name,
name
name,
yes=False
):
return _aks_mesh_update(
cmd,
client,
resource_group_name,
name,
yes=yes,
mesh_upgrade_command=CONST_AZURE_SERVICE_MESH_UPGRADE_COMMAND_ROLLBACK)


Expand All @@ -3075,6 +3080,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 @@ -3088,7 +3094,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 @@ -2174,6 +2174,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 @@ -2203,9 +2204,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
Loading

0 comments on commit 5498d0e

Please sign in to comment.