-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🌱 Flag for old infra machine naming #10576
🌱 Flag for old infra machine naming #10576
Conversation
74cdc9a
to
6b027f4
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.
I think this looks good.
Another observation. In both of the places where we're modifying the object's name we already have a MachineTemplateSpec:
cluster-api/api/v1beta1/machineset_types.go
Lines 91 to 102 in c6783a2
type MachineTemplateSpec struct { | |
// Standard object's metadata. | |
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata | |
// +optional | |
ObjectMeta `json:"metadata,omitempty"` | |
// Specification of the desired behavior of the machine. | |
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status | |
// +optional | |
Spec MachineSpec `json:"spec,omitempty"` | |
} | |
I think it would be quite a natural extension to the API to add, e.g. a GenerateName
field to MachineTemplateSpec
. We could then restore the Machine.Name
==InfraMachine.Name
relationship, and allow the user to control the naming of their Machines (and ultimately their Nodes) arbitrarily if required.
I think this would be pretty simple to implement, backwards compatible, and would solve the node naming problem long term. I could probably make time to implement it.
@@ -180,12 +180,16 @@ func (r *KubeadmControlPlaneReconciler) cloneConfigsAndGenerateMachine(ctx conte | |||
UID: kcp.UID, | |||
} | |||
|
|||
infraMachineName := machine.Name | |||
if r.DeprecatedInfraMachineNaming { | |||
infraMachineName = names.SimpleNameGenerator.GenerateName(kcp.Spec.MachineTemplate.InfrastructureRef.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.
Just an observation: this remains the default behaviour of GenerateTemplate()
if Name
is not given:
cluster-api/controllers/external/util.go
Lines 169 to 172 in c6783a2
if to.GetName() == "" { | |
to.SetName(names.SimpleNameGenerator.GenerateName(in.Template.GetName() + "-")) | |
} | |
to.SetNamespace(in.Namespace) |
You could omit this and simply not set Name
at all on line 192 below if DeprecatedInfraMachineNaming
is set.
The disadvantage of that is that the behaviour would be implicit and not local to use, and therefore easy to regress again.
If keeping this code, I wonder if it's worth removing the default from GenerateTemplate()
. When I looked before I don't think there were any callers which weren't setting Name. And if there were CI would find them pretty quickly.
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.
Current implementation seems like the most explicit way to implement it. So it's fine for me
There are no writes of the Name field in core CAPI, but these are exported functions. So I wouldn't change it
if r.DeprecatedInfraMachineNaming { | ||
infraMachineName = names.SimpleNameGenerator.GenerateName(ms.Spec.Template.Spec.InfrastructureRef.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.
Same observation as for KCP.
@@ -180,12 +180,16 @@ func (r *KubeadmControlPlaneReconciler) cloneConfigsAndGenerateMachine(ctx conte | |||
UID: kcp.UID, | |||
} | |||
|
|||
infraMachineName := machine.Name | |||
if r.DeprecatedInfraMachineNaming { | |||
infraMachineName = names.SimpleNameGenerator.GenerateName(kcp.Spec.MachineTemplate.InfrastructureRef.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.
Current implementation seems like the most explicit way to implement it. So it's fine for me
There are no writes of the Name field in core CAPI, but these are exported functions. So I wouldn't change it
Just some minor findings. Let's try to get this merged until Monday the latest (I know a few folks including me have a public holidy tomorrow :)) |
There is a breaking change to the way InfraMachines are named in v1.7.0. This commit adds a flag to the KCP and core controller for getting the old behavior back. It defaults to disabled so the new behavior stays. It is also marked as deprecated and to be removed in v1.9. Signed-off-by: Lennart Jern <lennart.jern@est.tech>
6b027f4
to
43f13bc
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
LGTM label has been added. Git tree hash: 3cc7b0e56c76b05235d3095a4ec7369f074e60a0
|
Thx! /lgtm |
/cherry-pick release-1.7 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbueringer 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 |
@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.7 in a new PR and assign it to you. In response to this:
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-sigs/prow repository. |
@sbueringer: new pull request created: #10587 In response to this:
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-sigs/prow repository. |
What this PR does / why we need it:
There is a breaking change to the way InfraMachines are named in v1.7.0. This commit adds a flag to the KCP and core controller for getting the old behavior back. It defaults to disabled so the new behavior stays. It is also marked as deprecated and to be removed in v1.9.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Stop-gap solution for #10463
/area provider/control-plane-kubeadm
/area machineset