Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'

Expand Down
4 changes: 4 additions & 0 deletions src/azure-cli/azure/cli/command_modules/batch/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading