Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ To release a new version, please select a new version number (usually plus 1 to

Pending
+++++++
* Allow longer node pool names; the service enforces the actual limit.

22.0.0b13
+++++++++
Expand Down
4 changes: 2 additions & 2 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ def load_arguments(self, _):
c.argument(
"nodepool_name",
default="nodepool1",
help="Node pool name, upto 12 alphanumeric characters",
help="Node pool name, alphanumeric characters only. See https://aka.ms/aks-naming-rules for length limits.",
validator=validate_nodepool_name,
)
c.argument(
Expand Down Expand Up @@ -2276,7 +2276,7 @@ def load_arguments(self, _):
with self.argument_context("aks scale") as c:
c.argument(
"nodepool_name",
help="Node pool name, upto 12 alphanumeric characters",
help="Node pool name, alphanumeric characters only. See https://aka.ms/aks-naming-rules for length limits.",
validator=validate_nodepool_name,
)

Expand Down
10 changes: 5 additions & 5 deletions src/aks-preview/azext_aks_preview/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,21 @@ def validate_resource_quota(namespace):


def _validate_nodepool_name(nodepool_name):
"""Validates a nodepool name to be at most 12 characters, alphanumeric only."""
"""Validates a nodepool name to be at most 39 characters, alphanumeric only."""
if nodepool_name != "":
if len(nodepool_name) > 12:
raise InvalidArgumentValueError('--nodepool-name can contain at most 12 characters')
if len(nodepool_name) > 39:
Comment thread
FumingZhang marked this conversation as resolved.
raise InvalidArgumentValueError('--nodepool-name can contain at most 39 characters')
if not nodepool_name.isalnum():
raise InvalidArgumentValueError('--nodepool-name should contain only alphanumeric characters')


def validate_nodepool_name(namespace):
"""Validates a nodepool name to be at most 12 characters, alphanumeric only."""
"""Validates a nodepool name to be at most 39 characters, alphanumeric only."""
_validate_nodepool_name(namespace.nodepool_name)


def validate_agent_pool_name(namespace):
"""Validates a nodepool name to be at most 12 characters, alphanumeric only."""
"""Validates a nodepool name to be at most 39 characters, alphanumeric only."""
_validate_nodepool_name(namespace.agent_pool_name)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,19 +815,19 @@ class TestValidateNodepoolName(unittest.TestCase):
def test_invalid_nodepool_name_too_long(self):
namespace = SimpleNamespace(
**{
"nodepool_name": "tooLongNodepoolName",
"nodepool_name": "a" * 40,
}
)
with self.assertRaises(InvalidArgumentValueError):
with self.assertRaisesRegex(InvalidArgumentValueError, "at most 39 characters"):
validators.validate_nodepool_name(namespace)

def test_invalid_agent_pool_name_too_long(self):
namespace = SimpleNamespace(
**{
"agent_pool_name": "tooLongNodepoolName",
"agent_pool_name": "a" * 40,
}
)
with self.assertRaises(InvalidArgumentValueError):
with self.assertRaisesRegex(InvalidArgumentValueError, "at most 39 characters"):
validators.validate_agent_pool_name(namespace)

def test_invalid_nodepool_name_not_alnum(self):
Expand Down Expand Up @@ -864,6 +864,24 @@ def test_valid_agent_pool_name(self):
)
validators.validate_agent_pool_name(namespace)

def test_valid_nodepool_name_length_boundaries(self):
for length in (12, 13, 39):
with self.subTest(length=length):
namespace = SimpleNamespace(nodepool_name="a" * length)
validators.validate_nodepool_name(namespace)

def test_valid_agent_pool_name_length_boundaries(self):
for length in (12, 13, 39):
with self.subTest(length=length):
namespace = SimpleNamespace(agent_pool_name="a" * length)
validators.validate_agent_pool_name(namespace)

def test_valid_empty_nodepool_name(self):
validators.validate_nodepool_name(SimpleNamespace(nodepool_name=""))

def test_valid_empty_agent_pool_name(self):
validators.validate_agent_pool_name(SimpleNamespace(agent_pool_name=""))


class TestValidateVMSetType(unittest.TestCase):
def test_accepts_flexnodes(self):
Expand Down
Loading