Skip to content

Commit 8bea748

Browse files
authored
[AKS] az aks nodepool update: Add GPU driver install options install and none for --gpu-driver parameter (#32531)
1 parent 6a01c96 commit 8bea748

File tree

5 files changed

+47
-0
lines changed

5 files changed

+47
-0
lines changed

src/azure-cli/azure/cli/command_modules/acs/_help.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,6 +2126,9 @@
21262126
- name: --localdns-config
21272127
type: string
21282128
short-summary: Set the localDNS Profile for a nodepool with a JSON config file.
2129+
- name: --gpu-driver
2130+
type: string
2131+
short-summary: Whether to install driver for GPU node pool. Possible values are "Install" or "None".
21292132
examples:
21302133
- name: Reconcile the nodepool back to its current state.
21312134
text: az aks nodepool update -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster

src/azure-cli/azure/cli/command_modules/acs/_params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,7 @@ def load_arguments(self, _):
10891089
c.argument("if_match")
10901090
c.argument("if_none_match")
10911091
c.argument('localdns_config', help='Path to a JSON file to configure the local DNS profile for a new nodepool.')
1092+
c.argument('gpu_driver', arg_type=get_enum_type(gpu_driver_install_modes))
10921093

10931094
with self.argument_context('aks nodepool upgrade') as c:
10941095
c.argument('max_surge', validator=validate_max_surge)

src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,6 +2622,18 @@ def update_vtpm(self, agentpool: AgentPool) -> AgentPool:
26222622

26232623
return agentpool
26242624

2625+
def update_gpu_profile(self, agentpool: AgentPool) -> AgentPool:
2626+
self._ensure_agentpool(agentpool)
2627+
2628+
gpu_driver = self.context.get_gpu_driver()
2629+
2630+
# Construct AgentPoolGPUProfile if one of the fields has been set
2631+
if gpu_driver:
2632+
agentpool.gpu_profile = self.models.GPUProfile()
2633+
agentpool.gpu_profile.driver = gpu_driver
2634+
2635+
return agentpool
2636+
26252637
def update_agentpool_profile_default(self, agentpools: List[AgentPool] = None) -> AgentPool:
26262638
"""The overall controller used to update AgentPool profile by default.
26272639
@@ -2652,6 +2664,8 @@ def update_agentpool_profile_default(self, agentpools: List[AgentPool] = None) -
26522664
agentpool = self.update_secure_boot(agentpool)
26532665
# update local DNS profile
26542666
agentpool = self.update_localdns_profile(agentpool)
2667+
# update gpu profile
2668+
agentpool = self.update_gpu_profile(agentpool)
26552669
return agentpool
26562670

26572671
def update_agentpool(self, agentpool: AgentPool) -> AgentPool:

src/azure-cli/azure/cli/command_modules/acs/custom.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2986,6 +2986,7 @@ def aks_agentpool_update(
29862986
if_none_match=None,
29872987
# local DNS
29882988
localdns_config=None,
2989+
gpu_driver=None,
29892990
):
29902991
# DO NOT MOVE: get all the original parameters and save them as a dictionary
29912992
raw_parameters = locals()

src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_agentpool_decorator.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3241,6 +3241,31 @@ def common_update_vm_properties(self):
32413241
)
32423242
self.assertEqual(dec_agentpool_1, grond_truth_agentpool_1)
32433243

3244+
def common_update_gpu_profile(self):
3245+
dec_1 = AKSAgentPoolUpdateDecorator(
3246+
self.cmd,
3247+
self.client,
3248+
{"gpu_driver": "None"},
3249+
self.resource_type,
3250+
self.agentpool_decorator_mode,
3251+
)
3252+
# fail on passing the wrong agentpool object
3253+
with self.assertRaises(CLIInternalError):
3254+
dec_1.update_gpu_profile(None)
3255+
agentpool_1 = self.create_initialized_agentpool_instance(
3256+
gpu_profile=self.models.GPUProfile(
3257+
driver="Install",
3258+
)
3259+
)
3260+
dec_1.context.attach_agentpool(agentpool_1)
3261+
dec_agentpool_1 = dec_1.update_gpu_profile(agentpool_1)
3262+
ground_truth_agentpool_1 = self.create_initialized_agentpool_instance(
3263+
gpu_profile=self.models.GPUProfile(
3264+
driver="None",
3265+
)
3266+
)
3267+
self.assertEqual(dec_agentpool_1, ground_truth_agentpool_1)
3268+
32443269
def common_update_fips_image(self):
32453270
dec_1 = AKSAgentPoolUpdateDecorator(
32463271
self.cmd,
@@ -3481,6 +3506,9 @@ def test_update_vm_properties(self):
34813506
def test_update_fips_image(self):
34823507
self.common_update_fips_image()
34833508

3509+
def test_update_gpu_profile(self):
3510+
self.common_update_gpu_profile()
3511+
34843512
def test_update_agentpool_profile_default(self):
34853513
import inspect
34863514

0 commit comments

Comments
 (0)