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

⚠️ KCP: Stop updating and using Kubeadm's ClusterStatus with Kubernetes v1.22 #4643

Conversation

fabriziopandini
Copy link
Member

What this PR does / why we need it:
This PR makes it possible for CAPI 0.4.x to work with Kubernetes/kubeadm v1.22.0, where the ClusterStatus field inside the Kubeadm-config has been dropped.

Which issue(s) this PR fixes:
Fixes #4423

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 20, 2021
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 20, 2021
@fabriziopandini
Copy link
Member Author

/hold
I need to check CI Ferros, they are not happening locally 🤔

@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 20, 2021
@sbueringer
Copy link
Member

sbueringer commented May 20, 2021

@fabriziopandini I'm not sure if you're aware so I thought I just mention it. Locally you're testing exactly this branch. Prow tests the commit which is created after this branch is merged into the base branch. Maybe that explains the error. It only really leads to differing results in rare cases. (but we had a few of them on-prem)

@fabriziopandini
Copy link
Member Author

Agree, rebase is usually the first things to do....

controlplane/kubeadm/internal/workload_cluster.go Outdated Show resolved Hide resolved
controlplane/kubeadm/internal/workload_cluster.go Outdated Show resolved Hide resolved
controlplane/kubeadm/internal/workload_cluster.go Outdated Show resolved Hide resolved
controlplane/kubeadm/internal/workload_cluster.go Outdated Show resolved Hide resolved
&actualConfig,
)).To(Succeed())

g.Expect(actualConfig.Data[clusterStatusKey]).To(Equal("apiEndpoints:\n" +
Copy link
Member

Choose a reason for hiding this comment

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

Could it be worth to switch to multiline strings here?

Copy link
Member Author

@fabriziopandini fabriziopandini May 24, 2021

Choose a reason for hiding this comment

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

IMO multiline strings makes the code less readable when using yaml, because the indentation gets abruptly interrupted (and this is even worst if we are in a middle in of table tests / a series of test cases).
Also, we already did this for recent changes in KCP (e.g. all the refactor on the kubeadm config update)...

Copy link
Member

Choose a reason for hiding this comment

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

Could you provide an example? I'm not sure how this is better than a straight multiline string

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm happy to change if you feel this is better, but here it is an example of indentation hard to read due to multiline strings

{
name: "updates the config map",
scheduler: kubeadmv1beta1.ControlPlaneComponent{ExtraArgs: map[string]string{"foo": "bar"}},
objs: []client.Object{kubeadmConfig},
expectErr: false,
expectedChanged: true,
expectedScheduler: `apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
scheduler:
extraArgs:
foo: bar
`,
},

This is ( much more complex) an example without multiline strings; indentation is consisted and easier to read

{
name: "it should set the scheduler config",
clusterConfigurationData: "apiVersion: kubeadm.k8s.io/v1beta2\n" +
"kind: ClusterConfiguration\n",
newScheduler: bootstrapv1.ControlPlaneComponent{
ExtraArgs: map[string]string{
"bar": "baz",
"someKey": "someVal",
},
ExtraVolumes: []bootstrapv1.HostPathMount{
{
Name: "mount2",
HostPath: "/bar/baz",
MountPath: "/foo/bar",
},
},
},
wantClusterConfiguration: "apiServer: {}\n" +
"apiVersion: kubeadm.k8s.io/v1beta2\n" +
"controllerManager: {}\n" +
"dns: {}\n" +
"etcd: {}\n" +
"kind: ClusterConfiguration\n" +
"networking: {}\n" +
"scheduler:\n" +
" extraArgs:\n" +
" bar: baz\n" +
" someKey: someVal\n" +
" extraVolumes:\n" +
" - hostPath: /bar/baz\n" +
" mountPath: /foo/bar\n" +
" name: mount2\n",
},

Copy link
Member

Choose a reason for hiding this comment

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

You could start the multi-line string with a new line and use TrimSpace https://play.golang.org/p/YShA372kY82 ?

Copy link
Member

Choose a reason for hiding this comment

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

Let's tackle this in a new PR?

bindPort: 6443
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterStatus`,
clusterStatusKey: "apiEndpoints:\n" +
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, re:multiline strings

machine: machine,
objs: []client.Object{kubeadmConfig},
expectErr: false,
expectedEndpoints: "apiEndpoints:\n" +
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, re:multiline strings

@vincepri
Copy link
Member

Why is this PR marked as a breaking change?

@fabriziopandini fabriziopandini force-pushed the stop-updating-ClusterStatus-for-KubernetesVersionGTE-v1.22.0-v1alpha4 branch from 6d60650 to 76e4cf8 Compare May 24, 2021 20:13
@fabriziopandini
Copy link
Member Author

Why is this PR marked as a breaking change?

I made this breaking change to raise the attention on the fact the there ClusterStatus is going away, in case some tools on top of CAPI is not paying attention to kubeadm changes.

@vincepri
Copy link
Member

/retitle ⚠️ KCP: Stop updating and using Kubeadm's ClusterStatus with Kuberntes v1.22

@k8s-ci-robot k8s-ci-robot changed the title ⚠️ Stop updating ClusterStatus for KubernetesVersion >= v1.22.0 ⚠️ KCP: Stop updating and using Kubeadm's ClusterStatus with Kuberntes v1.22 May 24, 2021
@vincepri
Copy link
Member

/milestone v0.4

@k8s-ci-robot k8s-ci-robot added this to the v0.4 milestone May 24, 2021
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve
/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 25, 2021
@k8s-ci-robot
Copy link
Contributor

[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 /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 25, 2021
@vincepri
Copy link
Member

@CecileRobertMichon over to you

@CecileRobertMichon
Copy link
Contributor

I need to check CI Ferros, they are not happening locally

is the hold still in place intentionally @fabriziopandini ?

Copy link
Contributor

@CecileRobertMichon CecileRobertMichon left a comment

Choose a reason for hiding this comment

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

/lgtm

@fabriziopandini
Copy link
Member Author

/hold cancel
Now everything is fixed

@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 25, 2021
@vincepri
Copy link
Member

/retest

@fabriziopandini fabriziopandini force-pushed the stop-updating-ClusterStatus-for-KubernetesVersionGTE-v1.22.0-v1alpha4 branch from 76e4cf8 to 40e737b Compare May 25, 2021 19:48
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 25, 2021
@fabriziopandini
Copy link
Member Author

rebased

@fabriziopandini
Copy link
Member Author

/retest

@CecileRobertMichon
Copy link
Contributor

/retitle ⚠️ KCP: Stop updating and using Kubeadm's ClusterStatus with Kubernetes v1.22

@k8s-ci-robot k8s-ci-robot changed the title ⚠️ KCP: Stop updating and using Kubeadm's ClusterStatus with Kuberntes v1.22 ⚠️ KCP: Stop updating and using Kubeadm's ClusterStatus with Kubernetes v1.22 May 26, 2021
@CecileRobertMichon
Copy link
Contributor

/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 26, 2021
@k8s-ci-robot k8s-ci-robot merged commit f1834fa into kubernetes-sigs:master May 26, 2021
@fabriziopandini fabriziopandini deleted the stop-updating-ClusterStatus-for-KubernetesVersionGTE-v1.22.0-v1alpha4 branch May 26, 2021 08:46
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. 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.

remove usage of the kubeadm ClusterStatus object in Cluster API.
5 participants