Skip to content
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

🌱 Log diffs for Cluster topology rollouts/patches #10690

Merged
merged 1 commit into from
May 31, 2024

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented May 28, 2024

Signed-off-by: Stefan Büringer [email protected]

What this PR does / why we need it:
Follow-up of this PR #10628 for Cluster topology (also similar to #10688)

Some example logs

Setting a field in KubeadmControlPlane

I0528 10:14:56.989054 96 reconcile_state.go:353] "Patching KubeadmControlPlane/development-10871-98gvp, diff: {"spec":{"kubeadmConfigSpec":{"clusterConfiguration":{"imageRepository":"abc"}}}}" controller="topology/cluster" controllerGroup="cluster.x-k8s.io" controllerKind="Cluster" Cluster="default/development-10871" namespace="default" name="development-10871" reconcileID="f6b52e3b-7ab8-48b5-a661-166d6945f726" resource={"group":"controlplane.cluster.x-k8s.io","version":"v1beta1","resource":"KubeadmControlPlane"} KubeadmControlPlane="default/development-10871-98gvp"

Rotating a DockerMachineTemplate

Rotate the template

I0528 10:21:12.163575 96 reconcile_state.go:691] "Rotating DockerMachineTemplate/development-10871-md-0-gczmp, new name development-10871-md-0-d2kbm, diff: {"spec":{"template":{"spec":{"customImage":"abc2"}}}}" controller="topology/cluster" controllerGroup="cluster.x-k8s.io" controllerKind="Cluster" Cluster="default/development-10871" namespace="default" name="development-10871" reconcileID="2685e1d2-7bf8-4a81-a191-18067b159da2" MachineDeployment="default/development-10871-md-0-h72rd" machineDeploymentTopology="md-0" resource={"group":"infrastructure.cluster.x-k8s.io","version":"v1beta1","resource":"DockerMachineTemplate"} DockerMachineTemplate="default/development-10871-md-0-gczmp"

Patch MachineDeployment

I0528 10:21:16.201107 96 reconcile_state.go:763] "Patching MachineDeployment/development-10871-md-0-h72rd, diff: {"spec":{"template":{"spec":{"infrastructureRef":{"name":"development-10871-md-0-d2kbm"}}}}}" controller="topology/cluster" controllerGroup="cluster.x-k8s.io" controllerKind="Cluster" Cluster="default/development-10871" namespace="default" name="development-10871" reconcileID="2685e1d2-7bf8-4a81-a191-18067b159da2" MachineDeployment="default/development-10871-md-0-h72rd" machineDeploymentTopology="md-0" resource={"group":"cluster.x-k8s.io","version":"v1beta1","resource":"MachineDeployment"} MachineDeployment="default/development-10871-md-0-h72rd"

MachineDeployment controller creates new MachineSet (this is from: #10688)

I0528 10:21:16.230154 96 machinedeployment_sync.go:175] "Creating new MachineSet, couldn't find MachineSet matching MachineDeployment spec template: MachineSet development-10871-md-0-h72rd-8pt2f: diff: &v1beta1.MachineTemplateSpec{\n ObjectMeta: {},\n Spec: v1beta1.MachineSpec{\n ClusterName: "development-10871",\n Bootstrap: {ConfigRef: &{Kind: "KubeadmConfigTemplate", Namespace: "default", Name: "development-10871-md-0-xvf2n", APIVersion: "bootstrap.cluster.x-k8s.io", ...}},\n InfrastructureRef: v1.ObjectReference{\n Kind: "DockerMachineTemplate",\n Namespace: "default",\n- Name: "development-10871-md-0-zm7np",\n+ Name: "development-10871-md-0-d2kbm",\n UID: "",\n APIVersion: "infrastructure.cluster.x-k8s.io",\n ... // 2 identical fields\n },\n Version: &"v1.30.0",\n ProviderID: nil,\n ... // 4 identical fields\n },\n },MachineSet development-10871-md-0-h72rd-pw246: diff: &v1beta1.MachineTemplateSpec{\n ObjectMeta: {},\n Spec: v1beta1.MachineSpec{\n ClusterName: "development-10871",\n Bootstrap: {ConfigRef: &{Kind: "KubeadmConfigTemplate", Namespace: "default", Name: "development-10871-md-0-xvf2n", APIVersion: "bootstrap.cluster.x-k8s.io", ...}},\n InfrastructureRef: v1.ObjectReference{\n Kind: "DockerMachineTemplate",\n Namespace: "default",\n- Name: "development-10871-md-0-gczmp",\n+ Name: "development-10871-md-0-d2kbm",\n UID: "",\n APIVersion: "infrastructure.cluster.x-k8s.io",\n ... // 2 identical fields\n },\n Version: &"v1.30.0",\n ProviderID: nil,\n ... // 4 identical fields\n },\n }" controller="machinedeployment" controllerGroup="cluster.x-k8s.io" controllerKind="MachineDeployment" MachineDeployment="default/development-10871-md-0-h72rd" namespace="default" name="development-10871-md-0-h72rd" reconcileID="6d096578-2592-425c-9809-702abf427f05" Cluster="default/development-10871" MachineSet="default/development-10871-md-0-h72rd-ntptx"

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Related to #8186

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area PR is missing an area label size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 28, 2024
@sbueringer sbueringer added the area/clusterclass Issues or PRs related to clusterclass label May 28, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-area PR is missing an area label label May 28, 2024
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-conformance-ci-latest-main
/test pull-cluster-api-e2e-conformance-main
/test pull-cluster-api-e2e-main
/test pull-cluster-api-e2e-mink8s-main
/test pull-cluster-api-e2e-upgrade-1-30-1-31-main

@@ -450,7 +450,12 @@ func (r *Reconciler) reconcileCluster(ctx context.Context, s *scope.Scope) error
return nil
}

log.Infof("Patching %s", tlog.KObj{Obj: s.Current.Cluster})
changes := patchHelper.Changes()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has there been consideration to let this changes log be part of the patchHelper.Patch func?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. I think it would work for almost all cases. Except the rotation. For the rotation case we create a new patchHelper because we eventually decide (after diffing) that we have to create an entirely new object.

So that patchHelper is not aware of the old object / the diff.

@fabriziopandini
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 30, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 457f2e1fe2bf345eff7f4affe5aefce5d25bfe1c

@sbueringer
Copy link
Member Author

/assign @enxebre

@chrischdi
Copy link
Member

/approve

/hold in case you want to wait for @enxebre

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 31, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 31, 2024
@enxebre
Copy link
Member

enxebre commented May 31, 2024

/hold cancel
Thanks, I'm good proceeding as it is

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 31, 2024
@k8s-ci-robot k8s-ci-robot merged commit 16baac8 into kubernetes-sigs:main May 31, 2024
39 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.8 milestone May 31, 2024
@sbueringer sbueringer deleted the pr-cr-topology-log branch May 31, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/clusterclass Issues or PRs related to clusterclass cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants