Skip to content

Commit 969b81a

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

30 files changed

+158
-611
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: 18 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -18,64 +18,49 @@ package cloudinit
1818

1919
import (
2020
"bytes"
21-
_ "embed"
2221
"fmt"
2322
"text/template"
2423

2524
"github.com/blang/semver/v4"
2625
"github.com/pkg/errors"
2726

2827
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2"
29-
"sigs.k8s.io/cluster-api/util/version"
3028
)
3129

3230
const (
3331
standardJoinCommand = "kubeadm join --config /run/kubeadm/kubeadm-join-config.yaml %s"
3432
// sentinelFileCommand writes a file to /run/cluster-api to signal successful Kubernetes bootstrapping in a way that
3533
// 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
34+
sentinelFileCommand = "echo success > /run/cluster-api/bootstrap-success.complete"
35+
cloudConfigHeader = `## template: jinja
4136
#cloud-config
4237
`
4338
)
4439

4540
// BaseUserData is shared across all the various types of files written to disk.
4641
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
42+
Header string
43+
BootCommands []string
44+
PreKubeadmCommands []string
45+
PostKubeadmCommands []string
46+
AdditionalFiles []bootstrapv1.File
47+
WriteFiles []bootstrapv1.File
48+
Users []bootstrapv1.User
49+
NTP *bootstrapv1.NTP
50+
DiskSetup *bootstrapv1.DiskSetup
51+
Mounts []bootstrapv1.MountPoints
52+
ControlPlane bool
53+
KubeadmCommand string
54+
KubeadmVerbosity string
55+
SentinelFileCommand string
56+
KubernetesVersion semver.Version
6357
}
6458

65-
func (input *BaseUserData) prepare() error {
59+
func (input *BaseUserData) prepare() {
6660
input.Header = cloudConfigHeader
6761
input.WriteFiles = append(input.WriteFiles, input.AdditionalFiles...)
6862
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-
}
7763
input.SentinelFileCommand = sentinelFileCommand
78-
return nil
7964
}
8065

8166
func generate(kind string, tpl string, data interface{}) ([]byte, error) {
@@ -124,36 +109,3 @@ func generate(kind string, tpl string, data interface{}) ([]byte, error) {
124109

125110
return out.Bytes(), nil
126111
}
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-
}

0 commit comments

Comments
 (0)