Skip to content

Commit ad0747a

Browse files
authored
[Batch] BREAKING CHANGE: Remove deprecated properties (#32397)
1 parent c56e257 commit ad0747a

File tree

9 files changed

+34
-106
lines changed

9 files changed

+34
-106
lines changed

src/azure-cli/azure/cli/command_modules/batch/_breaking_change.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/azure-cli/azure/cli/command_modules/batch/_parameter_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
'resource_file.blob_prefix',
100100
'resource_file.auto_storage_container_name',
101101
'virtual_machine_configuration.service_artifact_reference',
102-
102+
'target_node_communication_mode'
103103
]
104104

105105
# Options to be flattened into multiple arguments.

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from azure.batch.models import (
1818
CachingType,
1919
BatchNodeDeallocationOption,
20-
BatchNodeCommunicationMode,
2120
StorageAccountType)
2221

2322
from azure.cli.core.commands.parameters import (
@@ -39,7 +38,6 @@
3938
keyvault_id,
4039
metadata_item_format,
4140
resource_file_format,
42-
resource_tag_format,
4341
duration_format,
4442
storage_account_id,
4543
validate_client_parameters,
@@ -222,9 +220,6 @@ def load_arguments(self, _):
222220
'configured on the Pool. If omitted, or if you specify an'
223221
'empty collection, any existing metadata is removed from the'
224222
'Pool.')
225-
c.argument('target_node_communication_mode', options_list=['--target-communication'], arg_group='Pool',
226-
help="The desired node communication mode for the pool. If this element is present, it replaces the existing targetNodeCommunicationMode configured on the Pool. If omitted, any existing metadata is left unchanged.",
227-
arg_type=get_enum_type(BatchNodeCommunicationMode))
228223
c.argument('start_task_command_line', arg_group='Pool: Start Task',
229224
help='The command line of the start task. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux.')
230225
c.argument('start_task_wait_for_success', action='store_true', arg_group='Pool: Start Task',
@@ -382,10 +377,6 @@ def load_arguments(self, _):
382377

383378
with self.argument_context('batch pool create') as c:
384379
c.argument('json_file', help='The file containing pool create properties parameter specification in JSON(formatted to match REST API request body). If this parameter is specified, all \'Pool Create Properties Parameter Arguments\' are ignored. See https://learn.microsoft.com/rest/api/batchservice/pool/add?tabs=HTTP#request-body')
385-
c.argument('resource_tags', arg_group='Pool', type=resource_tag_format, help="User is able to specify resource tags for the pool. Any resource created for the pool will then also be tagged by the same resource tags")
386-
c.argument('target_node_communication_mode', options_list=['--target-communication'],
387-
help="The desired node communication mode for the pool. If this element is present, it replaces the existing targetNodeCommunicationMode configured on the Pool. If omitted, any existing metadata is left unchanged.",
388-
arg_type=get_enum_type(BatchNodeCommunicationMode))
389380
c.argument('enable_accelerated_networking', arg_type=get_three_state_flag(), options_list=['--accelerated-networking'], arg_group="Pool: Network Configuration",
390381
help='Whether this pool should enable accelerated networking. Accelerated networking enables single root I/O virtualization (SR-IOV) to a VM, which may lead to improved networking performance. For more details, see: https://learn.microsoft.com/azure/virtual-network/accelerated-networking-overview. Set true to enable.')
391382
c.argument('caching',
@@ -433,11 +424,6 @@ def load_arguments(self, _):
433424
c.argument('prioritize_unhealthy_instances', arg_type=get_three_state_flag())
434425
c.argument('rollback_failed_instances_on_policy_breach', arg_type=get_three_state_flag())
435426

436-
with self.argument_context('batch pool set') as c:
437-
c.argument('target_node_communication_mode', options_list=['--target-communication'],
438-
help="The desired node communication mode for the pool. If this element is present, it replaces the existing targetNodeCommunicationMode configured on the Pool. If omitted, any existing metadata is left unchanged.",
439-
arg_type=get_enum_type(BatchNodeCommunicationMode))
440-
441427
with self.argument_context('batch task create') as c:
442428
c.argument('json_file', type=file_type, help='The file containing the task(s) to create in JSON(formatted to match REST API request body). When submitting multiple tasks, accepts either an array of tasks or a TaskAddCollectionParamater. If this parameter is specified, all other parameters are ignored.', validator=validate_json_file, completer=FilesCompleter())
443429
c.argument('application_package_references', nargs='+', help='The space-separated list of IDs specifying the application packages to be installed. Space-separated application IDs with optional version in \'id[#version]\' format.', type=batch_application_package_reference_format)

src/azure-cli/azure/cli/command_modules/batch/_transformers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def transform_object(self, result):
2323
new_dict = {}
2424
for key, value in result.items():
2525
new_key = self.transform_mapping[key] if key in self.transform_mapping else key
26+
if new_key is None:
27+
continue
2628
if isinstance(value, Mapping):
2729
new_dict[new_key] = self.transform_result(value)
2830
else:
@@ -65,6 +67,10 @@ def transform_object_list(self, result):
6567
'userCPUTime': 'userCpuTime',
6668
'writeIOGiB': 'writeIoGiB',
6769
'writeIOps': 'writeIops',
70+
# Deprecated properties
71+
'targetNodeCommunicationMode': None,
72+
'currentNodeCommunicationMode': None,
73+
'resourceTags': None
6874
}
6975

7076
batch_transformer = Transformer(transform_map)

src/azure-cli/azure/cli/command_modules/batch/_validators.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,6 @@ def string_dictionary_format(values):
8181
return result
8282

8383

84-
def resource_tag_format(values):
85-
"""Space-separated values in 'key=value' format."""
86-
if not values:
87-
raise ValueError("No values in resource tags. "
88-
"Argument values should be in the format a=b c=d")
89-
result = {}
90-
try:
91-
for value in values.split(' '):
92-
k, v = value.split('=')
93-
result[k] = v
94-
except ValueError:
95-
message = ("Incorrectly formatted resource tags. "
96-
"Argument values should be in the format a=b c=d")
97-
raise ValueError(message)
98-
return result
99-
100-
10184
def environment_setting_format(value):
10285
"""Space-separated values in 'key=value' format."""
10386
try:

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def resize_pool(client, pool_id, target_dedicated_nodes=None, target_low_priorit
475475

476476
def replace_pool(client,
477477
pool_id, json_file=None, application_package_references=None,
478-
metadata=None, target_node_communication_mode=None, start_task_command_line=None,
478+
metadata=None, start_task_command_line=None,
479479
start_task_environment_settings=None, start_task_max_task_retry_count=None,
480480
start_task_resource_files=None, start_task_wait_for_success=None):
481481
if json_file:
@@ -501,8 +501,7 @@ def replace_pool(client,
501501
application_package_references = []
502502
param = BatchPoolReplaceContent(
503503
application_package_references=application_package_references,
504-
metadata=metadata,
505-
target_node_communication_mode=target_node_communication_mode)
504+
metadata=metadata)
506505

507506
if start_task_command_line:
508507
param.start_task = BatchStartTask(command_line=start_task_command_line,

src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_commands.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,6 @@ def test_batch_metadata_item_format(self):
5454

5555
with self.assertRaises(ValueError):
5656
_validators.metadata_item_format("name=value=other")
57-
58-
def test_batch_resource_tag_format(self):
59-
resource_tag = _validators.resource_tag_format("name=value")
60-
self.assertEqual(resource_tag, {'name': 'value'})
61-
62-
with self.assertRaises(ValueError):
63-
_validators.resource_tag_format("test")
64-
65-
with self.assertRaises(ValueError):
66-
_validators.resource_tag_format("name=value=other")
67-
68-
with self.assertRaises(ValueError):
69-
_validators.resource_tag_format("")
7057

7158
def test_batch_environment_setting_format(self):
7259
env = _validators.environment_setting_format("name=value")
@@ -604,7 +591,7 @@ def test_batch_load_arguments(self):
604591
# pylint: disable=too-many-statements
605592
handler = azure.batch._client.BatchClient.create_pool
606593
args = list(self.command_pool._load_transformed_arguments(handler))
607-
self.assertEqual(len(args), 48)
594+
self.assertEqual(len(args), 47)
608595
self.assertFalse('yes' in [a for a, _ in args])
609596
self.assertTrue('json_file' in [a for a, _ in args])
610597
self.assertFalse('destination' in [a for a, _ in args])

src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_data_plane_commands.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ def test_batch_pool_cmd(
117117
self.check('metadata[0].name', 'a'),
118118
self.check('metadata[1].value', 'd')])
119119

120+
# test that deprecated --target-communication for pool reset
121+
with self.assertRaises(SystemExit):
122+
self.batch_cmd('batch pool reset --pool-id {p_id} --target-communication classic')
123+
120124
self.batch_cmd('batch pool delete --pool-id {p_id} --yes')
121125

122126
@ResourceGroupPreparer()
@@ -540,11 +544,18 @@ def test_batch_pools_and_nodes(
540544
# test create pool using parameters
541545
self.batch_cmd('batch pool create --id {pool_i} --vm-size Standard_DS1_v2 '
542546
'--image Canonical:UbuntuServer:18.04-LTS '
543-
'--node-agent-sku-id "batch.node.ubuntu 18.04" '
544-
'--target-communication classic')
545-
self.batch_cmd('batch pool show --pool-id {pool_i}').assert_with_checks([
546-
self.check('targetNodeCommunicationMode', 'classic')
547-
])
547+
'--node-agent-sku-id "batch.node.ubuntu 18.04"')
548+
549+
# test that deprecated --target-communication argument causes argparse error
550+
with self.assertRaises(SystemExit):
551+
self.batch_cmd('batch pool create --id test-deprecated-arg --vm-size Standard_DS1_v2 '
552+
'--image Canonical:UbuntuServer:18.04-LTS '
553+
'--node-agent-sku-id "batch.node.ubuntu 18.04" '
554+
'--target-communication classic')
555+
556+
# test that the deprecated targetNodeCommunicationMode property is not included in pool show output
557+
pool_result = self.batch_cmd('batch pool show --pool-id {pool_i}').get_output_in_json()
558+
self.assertNotIn('targetNodeCommunicationMode', pool_result, 'targetNodeCommunicationMode should not be present in pool output')
548559

549560
# test create pool with missing parameters
550561
with self.assertRaises(SystemExit):
@@ -634,15 +645,13 @@ def test_batch_pools_and_nodes(
634645
updated = self.batch_cmd('batch pool show --pool-id {pool_j} --select "startTask"').get_output_in_json()
635646
self.assertNotEqual(current['startTask']['commandLine'], updated['startTask']['commandLine'])
636647

637-
# test patch pool with target-node-communication-mode
638-
self.batch_cmd('batch pool set --pool-id {pool_j} --target-communication classic')
639-
self.batch_cmd('batch pool show --pool-id {pool_j}').assert_with_checks([
640-
self.check('targetNodeCommunicationMode', 'classic')
641-
])
642-
643648
# test list node agent skus
644649
self.batch_cmd('batch pool supported-images list')
645650

651+
# test deprecated --target-communication for pool set
652+
with self.assertRaises(SystemExit):
653+
self.batch_cmd('batch pool set --pool-id {pool_i} --target-communication classic')
654+
646655
# test app package reference
647656
self.batch_cmd('batch pool set --pool-id {pool_i} --application-package-references does-not-exist',
648657
expect_failure=True)
@@ -658,6 +667,9 @@ def test_batch_pools_and_nodes(
658667
self.assertEqual(len(node_list), 1)
659668
self.kwargs.update({'node1': node_list[0]['id']})
660669

670+
# test that deprecated currentNodeCommunicationMode property is not present in pool output
671+
self.assertNotIn('currentNodeCommunicationMode', node_list, 'currentNodeCommunicationMode should not be present in pool output')
672+
661673
# node show
662674
self.batch_cmd('batch node show --pool-id {pool_i} --node-id {node1}').assert_with_checks([
663675
self.check('id', self.kwargs['node1']),

src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_mgmt_commands.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,7 @@ def test_batch_byos_account_cmd(self, resource_group):
405405

406406
self.batch_cmd('batch pool create --id xplatCreatedPool --vm-size "standard_d2s_v3" '
407407
'--image "canonical:0001-com-ubuntu-server-focal:20_04-lts" '
408-
'--node-agent-sku-id "batch.node.ubuntu 20.04" '
409-
'--resource-tags "dept=finance env=prod"')
410-
411-
# test for resource tags
412-
self.batch_cmd('batch pool show --pool-id xplatCreatedPool').assert_with_checks([
413-
self.check('resourceTags.dept', 'finance'),
414-
self.check('resourceTags.env', 'prod'),
415-
])
408+
'--node-agent-sku-id "batch.node.ubuntu 20.04" ')
416409

417410
# test batch account delete
418411
self.cmd('batch account delete -g {rg} -n {byos_n} --yes')

0 commit comments

Comments
 (0)