Skip to content

Commit ee0de09

Browse files
InduSridharIndu Sridhar
andauthored
fix(aks-preview): allow longer node pool names (#10458)
Co-authored-by: Indu Sridhar <indusridhar@microsoft.com>
1 parent 131489c commit ee0de09

4 files changed

Lines changed: 30 additions & 11 deletions

File tree

‎src/aks-preview/HISTORY.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ To release a new version, please select a new version number (usually plus 1 to
1111

1212
Pending
1313
+++++++
14+
* Allow longer node pool names; the service enforces the actual limit.
1415
* `az aks create`: Add `--enable-upgrade-gate` to enable health-aware upgrade gating for the cluster.
1516
* `az aks update`: Add `--enable-upgrade-gate` and `--disable-upgrade-gate` to enable or disable health-aware upgrade gating for the cluster.
1617
* `az aks nodepool add/update`: Add `--enable-upgrade-gate` and `--disable-upgrade-gate` to enable or disable health-aware upgrade gating for the node pool.

‎src/aks-preview/azext_aks_preview/_params.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ def load_arguments(self, _):
934934
c.argument(
935935
"nodepool_name",
936936
default="nodepool1",
937-
help="Node pool name, upto 12 alphanumeric characters",
937+
help="Node pool name, alphanumeric characters only. See https://aka.ms/aks-naming-rules for length limits.",
938938
validator=validate_nodepool_name,
939939
)
940940
c.argument(
@@ -2292,7 +2292,7 @@ def load_arguments(self, _):
22922292
with self.argument_context("aks scale") as c:
22932293
c.argument(
22942294
"nodepool_name",
2295-
help="Node pool name, upto 12 alphanumeric characters",
2295+
help="Node pool name, alphanumeric characters only. See https://aka.ms/aks-naming-rules for length limits.",
22962296
validator=validate_nodepool_name,
22972297
)
22982298

‎src/aks-preview/azext_aks_preview/_validators.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,21 @@ def validate_resource_quota(namespace):
219219

220220

221221
def _validate_nodepool_name(nodepool_name):
222-
"""Validates a nodepool name to be at most 12 characters, alphanumeric only."""
222+
"""Validates a nodepool name to be at most 39 characters, alphanumeric only."""
223223
if nodepool_name != "":
224-
if len(nodepool_name) > 12:
225-
raise InvalidArgumentValueError('--nodepool-name can contain at most 12 characters')
224+
if len(nodepool_name) > 39:
225+
raise InvalidArgumentValueError('--nodepool-name can contain at most 39 characters')
226226
if not nodepool_name.isalnum():
227227
raise InvalidArgumentValueError('--nodepool-name should contain only alphanumeric characters')
228228

229229

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

234234

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

239239

‎src/aks-preview/azext_aks_preview/tests/latest/test_validators.py‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,19 +815,19 @@ class TestValidateNodepoolName(unittest.TestCase):
815815
def test_invalid_nodepool_name_too_long(self):
816816
namespace = SimpleNamespace(
817817
**{
818-
"nodepool_name": "tooLongNodepoolName",
818+
"nodepool_name": "a" * 40,
819819
}
820820
)
821-
with self.assertRaises(InvalidArgumentValueError):
821+
with self.assertRaisesRegex(InvalidArgumentValueError, "at most 39 characters"):
822822
validators.validate_nodepool_name(namespace)
823823

824824
def test_invalid_agent_pool_name_too_long(self):
825825
namespace = SimpleNamespace(
826826
**{
827-
"agent_pool_name": "tooLongNodepoolName",
827+
"agent_pool_name": "a" * 40,
828828
}
829829
)
830-
with self.assertRaises(InvalidArgumentValueError):
830+
with self.assertRaisesRegex(InvalidArgumentValueError, "at most 39 characters"):
831831
validators.validate_agent_pool_name(namespace)
832832

833833
def test_invalid_nodepool_name_not_alnum(self):
@@ -864,6 +864,24 @@ def test_valid_agent_pool_name(self):
864864
)
865865
validators.validate_agent_pool_name(namespace)
866866

867+
def test_valid_nodepool_name_length_boundaries(self):
868+
for length in (12, 13, 39):
869+
with self.subTest(length=length):
870+
namespace = SimpleNamespace(nodepool_name="a" * length)
871+
validators.validate_nodepool_name(namespace)
872+
873+
def test_valid_agent_pool_name_length_boundaries(self):
874+
for length in (12, 13, 39):
875+
with self.subTest(length=length):
876+
namespace = SimpleNamespace(agent_pool_name="a" * length)
877+
validators.validate_agent_pool_name(namespace)
878+
879+
def test_valid_empty_nodepool_name(self):
880+
validators.validate_nodepool_name(SimpleNamespace(nodepool_name=""))
881+
882+
def test_valid_empty_agent_pool_name(self):
883+
validators.validate_agent_pool_name(SimpleNamespace(agent_pool_name=""))
884+
867885

868886
class TestValidateVMSetType(unittest.TestCase):
869887
def test_accepts_flexnodes(self):

0 commit comments

Comments
 (0)