diff --git a/src/aks-preview/HISTORY.rst b/src/aks-preview/HISTORY.rst index 33ca380a7d8..61e830d0542 100644 --- a/src/aks-preview/HISTORY.rst +++ b/src/aks-preview/HISTORY.rst @@ -9,8 +9,9 @@ If there is no rush to release a new version, please just add a description of t To release a new version, please select a new version number (usually plus 1 to last patch version, X.Y.Z -> Major.Minor.Patch, more details in `\doc `_), and then add a new section named as the new version number in this file, the content should include the new modifications and everything from the *Pending* section. Finally, update the `VERSION` variable in `setup.py` with this new version number. -Pending +20.0.0b7 +++++++ +* `az aks nodepool update --crg-id`: Allow updating `--crg-id` to associate an existing Capacity Reservation Group with a nodepool not currently associated with one. * Update the minimum required cli core version to `2.76.0` (actually since `20.0.0b3`). * `az aks upgrade`: Add `--k8s-support-plan` and `--tier` flag support to allow cluster support plan and tier configuration during cluster upgrade. diff --git a/src/aks-preview/azext_aks_preview/_help.py b/src/aks-preview/azext_aks_preview/_help.py index c33f774bd21..edc123910b6 100644 --- a/src/aks-preview/azext_aks_preview/_help.py +++ b/src/aks-preview/azext_aks_preview/_help.py @@ -2521,6 +2521,9 @@ - name: --gpu-driver type: string short-summary: Whether to install driver for GPU node pool. Possible values are "Install" or "None". + - name: --crg-id + type: string + short-summary: The Capacity Reservation Group (CRG) ID used to associate the existing nodepool with the existing Capacity Reservation Group resource. examples: - name: Reconcile the nodepool back to its current state. text: az aks nodepool update -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster @@ -2538,6 +2541,8 @@ text: az aks nodepool update -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --node-vm-size Standard_D4s_v3 - name: Update a node pool with blue-green upgrade settings text: az aks nodepool update -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --drain-batch-size 50% --drain-timeout-bg 5 --batch-soak-duration 10 --final-soak-duration 10 + - name: Update a nodepool with a Capacity Reservation Group(CRG) ID. + text: az aks nodepool update -g MyResourceGroup -n MyNodePool --cluster-name MyMC --node-vm-size VMSize --crg-id "/subscriptions/SubID/resourceGroups/ResourceGroupName/providers/Microsoft.Compute/CapacityReservationGroups/MyCRGID" """ helps['aks nodepool get-upgrades'] = """ diff --git a/src/aks-preview/azext_aks_preview/_params.py b/src/aks-preview/azext_aks_preview/_params.py index 84146eb6610..b0bbe5f16a7 100644 --- a/src/aks-preview/azext_aks_preview/_params.py +++ b/src/aks-preview/azext_aks_preview/_params.py @@ -2237,6 +2237,7 @@ def load_arguments(self, _): c.argument("mode", arg_type=get_enum_type(node_mode_types)) c.argument("scale_down_mode", arg_type=get_enum_type(scale_down_modes)) # extensions + c.argument("crg_id", validator=validate_crg_id, is_preview=True) c.argument( "allowed_host_ports", validator=validate_allowed_host_ports, is_preview=True ) diff --git a/src/aks-preview/azext_aks_preview/agentpool_decorator.py b/src/aks-preview/azext_aks_preview/agentpool_decorator.py index a61272f076b..541fbb0402e 100644 --- a/src/aks-preview/azext_aks_preview/agentpool_decorator.py +++ b/src/aks-preview/azext_aks_preview/agentpool_decorator.py @@ -1250,7 +1250,9 @@ def set_up_preview_vm_properties(self, agentpool: AgentPool) -> AgentPool: """ self._ensure_agentpool(agentpool) - agentpool.capacity_reservation_group_id = self.context.get_crg_id() + crg_id = self.context.get_crg_id() + if crg_id is not None: + agentpool.capacity_reservation_group_id = crg_id return agentpool def set_up_motd(self, agentpool: AgentPool) -> AgentPool: @@ -1944,6 +1946,17 @@ def update_fips_image(self, agentpool: AgentPool) -> AgentPool: return agentpool + def update_crg(self, agentpool: AgentPool) -> AgentPool: + """Update crg id for the AgentPool object. + :return: the AgentPool object + """ + self._ensure_agentpool(agentpool) + + crg_id = self.context.get_crg_id() + if crg_id is not None: + agentpool.capacity_reservation_group_id = crg_id + return agentpool + def update_vm_size(self, agentpool: AgentPool) -> AgentPool: """Update VM size for the AgentPool object. @@ -2051,6 +2064,9 @@ def update_agentpool_profile_preview(self, agentpools: List[AgentPool] = None) - # update gpu mig strategy agentpool = self.update_gpu_mig_strategy(agentpool) + # update crg id + agentpool = self.update_crg(agentpool) + return agentpool def update_auto_scaler_properties(self, agentpool: AgentPool) -> AgentPool: diff --git a/src/aks-preview/azext_aks_preview/custom.py b/src/aks-preview/azext_aks_preview/custom.py index b512cf0338e..9d717d04659 100644 --- a/src/aks-preview/azext_aks_preview/custom.py +++ b/src/aks-preview/azext_aks_preview/custom.py @@ -2068,6 +2068,8 @@ def aks_agentpool_update( node_vm_size=None, gpu_driver=None, gpu_mig_strategy=None, + # crg + crg_id=None, ): # DO NOT MOVE: get all the original parameters and save them as a dictionary raw_parameters = locals() diff --git a/src/aks-preview/azext_aks_preview/tests/latest/test_update_agentpool_profile_preview.py b/src/aks-preview/azext_aks_preview/tests/latest/test_update_agentpool_profile_preview.py index 39bff847708..4d85628a9b4 100644 --- a/src/aks-preview/azext_aks_preview/tests/latest/test_update_agentpool_profile_preview.py +++ b/src/aks-preview/azext_aks_preview/tests/latest/test_update_agentpool_profile_preview.py @@ -136,6 +136,7 @@ def test_update_agentpool_profile_preview_default_behavior(self): decorator.update_blue_green_upgrade_settings = Mock(return_value=agentpool) decorator.update_gpu_profile = Mock(return_value=agentpool) decorator.update_gpu_mig_strategy = Mock(return_value=agentpool) + decorator.update_crg = Mock(return_value=agentpool) # Act result = decorator.update_agentpool_profile_preview() @@ -162,6 +163,7 @@ def test_update_agentpool_profile_preview_default_behavior(self): decorator.update_blue_green_upgrade_settings.assert_called_once_with(agentpool) decorator.update_gpu_profile.assert_called_once_with(agentpool) decorator.update_gpu_mig_strategy.assert_called_once_with(agentpool) + decorator.update_crg.assert_called_once_with(agentpool) def test_update_agentpool_profile_preview_with_agentpools_parameter(self): """Test update_agentpool_profile_preview with agentpools parameter.""" @@ -206,6 +208,7 @@ def test_update_agentpool_profile_preview_with_agentpools_parameter(self): decorator.update_blue_green_upgrade_settings = Mock(return_value=agentpool) decorator.update_gpu_profile = Mock(return_value=agentpool) decorator.update_gpu_mig_strategy = Mock(return_value=agentpool) + decorator.update_crg = Mock(return_value=agentpool) # Act result = decorator.update_agentpool_profile_preview(agentpools) @@ -258,6 +261,8 @@ def test_update_agentpool_profile_preview_managed_system_mode(self): decorator.update_upgrade_strategy = Mock() decorator.update_blue_green_upgrade_settings = Mock() decorator.update_gpu_profile = Mock() + decorator.update_gpu_mig_strategy = Mock() + decorator.update_crg = Mock() # Act result = decorator.update_agentpool_profile_preview() @@ -288,6 +293,8 @@ def test_update_agentpool_profile_preview_managed_system_mode(self): decorator.update_upgrade_strategy.assert_not_called() decorator.update_blue_green_upgrade_settings.assert_not_called() decorator.update_gpu_profile.assert_not_called() + decorator.update_gpu_mig_strategy.assert_not_called() + decorator.update_crg.assert_not_called() def test_update_agentpool_profile_preview_managed_system_mode_with_agentpools(self): """Test update_agentpool_profile_preview with ManagedSystem mode and agentpools parameter.""" @@ -369,6 +376,7 @@ def test_update_agentpool_profile_preview_system_mode_regular_flow(self): decorator.update_blue_green_upgrade_settings = Mock(return_value=agentpool) decorator.update_gpu_profile = Mock(return_value=agentpool) decorator.update_gpu_mig_strategy = Mock(return_value=agentpool) + decorator.update_crg = Mock(return_value=agentpool) # Act result = decorator.update_agentpool_profile_preview() @@ -393,6 +401,7 @@ def test_update_agentpool_profile_preview_system_mode_regular_flow(self): decorator.update_blue_green_upgrade_settings.assert_called_once_with(agentpool) decorator.update_gpu_profile.assert_called_once_with(agentpool) decorator.update_gpu_mig_strategy.assert_called_once_with(agentpool) + decorator.update_crg.assert_called_once_with(agentpool) def test_update_agentpool_profile_preview_execution_order(self): """Test that update methods are called in the correct order.""" @@ -442,6 +451,7 @@ def mock_method(pool): decorator.update_blue_green_upgrade_settings = create_mock_update_method("update_blue_green_upgrade_settings") decorator.update_gpu_profile = create_mock_update_method("update_gpu_profile") decorator.update_gpu_mig_strategy = create_mock_update_method("update_gpu_mig_strategy") + decorator.update_crg = create_mock_update_method("update_crg") # Act decorator.update_agentpool_profile_preview() @@ -463,6 +473,7 @@ def mock_method(pool): "update_blue_green_upgrade_settings", "update_gpu_profile", "update_gpu_mig_strategy", + "update_crg", ] self.assertEqual(call_order, expected_order) @@ -514,6 +525,7 @@ def track_and_return(pool): decorator.update_blue_green_upgrade_settings = create_tracking_mock("update_blue_green_upgrade_settings") decorator.update_gpu_profile = create_tracking_mock("update_gpu_profile") decorator.update_gpu_mig_strategy = create_tracking_mock("update_gpu_mig_strategy") + decorator.update_crg = create_tracking_mock("update_crg") # Act result = decorator.update_agentpool_profile_preview() @@ -577,7 +589,7 @@ def test_update_agentpool_profile_preview_mixed_modes_scenario(self): 'update_secure_boot', 'update_vtpm', 'update_os_sku', 'update_fips_image', 'update_ssh_access', 'update_vm_size', 'update_localdns_profile', 'update_auto_scaler_properties_vms', 'update_upgrade_strategy', 'update_blue_green_upgrade_settings', 'update_gpu_profile', - 'update_gpu_mig_strategy' + 'update_gpu_mig_strategy', 'update_crg' ] for method_name in update_methods: @@ -653,6 +665,7 @@ def test_update_agentpool_profile_preview_managed_cluster_mode(self): decorator.update_blue_green_upgrade_settings = Mock(return_value=agentpool) decorator.update_gpu_profile = Mock(return_value=agentpool) decorator.update_gpu_mig_strategy = Mock(return_value=agentpool) + decorator.update_crg = Mock(return_value=agentpool) # Act result = decorator.update_agentpool_profile_preview(agentpools) diff --git a/src/aks-preview/setup.py b/src/aks-preview/setup.py index eb271541186..3c3f3b698b9 100644 --- a/src/aks-preview/setup.py +++ b/src/aks-preview/setup.py @@ -9,7 +9,7 @@ from setuptools import find_packages, setup -VERSION = "20.0.0b6" +VERSION = "20.0.0b7" CLASSIFIERS = [ "Development Status :: 4 - Beta",