Skip to content

Commit a81eaca

Browse files
committed
Remove KubeadmConfig UseExperimentalRetryJoin
Signed-off-by: Stefan Büringer buringerst@vmware.com
1 parent 2fbb798 commit a81eaca

25 files changed

+118
-600
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ linters:
238238
# should be removed as the referenced deprecated item is removed from the project.
239239
- linters:
240240
- staticcheck
241-
text: 'SA1019: (bootstrapv1.ClusterStatus|KubeadmConfigSpec.UseExperimentalRetryJoin|scope.Config.Spec.UseExperimentalRetryJoin|DockerMachine.Spec.Bootstrapped|machineStatus.Bootstrapped|dockerMachine.Spec.Backend.Docker.Bootstrapped|dockerMachine.Spec.Bootstrapped|devMachine.Spec.Backend.Docker.Bootstrapped|c.TopologyPlan|clusterv1.ClusterClassVariableMetadata|clusterv1beta1.ClusterClassVariableMetadata|(variable|currentDefinition|specVar|newVariableDefinition|statusVarDefinition).Metadata) is deprecated'
241+
text: 'SA1019: (bootstrapv1.ClusterStatus|DockerMachine.Spec.Bootstrapped|machineStatus.Bootstrapped|dockerMachine.Spec.Backend.Docker.Bootstrapped|dockerMachine.Spec.Bootstrapped|devMachine.Spec.Backend.Docker.Bootstrapped|c.TopologyPlan|clusterv1.ClusterClassVariableMetadata|clusterv1beta1.ClusterClassVariableMetadata|(variable|currentDefinition|specVar|newVariableDefinition|statusVarDefinition).Metadata) is deprecated'
242242
# Deprecations for MD revision management
243243
- linters:
244244
- staticcheck

bootstrap/kubeadm/api/v1beta1/conversion.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ func Convert_v1beta2_KubeadmConfigStatus_To_v1beta1_KubeadmConfigStatus(in *boot
8282
return nil
8383
}
8484

85+
func Convert_v1beta1_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in *KubeadmConfigSpec, out *bootstrapv1.KubeadmConfigSpec, s apimachineryconversion.Scope) error {
86+
// NOTE: v1beta2 KubeadmConfigSpec does not have UseExperimentalRetryJoin anymore, so it's fine to just lose this field.
87+
return autoConvert_v1beta1_KubeadmConfigSpec_To_v1beta2_KubeadmConfigSpec(in, out, s)
88+
}
89+
8590
func Convert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in *KubeadmConfigStatus, out *bootstrapv1.KubeadmConfigStatus, s apimachineryconversion.Scope) error {
8691
if err := autoConvert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in, out, s); err != nil {
8792
return err

bootstrap/kubeadm/api/v1beta1/conversion_test.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ func TestFuzzyConversion(t *testing.T) {
3939
FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmConfigFuzzFuncs},
4040
}))
4141
t.Run("for KubeadmConfigTemplate", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
42-
Hub: &bootstrapv1.KubeadmConfigTemplate{},
43-
Spoke: &KubeadmConfigTemplate{},
42+
Hub: &bootstrapv1.KubeadmConfigTemplate{},
43+
Spoke: &KubeadmConfigTemplate{},
44+
FuzzerFuncs: []fuzzer.FuzzerFuncs{KubeadmConfigTemplateFuzzFuncs},
4445
}))
4546
}
4647

4748
func KubeadmConfigFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
4849
return []interface{}{
4950
hubKubeadmConfigStatus,
51+
spokeKubeadmConfigSpec,
5052
spokeKubeadmConfigStatus,
5153
}
5254
}
@@ -69,6 +71,13 @@ func hubKubeadmConfigStatus(in *bootstrapv1.KubeadmConfigStatus, c fuzz.Continue
6971
}
7072
}
7173

74+
func spokeKubeadmConfigSpec(in *KubeadmConfigSpec, c fuzz.Continue) {
75+
c.FuzzNoCustom(in)
76+
77+
// Drop UseExperimentalRetryJoin as we intentionally don't preserve it.
78+
in.UseExperimentalRetryJoin = false
79+
}
80+
7281
func spokeKubeadmConfigStatus(in *KubeadmConfigStatus, c fuzz.Continue) {
7382
c.FuzzNoCustom(in)
7483
// Drop empty structs with only omit empty fields.
@@ -78,3 +87,9 @@ func spokeKubeadmConfigStatus(in *KubeadmConfigStatus, c fuzz.Continue) {
7887
}
7988
}
8089
}
90+
91+
func KubeadmConfigTemplateFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
92+
return []interface{}{
93+
spokeKubeadmConfigSpec,
94+
}
95+
}

bootstrap/kubeadm/api/v1beta1/zz_generated.conversion.go

Lines changed: 6 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootstrap/kubeadm/api/v1beta2/kubeadmconfig_types.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,6 @@ type KubeadmConfigSpec struct {
122122
// +optional
123123
Verbosity *int32 `json:"verbosity,omitempty"`
124124

125-
// useExperimentalRetryJoin replaces a basic kubeadm command with a shell
126-
// script with retries for joins.
127-
//
128-
// This is meant to be an experimental temporary workaround on some environments
129-
// where joins fail due to timing (and other issues). The long term goal is to add retries to
130-
// kubeadm proper and use that functionality.
131-
//
132-
// This will add about 40KB to userdata
133-
//
134-
// For more information, refer to https://github.com/kubernetes-sigs/cluster-api/pull/2763#discussion_r397306055.
135-
// +optional
136-
//
137-
// Deprecated: This experimental fix is no longer needed and this field will be removed in a future release.
138-
// When removing also remove from staticcheck exclude-rules for SA1019 in golangci.yml
139-
UseExperimentalRetryJoin bool `json:"useExperimentalRetryJoin,omitempty"`
140-
141125
// ignition contains Ignition specific configuration.
142126
// +optional
143127
Ignition *IgnitionSpec `json:"ignition,omitempty"`
@@ -347,16 +331,6 @@ func (c *KubeadmConfigSpec) validateIgnition(pathPrefix *field.Path) field.Error
347331
}
348332
}
349333

350-
if c.UseExperimentalRetryJoin {
351-
allErrs = append(
352-
allErrs,
353-
field.Forbidden(
354-
pathPrefix.Child("useExperimentalRetryJoin"),
355-
cannotUseWithIgnition,
356-
),
357-
)
358-
}
359-
360334
for i, file := range c.Files {
361335
if file.Encoding == Gzip || file.Encoding == GzipBase64 {
362336
allErrs = append(

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootstrap/kubeadm/internal/cloudinit/cloudinit.go

Lines changed: 17 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -26,54 +26,41 @@ import (
2626
"github.com/pkg/errors"
2727

2828
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2"
29-
"sigs.k8s.io/cluster-api/util/version"
3029
)
3130

3231
const (
3332
standardJoinCommand = "kubeadm join --config /run/kubeadm/kubeadm-join-config.yaml %s"
3433
// sentinelFileCommand writes a file to /run/cluster-api to signal successful Kubernetes bootstrapping in a way that
3534
// works both for Linux and Windows OS.
36-
sentinelFileCommand = "echo success > /run/cluster-api/bootstrap-success.complete"
37-
retriableJoinScriptName = "/usr/local/bin/kubeadm-bootstrap-script"
38-
retriableJoinScriptOwner = "root"
39-
retriableJoinScriptPermissions = "0755"
40-
cloudConfigHeader = `## template: jinja
35+
sentinelFileCommand = "echo success > /run/cluster-api/bootstrap-success.complete"
36+
cloudConfigHeader = `## template: jinja
4137
#cloud-config
4238
`
4339
)
4440

4541
// BaseUserData is shared across all the various types of files written to disk.
4642
type BaseUserData struct {
47-
Header string
48-
BootCommands []string
49-
PreKubeadmCommands []string
50-
PostKubeadmCommands []string
51-
AdditionalFiles []bootstrapv1.File
52-
WriteFiles []bootstrapv1.File
53-
Users []bootstrapv1.User
54-
NTP *bootstrapv1.NTP
55-
DiskSetup *bootstrapv1.DiskSetup
56-
Mounts []bootstrapv1.MountPoints
57-
ControlPlane bool
58-
UseExperimentalRetry bool
59-
KubeadmCommand string
60-
KubeadmVerbosity string
61-
SentinelFileCommand string
62-
KubernetesVersion semver.Version
43+
Header string
44+
BootCommands []string
45+
PreKubeadmCommands []string
46+
PostKubeadmCommands []string
47+
AdditionalFiles []bootstrapv1.File
48+
WriteFiles []bootstrapv1.File
49+
Users []bootstrapv1.User
50+
NTP *bootstrapv1.NTP
51+
DiskSetup *bootstrapv1.DiskSetup
52+
Mounts []bootstrapv1.MountPoints
53+
ControlPlane bool
54+
KubeadmCommand string
55+
KubeadmVerbosity string
56+
SentinelFileCommand string
57+
KubernetesVersion semver.Version
6358
}
6459

6560
func (input *BaseUserData) prepare() error {
6661
input.Header = cloudConfigHeader
6762
input.WriteFiles = append(input.WriteFiles, input.AdditionalFiles...)
6863
input.KubeadmCommand = fmt.Sprintf(standardJoinCommand, input.KubeadmVerbosity)
69-
if input.UseExperimentalRetry {
70-
input.KubeadmCommand = retriableJoinScriptName
71-
joinScriptFile, err := generateBootstrapScript(input, input.KubernetesVersion)
72-
if err != nil {
73-
return errors.Wrap(err, "failed to generate user data for machine joining control plane")
74-
}
75-
input.WriteFiles = append(input.WriteFiles, *joinScriptFile)
76-
}
7764
input.SentinelFileCommand = sentinelFileCommand
7865
return nil
7966
}
@@ -124,36 +111,3 @@ func generate(kind string, tpl string, data interface{}) ([]byte, error) {
124111

125112
return out.Bytes(), nil
126113
}
127-
128-
var (
129-
//go:embed kubeadm-bootstrap-script-pre-k8s-1-31.sh
130-
kubeadmBootstrapScriptPre1_31 string
131-
//go:embed kubeadm-bootstrap-script.sh
132-
kubeadmBootstrapScript string
133-
134-
// kubernetesVersion1_31 is the version where kubeadm removed the update-status phase
135-
// and introduced new phases with the ControlPlaneKubeletLocalMode feature gate.
136-
kubernetesVersion1_31 = semver.MustParse("1.31.0")
137-
)
138-
139-
func generateBootstrapScript(input interface{}, parsedversion semver.Version) (*bootstrapv1.File, error) {
140-
bootstrapScript := kubeadmBootstrapScript
141-
if useKubeadmBootstrapScriptPre1_31(parsedversion) {
142-
bootstrapScript = kubeadmBootstrapScriptPre1_31
143-
}
144-
145-
joinScript, err := generate("JoinScript", bootstrapScript, input)
146-
if err != nil {
147-
return nil, errors.Wrap(err, "failed to bootstrap script for machine joins")
148-
}
149-
return &bootstrapv1.File{
150-
Path: retriableJoinScriptName,
151-
Owner: retriableJoinScriptOwner,
152-
Permissions: retriableJoinScriptPermissions,
153-
Content: string(joinScript),
154-
}, nil
155-
}
156-
157-
func useKubeadmBootstrapScriptPre1_31(parsedversion semver.Version) bool {
158-
return version.Compare(parsedversion, kubernetesVersion1_31, version.WithoutPreReleases()) < 0
159-
}

bootstrap/kubeadm/internal/cloudinit/cloudinit_test.go

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package cloudinit
1919
import (
2020
"testing"
2121

22-
"github.com/blang/semver/v4"
2322
. "github.com/onsi/gomega"
2423
"k8s.io/utils/ptr"
2524

@@ -250,82 +249,6 @@ func TestNewJoinControlPlaneAdditionalFileEncodings(t *testing.T) {
250249
}
251250
}
252251

253-
func TestNewJoinControlPlaneExperimentalRetry(t *testing.T) {
254-
g := NewWithT(t)
255-
256-
cpinput := &ControlPlaneJoinInput{
257-
BaseUserData: BaseUserData{
258-
Header: "test",
259-
BootCommands: nil,
260-
PreKubeadmCommands: nil,
261-
PostKubeadmCommands: nil,
262-
UseExperimentalRetry: true,
263-
WriteFiles: nil,
264-
Users: nil,
265-
NTP: nil,
266-
},
267-
Certificates: secret.Certificates{},
268-
BootstrapToken: "my-bootstrap-token",
269-
JoinConfiguration: "my-join-config",
270-
}
271-
272-
for _, certificate := range cpinput.Certificates {
273-
certificate.KeyPair = &certs.KeyPair{
274-
Cert: []byte("some certificate"),
275-
Key: []byte("some key"),
276-
}
277-
}
278-
279-
out, err := NewJoinControlPlane(cpinput)
280-
g.Expect(err).ToNot(HaveOccurred())
281-
282-
expectedFiles := []string{
283-
`- path: ` + retriableJoinScriptName + `
284-
owner: ` + retriableJoinScriptOwner + `
285-
permissions: '` + retriableJoinScriptPermissions + `'
286-
`,
287-
}
288-
for _, f := range expectedFiles {
289-
g.Expect(out).To(ContainSubstring(f))
290-
}
291-
}
292-
293-
func Test_useKubeadmBootstrapScriptPre1_31(t *testing.T) {
294-
tests := []struct {
295-
name string
296-
parsedversion semver.Version
297-
want bool
298-
}{
299-
{
300-
name: "true for version for v1.30",
301-
parsedversion: semver.MustParse("1.30.99"),
302-
want: true,
303-
},
304-
{
305-
name: "true for version for v1.28",
306-
parsedversion: semver.MustParse("1.28.0"),
307-
want: true,
308-
},
309-
{
310-
name: "false for v1.31.0",
311-
parsedversion: semver.MustParse("1.31.0"),
312-
want: false,
313-
},
314-
{
315-
name: "false for v1.31.0-beta.0",
316-
parsedversion: semver.MustParse("1.31.0-beta.0"),
317-
want: false,
318-
},
319-
}
320-
for _, tt := range tests {
321-
t.Run(tt.name, func(t *testing.T) {
322-
if got := useKubeadmBootstrapScriptPre1_31(tt.parsedversion); got != tt.want {
323-
t.Errorf("useKubeadmBootstrapScriptPre1_31() = %v, want %v", got, tt.want)
324-
}
325-
})
326-
}
327-
}
328-
329252
func TestNewJoinControlPlaneCommands(t *testing.T) {
330253
g := NewWithT(t)
331254

0 commit comments

Comments
 (0)