Skip to content

Commit 5c42406

Browse files
committed
update agentpool update decorator and add tests
1 parent a98f57c commit 5c42406

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/aks-preview/azext_aks_preview/agentpool_decorator.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,16 @@ def update_network_profile(self, agentpool: AgentPool) -> AgentPool:
16441644
agentpool.network_profile.allowed_host_ports = allowed_host_ports
16451645
return agentpool
16461646

1647+
def update_gpu_profile(self, agentpool: AgentPool) -> AgentPool:
1648+
self._ensure_agentpool(agentpool)
1649+
1650+
gpu_driver = self.context.get_gpu_driver()
1651+
if gpu_driver is not None:
1652+
if agentpool.gpu_profile is None:
1653+
agentpool.gpu_profile = self.models.GPUProfile()
1654+
agentpool.gpu_profile.driver = gpu_driver
1655+
return agentpool
1656+
16471657
def update_artifact_streaming(self, agentpool: AgentPool) -> AgentPool:
16481658
"""Update artifact streaming property for the AgentPool object.
16491659
:return: the AgentPool object
@@ -1807,6 +1817,9 @@ def update_agentpool_profile_preview(self, agentpools: List[AgentPool] = None) -
18071817
# update blue-green upgrade settings
18081818
agentpool = self.update_blue_green_upgrade_settings(agentpool)
18091819

1820+
# update gpu profile
1821+
agentpool = self.update_gpu_profile(agentpool)
1822+
18101823
return agentpool
18111824

18121825
def update_auto_scaler_properties(self, agentpool: AgentPool) -> AgentPool:

src/aks-preview/azext_aks_preview/tests/latest/test_agentpool_decorator.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,6 +2660,31 @@ def common_update_localdns_profile(self):
26602660
finally:
26612661
os.unlink(config_file_path)
26622662

2663+
def common_update_gpu_profile(self):
2664+
dec_1 = AKSPreviewAgentPoolUpdateDecorator(
2665+
self.cmd,
2666+
self.client,
2667+
{"gpu_driver": "None"},
2668+
self.resource_type,
2669+
self.agentpool_decorator_mode,
2670+
)
2671+
# fail on passing the wrong agentpool object
2672+
with self.assertRaises(CLIInternalError):
2673+
dec_1.set_up_gpu_profile(None)
2674+
agentpool_1 = self.create_initialized_agentpool_instance(
2675+
gpu_profile=self.models.GPUProfile(
2676+
driver="Install",
2677+
)
2678+
)
2679+
dec_1.context.attach_agentpool(agentpool_1)
2680+
dec_agentpool_1 = dec_1.update_gpu_profile(agentpool_1)
2681+
ground_truth_agentpool_1 = self.create_initialized_agentpool_instance(
2682+
gpu_profile=self.models.GPUProfile(
2683+
driver="None",
2684+
)
2685+
)
2686+
self.assertEqual(dec_agentpool_1, ground_truth_agentpool_1)
2687+
26632688
def common_test_process_dns_overrides_helper(self):
26642689
from azext_aks_preview._helpers import process_dns_overrides
26652690

@@ -2744,6 +2769,9 @@ def test_update_blue_green_upgrade_settings(self):
27442769
def test_update_localdns_profile(self):
27452770
self.common_update_localdns_profile()
27462771

2772+
def test_update_gpu_profile(self):
2773+
self.common_update_gpu_profile()
2774+
27472775
def test_process_dns_overrides_helper(self):
27482776
self.common_test_process_dns_overrides_helper()
27492777

0 commit comments

Comments
 (0)