Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AKS] Prompt when disabling CSI Drivers #4868

Merged
merged 1 commit into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++

0.5.78
++++++

* Prompt when disabling CSI Drivers.

0.5.77
++++++

Expand Down
20 changes: 10 additions & 10 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ def load_arguments(self, _):
c.argument('gmsa_root_domain_name')
c.argument('attach_acr', acr_arg_type)
c.argument('skip_subnet_role_assignment', action='store_true')
c.argument('disk_driver_version', arg_type=get_enum_type(disk_driver_versions))
c.argument('disable_disk_driver', action='store_true')
c.argument('disable_file_driver', action='store_true')
c.argument('disable_snapshot_controller', action='store_true')
# addons
c.argument('enable_addons', options_list=['--enable-addons', '-a'], validator=validate_addons)
c.argument('workspace_resource_id')
Expand Down Expand Up @@ -272,10 +276,6 @@ def load_arguments(self, _):
c.argument('enable_fips_image', action='store_true')
c.argument('kubelet_config')
c.argument('linux_os_config')
c.argument('disk_driver_version', arg_type=get_enum_type(disk_driver_versions))
c.argument('disable_disk_driver', arg_type=get_three_state_flag())
c.argument('disable_file_driver', arg_type=get_three_state_flag())
c.argument('disable_snapshot_controller', arg_type=get_three_state_flag())
c.argument('yes', options_list=[
'--yes', '-y'], help='Do not prompt for confirmation.', action='store_true')
c.argument('aks_custom_headers')
Expand Down Expand Up @@ -340,13 +340,13 @@ def load_arguments(self, _):
c.argument('enable_windows_gmsa', action='store_true')
c.argument('gmsa_dns_server')
c.argument('gmsa_root_domain_name')
c.argument('enable_disk_driver', arg_type=get_three_state_flag())
c.argument('enable_disk_driver', action='store_true')
c.argument('disk_driver_version', arg_type=get_enum_type(disk_driver_versions))
c.argument('disable_disk_driver', arg_type=get_three_state_flag())
c.argument('enable_file_driver', arg_type=get_three_state_flag())
c.argument('disable_file_driver', arg_type=get_three_state_flag())
c.argument('enable_snapshot_controller', arg_type=get_three_state_flag())
c.argument('disable_snapshot_controller', arg_type=get_three_state_flag())
c.argument('disable_disk_driver', action='store_true')
c.argument('enable_file_driver', action='store_true')
c.argument('disable_file_driver', action='store_true')
c.argument('enable_snapshot_controller', action='store_true')
c.argument('disable_snapshot_controller', action='store_true')
c.argument('attach_acr', acr_arg_type, validator=validate_acr)
c.argument('detach_acr', acr_arg_type, validator=validate_acr)
# addons
Expand Down
18 changes: 9 additions & 9 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,9 @@ def aks_create(cmd,
edge_zone=None,
enable_secret_rotation=False,
disk_driver_version=None,
disable_disk_driver=None,
disable_file_driver=None,
disable_snapshot_controller=None,
disable_disk_driver=False,
ZeroMagic marked this conversation as resolved.
Show resolved Hide resolved
disable_file_driver=False,
disable_snapshot_controller=False,
rotation_poll_interval=None,
disable_local_accounts=False,
no_wait=False,
Expand Down Expand Up @@ -880,13 +880,13 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
enable_secret_rotation=False,
disable_secret_rotation=False,
rotation_poll_interval=None,
enable_disk_driver=None,
enable_disk_driver=False,
ZeroMagic marked this conversation as resolved.
Show resolved Hide resolved
disk_driver_version=None,
disable_disk_driver=None,
enable_file_driver=None,
disable_file_driver=None,
enable_snapshot_controller=None,
disable_snapshot_controller=None,
disable_disk_driver=False,
enable_file_driver=False,
disable_file_driver=False,
enable_snapshot_controller=False,
disable_snapshot_controller=False,
disable_local_accounts=False,
enable_local_accounts=False,
enable_public_fqdn=False,
Expand Down
21 changes: 17 additions & 4 deletions src/aks-preview/azext_aks_preview/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1717,13 +1717,14 @@ def get_node_vm_size(self) -> str:
return self._get_node_vm_size()

def get_disk_driver(self) -> Optional[ManagedClusterStorageProfileDiskCSIDriver]:
"""Obtrain the value of storage_profile.disk_csi_driver
"""Obtain the value of storage_profile.disk_csi_driver

:return: Optional[ManagedClusterStorageProfileDiskCSIDriver]
"""
enable_disk_driver = self.raw_param.get("enable_disk_driver")
disable_disk_driver = self.raw_param.get("disable_disk_driver")
disk_driver_version = self.raw_param.get("disk_driver_version")

if not enable_disk_driver and not disable_disk_driver and not disk_driver_version:
return None
profile = self.models.ManagedClusterStorageProfileDiskCSIDriver()
Expand Down Expand Up @@ -1759,17 +1760,21 @@ def get_disk_driver(self) -> Optional[ManagedClusterStorageProfileDiskCSIDriver]
if disk_driver_version:
profile.version = disk_driver_version
elif disable_disk_driver:
msg = "Please make sure there are no existing PVs and PVCs that are used by AzureDisk CSI driver before disabling."
if not self.get_yes() and not prompt_y_n(msg, default="n"):
raise DecoratorEarlyExitException()
Comment on lines +1763 to +1765
Copy link
Contributor

@zhoxing-ms zhoxing-ms Jun 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask will the execution of CLI scripts in the automation scenario be blocked by such interactive steps that require input?

Copy link
Contributor Author

@ZeroMagic ZeroMagic Jun 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. but -y can be added into scripts like what we do in test_aks_command.py

profile.enabled = False

return profile

def get_file_driver(self) -> Optional[ManagedClusterStorageProfileFileCSIDriver]:
"""Obtrain the value of storage_profile.file_csi_driver
"""Obtain the value of storage_profile.file_csi_driver

:return: Optional[ManagedClusterStorageProfileFileCSIDriver]
"""
enable_file_driver = self.raw_param.get("enable_file_driver")
disable_file_driver = self.raw_param.get("disable_file_driver")

if not enable_file_driver and not disable_file_driver:
return None
profile = self.models.ManagedClusterStorageProfileFileCSIDriver()
Expand All @@ -1790,17 +1795,21 @@ def get_file_driver(self) -> Optional[ManagedClusterStorageProfileFileCSIDriver]
if enable_file_driver:
profile.enabled = True
elif disable_file_driver:
msg = "Please make sure there are no existing PVs and PVCs that are used by AzureFile CSI driver before disabling."
if not self.get_yes() and not prompt_y_n(msg, default="n"):
raise DecoratorEarlyExitException()
Comment on lines +1798 to +1800
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

profile.enabled = False

return profile

def get_snapshot_controller(self) -> Optional[ManagedClusterStorageProfileSnapshotController]:
"""Obtrain the value of storage_profile.snapshot_controller
"""Obtain the value of storage_profile.snapshot_controller

:return: Optional[ManagedClusterStorageProfileSnapshotController]
"""
enable_snapshot_controller = self.raw_param.get("enable_snapshot_controller")
disable_snapshot_controller = self.raw_param.get("disable_snapshot_controller")

if not enable_snapshot_controller and not disable_snapshot_controller:
return None

Expand All @@ -1822,12 +1831,16 @@ def get_snapshot_controller(self) -> Optional[ManagedClusterStorageProfileSnapsh
if enable_snapshot_controller:
profile.enabled = True
elif disable_snapshot_controller:
msg = "Please make sure there are no existing VolumeSnapshots, VolumeSnapshotClasses and VolumeSnapshotContents " \
"that are used by the snapshot controller before disabling."
if not self.get_yes() and not prompt_y_n(msg, default="n"):
raise DecoratorEarlyExitException()
Comment on lines +1834 to +1837
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

profile.enabled = False

return profile

def get_storage_profile(self) -> Optional[ManagedClusterStorageProfile]:
"""Obtrain the value of storage_profile.
"""Obtain the value of storage_profile.

:return: Optional[ManagedClusterStorageProfile]
"""
Expand Down
Loading