Skip to content

Commit 0c93929

Browse files
authored
Merge pull request kubernetes#75178 from rosti/kill-commonconfig
kubeadm: Cleanup CommonConfiguration
2 parents d29afda + 4567e7e commit 0c93929

File tree

3 files changed

+8
-55
lines changed

3 files changed

+8
-55
lines changed

cmd/kubeadm/app/apis/kubeadm/types.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -411,50 +411,3 @@ type HostPathMount struct {
411411
// PathType is the type of the HostPath.
412412
PathType v1.HostPathType
413413
}
414-
415-
// CommonConfiguration defines the list of common configuration elements and the getter
416-
// methods that must exist for both the InitConfiguration and JoinConfiguration objects.
417-
// This is used internally to deduplicate the kubeadm preflight checks.
418-
type CommonConfiguration interface {
419-
GetCRISocket() string
420-
GetNodeName() string
421-
GetKubernetesVersion() string
422-
}
423-
424-
// GetCRISocket will return the CRISocket that is defined for the InitConfiguration.
425-
// This is used internally to deduplicate the kubeadm preflight checks.
426-
func (cfg *InitConfiguration) GetCRISocket() string {
427-
return cfg.NodeRegistration.CRISocket
428-
}
429-
430-
// GetNodeName will return the NodeName that is defined for the InitConfiguration.
431-
// This is used internally to deduplicate the kubeadm preflight checks.
432-
func (cfg *InitConfiguration) GetNodeName() string {
433-
return cfg.NodeRegistration.Name
434-
}
435-
436-
// GetKubernetesVersion will return the KubernetesVersion that is defined for the InitConfiguration.
437-
// This is used internally to deduplicate the kubeadm preflight checks.
438-
func (cfg *InitConfiguration) GetKubernetesVersion() string {
439-
return cfg.KubernetesVersion
440-
}
441-
442-
// GetCRISocket will return the CRISocket that is defined for the JoinConfiguration.
443-
// This is used internally to deduplicate the kubeadm preflight checks.
444-
func (cfg *JoinConfiguration) GetCRISocket() string {
445-
return cfg.NodeRegistration.CRISocket
446-
}
447-
448-
// GetNodeName will return the NodeName that is defined for the JoinConfiguration.
449-
// This is used internally to deduplicate the kubeadm preflight checks.
450-
func (cfg *JoinConfiguration) GetNodeName() string {
451-
return cfg.NodeRegistration.Name
452-
}
453-
454-
// GetKubernetesVersion will return an empty string since KubernetesVersion is not a
455-
// defined property for JoinConfiguration. This will just cause the regex validation
456-
// of the defined version to be skipped during the preflight checks.
457-
// This is used internally to deduplicate the kubeadm preflight checks.
458-
func (cfg *JoinConfiguration) GetKubernetesVersion() string {
459-
return ""
460-
}

cmd/kubeadm/app/cmd/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ func NewCmdConfigImagesPull() *cobra.Command {
423423
kubeadmutil.CheckErr(err)
424424
internalcfg, err := configutil.LoadOrDefaultInitConfiguration(cfgPath, externalcfg)
425425
kubeadmutil.CheckErr(err)
426-
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), internalcfg.GetCRISocket())
426+
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), internalcfg.NodeRegistration.CRISocket)
427427
kubeadmutil.CheckErr(err)
428428
imagesPull := NewImagesPull(containerRuntime, images.GetAllImages(&internalcfg.ClusterConfiguration))
429429
kubeadmutil.CheckErr(imagesPull.PullAll())

cmd/kubeadm/app/preflight/checks.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigura
901901
}
902902

903903
if !isSecondaryControlPlane {
904-
checks = addCommonChecks(execer, cfg, checks)
904+
checks = addCommonChecks(execer, cfg.KubernetesVersion, &cfg.NodeRegistration, checks)
905905

906906
// Check IVPS required kernel module once we use IVPS kube-proxy mode
907907
if cfg.ComponentConfigs.KubeProxy != nil && cfg.ComponentConfigs.KubeProxy.Mode == ipvsutil.IPVSProxyMode {
@@ -959,7 +959,7 @@ func RunJoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.JoinConfigura
959959
FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletKubeConfigFileName)},
960960
FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletBootstrapKubeConfigFileName)},
961961
}
962-
checks = addCommonChecks(execer, cfg, checks)
962+
checks = addCommonChecks(execer, "", &cfg.NodeRegistration, checks)
963963
if cfg.ControlPlane == nil {
964964
checks = append(checks, FileAvailableCheck{Path: cfg.CACertPath})
965965
}
@@ -1006,8 +1006,8 @@ func RunOptionalJoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.Clust
10061006

10071007
// addCommonChecks is a helper function to deplicate checks that are common between both the
10081008
// kubeadm init and join commands
1009-
func addCommonChecks(execer utilsexec.Interface, cfg kubeadmapi.CommonConfiguration, checks []Checker) []Checker {
1010-
containerRuntime, err := utilruntime.NewContainerRuntime(execer, cfg.GetCRISocket())
1009+
func addCommonChecks(execer utilsexec.Interface, k8sVersion string, nodeReg *kubeadmapi.NodeRegistrationOptions, checks []Checker) []Checker {
1010+
containerRuntime, err := utilruntime.NewContainerRuntime(execer, nodeReg.CRISocket)
10111011
isDocker := false
10121012
if err != nil {
10131013
fmt.Printf("[preflight] WARNING: Couldn't create the interface used for talking to the container runtime: %v\n", err)
@@ -1044,8 +1044,8 @@ func addCommonChecks(execer utilsexec.Interface, cfg kubeadmapi.CommonConfigurat
10441044
}
10451045
checks = append(checks,
10461046
SystemVerificationCheck{IsDocker: isDocker},
1047-
HostnameCheck{nodeName: cfg.GetNodeName()},
1048-
KubeletVersionCheck{KubernetesVersion: cfg.GetKubernetesVersion(), exec: execer},
1047+
HostnameCheck{nodeName: nodeReg.Name},
1048+
KubeletVersionCheck{KubernetesVersion: k8sVersion, exec: execer},
10491049
ServiceCheck{Service: "kubelet", CheckIfActive: false},
10501050
PortOpenCheck{port: ports.KubeletPort})
10511051
return checks
@@ -1062,7 +1062,7 @@ func RunRootCheckOnly(ignorePreflightErrors sets.String) error {
10621062

10631063
// RunPullImagesCheck will pull images kubeadm needs if they are not found on the system
10641064
func RunPullImagesCheck(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.String) error {
1065-
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), cfg.GetCRISocket())
1065+
containerRuntime, err := utilruntime.NewContainerRuntime(utilsexec.New(), cfg.NodeRegistration.CRISocket)
10661066
if err != nil {
10671067
return err
10681068
}

0 commit comments

Comments
 (0)