-
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
✨Add support to MachinePool to reference template objects #4112
✨Add support to MachinePool to reference template objects #4112
Conversation
Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev>
Signed-off-by: Felipe Oliveira <fpo@felipeweb.dev>
Welcome @felipeweb! |
Hi @felipeweb. 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
/ok-to-test
obj, err = external.Get(ctx, r.Client, ref, m.Namespace) | ||
if err != nil { | ||
if apierrors.IsNotFound(errors.Cause(err)) { | ||
return external.ReconcileOutput{}, errors.Wrapf(err, "could not find %v %q for MachinePool %q in namespace %q, requeuing", |
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.
Should this be could not find the MachinePool template?
Also, for my understanding, what kind of error are we trying to catch by getting the cloned template after it is cloned? If the clone operation passed, the template should be there...
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.
@fabriziopandini I may be wrong because I don't have a deep knowledge of the codebase of the cluster-api, but by my understanding the object to be reconciled must be the concrete object and not the template so I do Get after the clone and if I can't get the concrete object I can't continue the reconciliation
Is this PR still needed? I see kubernetes-sigs/cluster-api-provider-aws#2226 was opened to fix the same problem |
Yes, it is not the same @CecileRobertMichon . This PR adds funcionality to refer template
objects (kubeadmConfigTemplate and EKSConfigTemplate) in MachinePool and
other PR adds support to add an AWS Launch template in MachinePool object
|
/assign @devigned |
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
This was something I had wanted to fix, but had forgotten about. Thank you!!
/assign @vincepri |
owner := &metav1.OwnerReference{ | ||
APIVersion: expv1.GroupVersion.String(), | ||
Kind: "MachinePool", | ||
Name: m.Name, | ||
UID: m.UID, | ||
} |
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.
Isn't the owner reference already set below?
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 don't t think so
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 line 118, there is a call that sets it controllerutil.SetControllerReference(m, obj, r.Client.Scheme())
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 use this owner in line 123 passing owner as input in ColneTemplate func so i can't remove it.
ref, err = external.CloneTemplate(ctx, &external.CloneTemplateInput{ | ||
Client: r.Client, | ||
TemplateRef: ref, | ||
Namespace: m.Namespace, | ||
ClusterName: cluster.Name, | ||
OwnerRef: owner, | ||
}) |
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.
/hold
Wouldn't this code clone the reference every time it reconciles?
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 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.
In my point of view no because reference is replaced by concrete object reference, so in next reconciliation the code will do not pass inside if block
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.
The ref, err = external.CloneTemplate
assignment would only replace the reference for the current function, am I missing something?
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.
line 128 is getting the ref object and this object returned by function
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.
To clarify my earlier statement, the MachinePools
and MachineDeployments
incongruity with KubeadmConfig
and KubeadmConfigTemplate
respectively caused me some confusion when I first started writing cluster yamls for the AzureMachinePool
implementation.
When I initially authored the cluster yamls for AzureMachinePool
, I started with a working set of resources from the CAPZ default cluster-template.yaml
. I started replacing the MachineDeployment
with a MachinePool
and kept the KubeadmConfigTemplate
. After writing a bit of code, I started testing and found that CAPI MachinePool
controller didn't pick up on the KubeadmConfigTemplate
, but rather, was looking for a KubeadmConfig
. It took a bit of debugging and getting into the internals of the MachinePool
controller (I was really new to the project at the time and still trying to wrap my head around the project.)
However much confusion I had previously, I feel better about about the distinction today since, as @CecileRobertMichon pointed out, MachinePools
reference 1 bootstrap config, not many instances of a config template. That distinction may not make sense to a newcomer to the project. They may try to write MachinePools
in a similar manor as a MachineDeployment
without regard to the subtle distinction between them.
I don't feel strongly one way or another. Just thought I'd share my early experiences in case it can provide some color.
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.
What @devigned described was exactly what I went through as well. I don't have a use case for this yet, only those pains that @devigned pointed out.
Perhaps we could put in the developer documentation how and when to use template objects. This is a little confusing for those who are starting to understand the project and looking at MachineDeployment and MachinePool
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.
Got it. In that case, how can we make this subtle distinction very explicit so it's not so confusing for newcomers? I don't think allowing templates and making MachinePool more like MachineDeployments is the answer here, but we should make it clear why and how they are different.
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.
Maybe pictures would tell the story our words have failed to tell.
Documentation showing a visual representation comparing a MachineDeployment
and MachinePool
would be super helpful. Perhaps, a multi-step visualization starting from initial apply and ending with deployment completed with multiple machines that describes the anatomy, relationships and choreography of the resources the user specified and the ones created by the controller. This documentation could be less developer focused and more user focused; less state diagrams and more context / intent.
@felipeweb do you think that would have helped you?
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.
@devigned sure!
/milestone v0.4.0 |
/close opened an issue to track docs improvements #4288 |
@CecileRobertMichon: Closed this PR. 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/test-infra repository. |
What this PR does / why we need it:
MachinePool must support to reference template objects like MachineDeployment supports
Which issue(s) this PR fixes
kubernetes-sigs/cluster-api-provider-aws/issues/2224