-
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
🐛 avoid in-place capbk mutation, duplicate files #3473
Conversation
|
||
for i := range merge { |
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.
is this unit tested?
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.
edit: just saw you have a hold for tests, nvm
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.
Good catch!
Wondering if we can remove the merge
parameter from resolveFiles
, since it seems it is never used now.
Additional question, from a quick glance at this feauture, it seems to me that the AdditionalFiles
are never added to cloud-init for a joining control plane node. see
cluster-api/bootstrap/kubeadm/internal/cloudinit/controlplane_init.go
Lines 58 to 59 in d910413
input.WriteFiles = input.Certificates.AsFiles() | |
input.WriteFiles = append(input.WriteFiles, input.AdditionalFiles...) |
vs
input.WriteFiles = input.Certificates.AsFiles() |
Is this intentional or another potential bug hidden by the duplication of files?
I think for the join case, we take
and plumb it through to cluster-api/bootstrap/kubeadm/internal/cloudinit/controlplane_join.go Lines 57 to 59 in 2afc70d
will see if I can align these, or if there's a reason not to 👍 |
I guess cluster-api/bootstrap/kubeadm/internal/cloudinit/cloudinit.go Lines 58 to 66 in 2afc70d
|
@alexeldeib thanks for investigating this. |
@@ -578,20 +578,35 @@ func (r *KubeadmConfigReconciler) joinControlplane(ctx context.Context, scope *S | |||
// resolveFiles maps .Spec.Files into cloudinit.Files, resolving any object references | |||
// along the way. | |||
func (r *KubeadmConfigReconciler) resolveFiles(ctx context.Context, cfg *bootstrapv1.KubeadmConfig, merge ...bootstrapv1.File) ([]bootstrapv1.File, error) { | |||
collected := append(cfg.Spec.Files, merge...) | |||
collected := make([]bootstrapv1.File, len(cfg.Spec.Files)+len(merge)) |
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.
collected := make([]bootstrapv1.File, len(cfg.Spec.Files)+len(merge)) | |
collected := make([]bootstrapv1.File, 0, len(cfg.Spec.Files)+len(merge)) |
Then we don't need index
, but we can just append()
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.
not actually merging anything anymore, so got rid of this altogether and switched to append
/milestone v0.3.9 |
@CecileRobertMichon added tests |
/hold cancel |
}, | ||
objects: []runtime.Object{testSecret}, | ||
}, | ||
"multiple files should work correctly": { |
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.
was about to hit enter on a comment asking exactly for this :D
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
Signed-off-by: Alexander Eldeib <alexeldeib@gmail.com>
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
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri 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 this PR does / why we need it:
we write the certificate files twice into cloud init, once as writeFiles and again as additionalFiles which get written back to writeFiles.
we also mutate the kubeadm config spec in place when converting contentFrom -> content. avoid doing that.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):/hold
for some tests