diff --git a/src/azure-cli/azure/cli/command_modules/batch/_breaking_change.py b/src/azure-cli/azure/cli/command_modules/batch/_breaking_change.py index 57b5f19ba98..1870306d078 100644 --- a/src/azure-cli/azure/cli/command_modules/batch/_breaking_change.py +++ b/src/azure-cli/azure/cli/command_modules/batch/_breaking_change.py @@ -4,7 +4,7 @@ # -------------------------------------------------------------------------------------------- from azure.cli.core.breaking_change import (AzCLIOtherChange, register_command_deprecate, - register_conditional_breaking_change) + register_conditional_breaking_change, register_output_breaking_change) # The target version of every pre-announcement in this file: the CLI's breaking change release in June 2027. # The messages are custom, so they include it too, as TARGET_TEXT. @@ -19,6 +19,14 @@ "error. For more information, see https://github.com/Azure/Batch/issues/140." ) +register_output_breaking_change( + 'batch pool reset', + description="'az batch pool reset' will print the pool in the same format as 'az batch pool show'", + target_version=TARGET_VERSION, + guide=f"Update scripts that read this output before {TARGET_TEXT}; 'az batch pool show' already prints that " + "format" +) + # Printed by validate_retained_data_option only when the value 'retaineddata' is used RETAINED_DATA_TAG = 'retaineddata' diff --git a/src/azure-cli/azure/cli/command_modules/batch/_help.py b/src/azure-cli/azure/cli/command_modules/batch/_help.py index ff5545f306a..5b94a5d4b8a 100644 --- a/src/azure-cli/azure/cli/command_modules/batch/_help.py +++ b/src/azure-cli/azure/cli/command_modules/batch/_help.py @@ -554,6 +554,10 @@ helps['batch pool reset'] = """ type: command short-summary: Update the properties of a Batch pool. Unspecified properties which can be updated are reset to their defaults. +examples: + - name: Set a new start task on a Linux pool and reset other properties to their defaults. + text: > + az batch pool reset --pool-id pool1 --start-task-command-line "/bin/sh -c 'echo ready'" """ helps['batch pool resize'] = """ diff --git a/src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_breaking_change.py b/src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_breaking_change.py index fb843a0996d..649c90e61e7 100644 --- a/src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_breaking_change.py +++ b/src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_breaking_change.py @@ -13,7 +13,7 @@ from azure.batch._operations._patch import BatchClientOperationsMixin from azure.cli.command_modules.batch._validators import validate_retained_data_option -from azure.cli.core.breaking_change import ExactVersion, upcoming_breaking_changes +from azure.cli.core.breaking_change import AzCLIOutputChange, ExactVersion, upcoming_breaking_changes from azure.cli.core.mock import DummyCli from azure.cli.core.util import rmtree_with_retry @@ -27,14 +27,22 @@ def test_batch_preannouncements(self): self.assertEqual(sorted(upcoming_breaking_changes), [ 'batch node delete.retaineddata', 'batch node reboot.retaineddata', + 'batch pool reset', 'batch pool resize.retaineddata', 'batch pool usage-metrics list']) - for changes in upcoming_breaking_changes.values(): + for name, changes in upcoming_breaking_changes.items(): self.assertEqual(len(changes), 1) # A fixed version number: the default report skips date targets, and the next window can move self.assertIsInstance(changes[0].target_version, ExactVersion) self.assertEqual(changes[0].target_version.version(), '2.100.0') - self.assertIn('will be removed in 2.100.0 (June 2027)', changes[0].message) + if name != 'batch pool reset': + self.assertIn('will be removed in 2.100.0 (June 2027)', changes[0].message) + output_change = upcoming_breaking_changes['batch pool reset'][0] + self.assertIsInstance(output_change, AzCLIOutputChange) + self.assertEqual(output_change.message, + "The output will be changed in 2.100.0. 'az batch pool reset' will print the pool in the " + "same format as 'az batch pool show'. Update scripts that read this output before " + "2.100.0 (June 2027); 'az batch pool show' already prints that format.") class TestBatchRetainedDataWarning(unittest.TestCase): diff --git a/src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_output.py b/src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_output.py index aa475363cde..9685bb1d004 100644 --- a/src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_output.py +++ b/src/azure-cli/azure/cli/command_modules/batch/tests/latest/test_batch_output.py @@ -46,8 +46,9 @@ class TestBatchOutput(unittest.TestCase): code turn a service response into the printed JSON, as they do for customers.""" def setUp(self): - # No Batch settings from AZURE_BATCH_* environment variables or the CLI config - environ = {name: value for name, value in os.environ.items() if not name.startswith('AZURE_BATCH_')} + # No Batch settings from AZURE_BATCH_* environment variables or the CLI config, and warnings are shown + environ = {name: value for name, value in os.environ.items() + if not name.startswith('AZURE_BATCH_') and name != 'AZURE_CORE_ONLY_SHOW_ERRORS'} environ_patch = mock.patch.dict(os.environ, environ, clear=True) environ_patch.start() self.addCleanup(environ_patch.stop) @@ -91,10 +92,14 @@ def test_batch_pool_show_output(self): {'nodeAgentSkuId': 'batch.node.ubuntu 20.04', 'osDisk': {'diskSizeGb': 100}}) def test_batch_pool_reset_output(self): - pool = self._invoke('batch pool reset --pool-id pool1 --start-task-command-line hostname', { - ('POST', '/pools/pool1/updateproperties'): (204, None), - ('GET', '/pools/pool1'): (200, POOL)}) - + with mock.patch('sys.stderr', new_callable=io.StringIO) as stderr: + pool = self._invoke('batch pool reset --pool-id pool1 --start-task-command-line hostname', { + ('POST', '/pools/pool1/updateproperties'): (204, None), + ('GET', '/pools/pool1'): (200, POOL)}) + + # The change to the format of 'pool show' is pre-announced for 2.100.0 + self.assertIn("The output will be changed in 2.100.0. 'az batch pool reset' will print the pool in the same " + "format as 'az batch pool show'.", stderr.getvalue()) # 'pool reset' prints the SDK model without the module's key changes, unlike 'pool show' self.assertEqual(pool['stats']['resourceStats']['diskReadIOps'], 3000000000) self.assertEqual(pool['stats']['resourceStats']['diskWriteIOps'], 2222)