-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add proper validation for nodepool name #3974
Add proper validation for nodepool name #3974
Conversation
|
Welcome @tapojit047! |
Hi @tapojit047. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
0a80bad
to
ed11eaa
Compare
01ea9da
to
894105b
Compare
/ok-to-test |
20b341d
to
b8a9787
Compare
/test pull-cluster-api-provider-azure-e2e-aks |
b8a9787
to
0ee2116
Compare
return -1 | ||
}, name) | ||
name = strings.TrimLeftFunc(name, unicode.IsNumber) | ||
if len(name) > 6 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want to truncate the name from MachinePool
to 6 chars and then add 6 chars of random characters?
Wouldn't this be sufficient?:
- remove/replace invalid characters
- truncate at the maximum allowed character limit (12)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would like to avoid naming conflict created from different CAPZ cluster. So, we want to add a random part to the pool name that is passed to Azure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification.
So is the scenario that we might run multiple clusters w/ a common MachinePool naming convention. E.g.:
- cluster1
- pool1
- pool2
- pool3
- cluster2
- pool1
- pool2
- pool3
And you want to have CAPZ ensure that cluster1 and cluster2 don't produce identically named pool names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We want to avoid naming conflict.
Also, adding a random part to will not affect ux, since user don't really have to interact with this directly unless they are doing something from the Azure portal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again.
So, my initial response to this is that is that this type of enforcement should not be the responsibility of CAPZ. There could be other environments with the exact opposite requirements (require identical pool names across common cluster ecosystems).
Could you enforce this pool naming requirement in your cluster creation CI so that you're fully in control of these requirements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about validating the AzureManagedMachinePool metadata name according to the Azure pool name rules if and only if the spec.Name field is not explicitly set? And if the spec.Name field is set, we should validate the spec.Name.
Since we already default spec.name
to metadata.name
when not set, do we only need to validate spec.name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we only need to validate spec.name
That would be equivalent, only reason I can think of for doing both is that it might be more user friendly to validate the thing the user is actually setting (otherwise I could see users getting confused with "why am I getting a validation error for something I didn't set"). That's an implementation detail though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no Azure requirement that a pool name must be unique (it should only be unique within a cluster).
I did not realise that. Thanks for the info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to convert this into a new PR that validates the AKS 12 character limit, or simply close this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converted it into a validation for the nodepool name PR. @jackfrancis
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3974 +/- ##
==========================================
- Coverage 56.57% 56.56% -0.01%
==========================================
Files 187 187
Lines 19130 19168 +38
==========================================
+ Hits 10823 10843 +20
- Misses 7676 7691 +15
- Partials 631 634 +3
☔ View full report in Codecov by Sentry. |
651fe3d
to
64b7dc8
Compare
Signed-off-by: Tapajit Chandra Paul <[email protected]>
64b7dc8
to
66860ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/assign @jackfrancis @nojnhuh
LGTM label has been added. Git tree hash: 60a6bfcab36e64d86d32c985b90b9bed05bc5e6e
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nojnhuh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
What this PR does / why we need it:
- The name of a node pool may only contain lowercase alphanumeric characters and must begin with a lowercase letter.
- For Linux node pools, the length must be between 1-12 characters.
But the nodepool name is not validated properly (according to these restrictions). Proper validation following these restrictions in the
azuremanagedmachinepool_webhook.go
is added.spec.name
field isnot specified
in the YAML ofAzureManagedMachinePool
, then the default name is set to themetadata.name
. Take a look here. Sometadata.name
is validated whenspec.name
is not set.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #3968
Special notes for your reviewer:
TODOs:
Release note: