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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃尡 Add compare util using go-cmp, modify webhooks & KCP controller #10628

Merged

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented May 15, 2024

What this PR does / why we need it:
Needs a bit more work and some manual tests (want to see how the diffs are looking in logs)

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 #8186

Example logs for KCP controller

I0516 16:01:22.008912      58 controller.go:412] "Rolling out Control Plane machines: Machine capi-quickstart-control-plane-xvq7h needs rollout: Machine KubeadmConfig ClusterConfiguration is outdated: diff: &v1beta1.ClusterConfiguration{\n    ... // 3 identical fields\n    KubernetesVersion:    \"\",\n    ControlPlaneEndpoint: \"\",\n    APIServer: v1beta1.APIServer{\n      ControlPlaneComponent: {},\n      CertSANs: []string{\n        \"localhost\",\n-       \"127.0.0.1\",\n        \"0.0.0.0\",\n        \"host.docker.internal\",\n      },\n      TimeoutForControlPlane: nil,\n    },\n    ControllerManager: {ExtraArgs: {\"enable-hostpath-provisioner\": \"true\"}},\n    Scheduler:         {},\n    ... // 5 identical fields\n  }" controller="kubeadmcontrolplane" controllerGroup="controlplane.cluster.x-k8s.io" controllerKind="KubeadmControlPlane" KubeadmControlPlane="default/capi-quickstart-control-plane" namespace="default" name="capi-quickstart-control-plane" reconcileID="93e4bce7-00da-44c7-9421-a714ecf996ca" Cluster="default/capi-quickstart" machinesNeedingRollout=["capi-quickstart-control-plane-xvq7h"]

Message after removing escaping

Rolling out Control Plane machines: Machine capi-quickstart-control-plane-xvq7h needs rollout: Machine KubeadmConfig ClusterConfiguration is outdated: diff: &v1beta1.ClusterConfiguration{
    ... // 3 identical fields
    KubernetesVersion:    "",
    ControlPlaneEndpoint: "",
    APIServer: v1beta1.APIServer{
      ControlPlaneComponent: {},
      CertSANs: []string{
        "localhost",
-       "127.0.0.1",
        "0.0.0.0",
        "host.docker.internal",
      },
      TimeoutForControlPlane: nil,
    },
    ControllerManager: {ExtraArgs: {"enable-hostpath-provisioner": "true"}},
    Scheduler:         {},
    ... // 5 identical fields
  }

Example for webhook

k apply -f /var/folders/v0/mny6w2dd33gfzwmwxb3wyyx40000gq/T/kubectl-edit-3932073547.yaml
[kubeadmcontrolplanetemplate.controlplane.cluster.x-k8s.io/quick-start-control-plane-2](http://kubeadmcontrolplanetemplate.controlplane.cluster.x-k8s.io/quick-start-control-plane-2) configured
[kubeadmcontrolplanetemplate.controlplane.cluster.x-k8s.io/quick-start-control-plane-3](http://kubeadmcontrolplanetemplate.controlplane.cluster.x-k8s.io/quick-start-control-plane-3) configured
The KubeadmControlPlaneTemplate "quick-start-control-plane" is invalid: spec.template.spec: Invalid value: v1beta1.KubeadmControlPlaneTemplate{TypeMeta:v1.TypeMeta{Kind:"KubeadmControlPlaneTemplate", APIVersion:"[controlplane.cluster.x-k8s.io/v1beta1](http://controlplane.cluster.x-k8s.io/v1beta1)"}, ObjectMeta:v1.ObjectMeta{Name:"quick-start-control-plane", GenerateName:"", Namespace:"default", SelfLink:"", UID:"288374d2-7a3b-4a26-9606-0627bd06db1d", ResourceVersion:"2293", Generation:2, CreationTimestamp:time.Date(2024, time.May, 16, 16, 6, 12, 0, time.Local), DeletionTimestamp:<nil>, DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string(nil), Annotations:map[string]string{"[kubectl.kubernetes.io/last-applied-configuration](http://kubectl.kubernetes.io/last-applied-configuration)":"{\"apiVersion\":\"[controlplane.cluster.x-k8s.io/v1beta1](http://controlplane.cluster.x-k8s.io/v1beta1)\",\"kind\":\"KubeadmControlPlaneTemplate\",\"metadata\":{\"annotations\":{},\"creationTimestamp\":\"2024-05-16T16:06:12Z\",\"generation\":1,\"name\":\"quick-start-control-plane\",\"namespace\":\"default\",\"resourceVersion\":\"2293\",\"uid\":\"288374d2-7a3b-4a26-9606-0627bd06db1d\"},\"spec\":{\"template\":{\"metadata\":{},\"spec\":{\"kubeadmConfigSpec\":{\"clusterConfiguration\":{\"apiServer\":{\"certSANs\":[\"localhost\",\"0.0.0.0\",\"host.docker.internal\"]},\"controllerManager\":{\"extraArgs\":{\"enable-hostpath-provisioner\":\"true\"}},\"dns\":{},\"etcd\":{},\"networking\":{},\"scheduler\":{}},\"files\":[{\"content\":\"SOMETESTCONTENT\\n\",\"path\":\"abc\"}],\"format\":\"cloud-config\",\"initConfiguration\":{\"localAPIEndpoint\":{},\"nodeRegistration\":{\"criSocket\":\"/var/run/containerd/containerd.sock\",\"imagePullPolicy\":\"IfNotPresent\",\"kubeletExtraArgs\":{\"eviction-hard\":\"nodefs.available\\u003c0%,nodefs.inodesFree\\u003c0%,imagefs.available\\u003c0%\"}}},\"joinConfiguration\":{\"discovery\":{},\"nodeRegistration\":{\"criSocket\":\"/var/run/containerd/containerd.sock\",\"imagePullPolicy\":\"IfNotPresent\",\"kubeletExtraArgs\":{\"eviction-hard\":\"nodefs.available\\u003c0%,nodefs.inodesFree\\u003c0%,imagefs.available\\u003c0%\"}}}},\"rolloutStrategy\":{\"rollingUpdate\":{\"maxSurge\":1},\"type\":\"RollingUpdate\"}}}}}\n"}, OwnerReferences:[]v1.OwnerReference(nil), Finalizers:[]string(nil), ManagedFields:[]v1.ManagedFieldsEntry{v1.ManagedFieldsEntry{Manager:"kubectl-client-side-apply", Operation:"Update", APIVersion:"[controlplane.cluster.x-k8s.io/v1beta1](http://controlplane.cluster.x-k8s.io/v1beta1)", Time:time.Date(2024, time.May, 16, 16, 7, 25, 0, time.Local), FieldsType:"FieldsV1", FieldsV1:(*v1.FieldsV1)(0x4000a540a8), Subresource:""}}}, Spec:v1beta1.KubeadmControlPlaneTemplateSpec{Template:v1beta1.KubeadmControlPlaneTemplateResource{ObjectMeta:v1beta1.ObjectMeta{Labels:map[string]string(nil), Annotations:map[string]string(nil)}, Spec:v1beta1.KubeadmControlPlaneTemplateResourceSpec{MachineTemplate:(*v1beta1.KubeadmControlPlaneTemplateMachineTemplate)(nil), KubeadmConfigSpec:v1beta1.KubeadmConfigSpec{ClusterConfiguration:(*v1beta1.ClusterConfiguration)(0x4000d862c0), InitConfiguration:(*v1beta1.InitConfiguration)(0x40000ea620), JoinConfiguration:(*v1beta1.JoinConfiguration)(0x4001172000), Files:[]v1beta1.File{v1beta1.File{Path:"abc", Owner:"", Permissions:"", Encoding:"", Append:false, Content:"SOMETESTCONTENT\n", ContentFrom:(*v1beta1.FileSource)(nil)}}, DiskSetup:(*v1beta1.DiskSetup)(nil), Mounts:[]v1beta1.MountPoints(nil), PreKubeadmCommands:[]string(nil), PostKubeadmCommands:[]string(nil), Users:[]v1beta1.User(nil), NTP:(*v1beta1.NTP)(nil), Format:"cloud-config", Verbosity:(*int32)(nil), UseExperimentalRetryJoin:false, Ignition:(*v1beta1.IgnitionSpec)(nil)}, RolloutBefore:(*v1beta1.RolloutBefore)(nil), RolloutAfter:<nil>, RolloutStrategy:(*v1beta1.RolloutStrategy)(0x4000a54150), RemediationStrategy:(*v1beta1.RemediationStrategy)(nil)}}}}: KubeadmControlPlaneTemplate spec.template.spec field is immutable. Please create new resource instead. Diff: v1beta1.KubeadmControlPlaneTemplateResourceSpec{
    MachineTemplate: nil,
    KubeadmConfigSpec: v1beta1.KubeadmConfigSpec{
      ClusterConfiguration: &v1beta1.ClusterConfiguration{
        ... // 3 identical fields
        KubernetesVersion:    "",
        ControlPlaneEndpoint: "",
        APIServer: v1beta1.APIServer{
          ControlPlaneComponent: {},
          CertSANs: []string{
            "localhost",
-           "127.0.0.1",
            "0.0.0.0",
            "host.docker.internal",
          },
          TimeoutForControlPlane: nil,
        },
        ControllerManager: {ExtraArgs: {"enable-hostpath-provisioner": "true"}},
        Scheduler:         {},
        ... // 5 identical fields
      },
      InitConfiguration: &{NodeRegistration: {CRISocket: "/var/run/containerd/containerd.sock", KubeletExtraArgs: {"eviction-hard": "nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%"}, ImagePullPolicy: "IfNotPresent"}},
      JoinConfiguration: &{NodeRegistration: {CRISocket: "/var/run/containerd/containerd.sock", KubeletExtraArgs: {"eviction-hard": "nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%"}, ImagePullPolicy: "IfNotPresent"}},
      ... // 11 identical fields
    },
    RolloutBefore: nil,
    RolloutAfter:  nil,
    ... // 2 identical fields
  }

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 15, 2024
@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-area PR is missing an area label size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 15, 2024
@sbueringer sbueringer added the area/provider/control-plane-kubeadm Issues or PRs related to KCP label May 15, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-area PR is missing an area label label May 15, 2024
@sbueringer
Copy link
Member Author

sbueringer commented May 15, 2024

Not sure what the right areas are (apart from KCP)

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@sbueringer sbueringer force-pushed the pr-replace-reflect-equal branch 2 times, most recently from d7b3d5c to 8276336 Compare May 16, 2024 16:11
@sbueringer sbueringer changed the title [WIP] 馃尡 Add compare util using go-cmp, modify webhooks & KCP controller 馃尡 Add compare util using go-cmp, modify webhooks & KCP controller May 16, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 16, 2024
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@sbueringer
Copy link
Member Author

/assign @chrischdi @fabriziopandini

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

small nit

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@chrischdi
Copy link
Member

/lgtm

(failing test though)

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

LGTM label has been added.

Git tree hash: 1cbb61b35cb32a436cb37ed94cbe31e05798a4c7

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 17, 2024
@sbueringer
Copy link
Member Author

Ups, thx, fixed

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@chrischdi
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 17, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: c6142679f413cf7869f87d9fd3f3cf2730468d37

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 18, 2024
Signed-off-by: Stefan B眉ringer buringerst@vmware.com
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 21, 2024
@sbueringer
Copy link
Member Author

Had to rebase because of the defaulting webhook fix

/assign @fabriziopandini @chrischdi

@chrischdi
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 21, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 3dd034826d867dd90f918d23537ea8663305d1ec

@sbueringer
Copy link
Member Author

/assign @fabriziopandini

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

Nice
This will greatly improve debugging rollouts in the logs
/lgtm
/approved

@fabriziopandini
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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 22, 2024
@k8s-ci-robot k8s-ci-robot merged commit a2b7dd1 into kubernetes-sigs:main May 22, 2024
20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.8 milestone May 22, 2024
@sbueringer sbueringer deleted the pr-replace-reflect-equal branch May 22, 2024 14:18
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/provider/control-plane-kubeadm Issues or PRs related to KCP 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider replacing reflect.DeepEqual
4 participants