Merge pull request #74873 from neolit123/fix-join-phase-preflight

kubeadm: add a flag to RunInitNodeChecks to indicate sec. control-plane
This commit is contained in:
Kubernetes Prow Robot 2019-03-05 08:16:50 -08:00 committed by GitHub
commit c525155b31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 21 deletions

View File

@ -57,7 +57,7 @@ func runPreflight(c workflow.RunData) error {
} }
fmt.Println("[preflight] Running pre-flight checks") fmt.Println("[preflight] Running pre-flight checks")
if err := preflight.RunInitNodeChecks(utilsexec.New(), data.Cfg(), data.IgnorePreflightErrors()); err != nil { if err := preflight.RunInitNodeChecks(utilsexec.New(), data.Cfg(), data.IgnorePreflightErrors(), false); err != nil {
return err return err
} }

View File

@ -120,7 +120,7 @@ func runPreflight(c workflow.RunData) error {
// run kubeadm init preflight checks for checking all the prequisites // run kubeadm init preflight checks for checking all the prequisites
fmt.Println("[preflight] Running pre-flight checks before initializing the new control plane instance") fmt.Println("[preflight] Running pre-flight checks before initializing the new control plane instance")
if err := preflight.RunInitNodeChecks(utilsexec.New(), initCfg, j.IgnorePreflightErrors()); err != nil { if err := preflight.RunInitNodeChecks(utilsexec.New(), initCfg, j.IgnorePreflightErrors(), true); err != nil {
return err return err
} }

View File

@ -873,11 +873,15 @@ func (ncc NumCPUCheck) Check() (warnings, errorList []error) {
} }
// RunInitNodeChecks executes all individual, applicable to control-plane node checks. // RunInitNodeChecks executes all individual, applicable to control-plane node checks.
func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.String) error { // The boolean flag 'isSecondaryControlPlane' controls whether we are running checks in a --join-control-plane scenario.
// If the flag is set to true we should skip checks already executed by RunJoinNodeChecks and RunOptionalJoinNodeChecks.
func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.String, isSecondaryControlPlane bool) error {
if !isSecondaryControlPlane {
// First, check if we're root separately from the other preflight checks and fail fast // First, check if we're root separately from the other preflight checks and fail fast
if err := RunRootCheckOnly(ignorePreflightErrors); err != nil { if err := RunRootCheckOnly(ignorePreflightErrors); err != nil {
return err return err
} }
}
manifestsDir := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.ManifestsSubDirName) manifestsDir := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.ManifestsSubDirName)
checks := []Checker{ checks := []Checker{
@ -895,15 +899,28 @@ func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigura
HTTPProxyCIDRCheck{Proto: "https", CIDR: cfg.Networking.ServiceSubnet}, HTTPProxyCIDRCheck{Proto: "https", CIDR: cfg.Networking.ServiceSubnet},
HTTPProxyCIDRCheck{Proto: "https", CIDR: cfg.Networking.PodSubnet}, HTTPProxyCIDRCheck{Proto: "https", CIDR: cfg.Networking.PodSubnet},
} }
if !isSecondaryControlPlane {
checks = addCommonChecks(execer, cfg, checks) checks = addCommonChecks(execer, cfg, checks)
// Check ipvs required kernel module once we use ipvs kube-proxy mode // Check IVPS required kernel module once we use IVPS kube-proxy mode
if cfg.ComponentConfigs.KubeProxy != nil && cfg.ComponentConfigs.KubeProxy.Mode == ipvsutil.IPVSProxyMode { if cfg.ComponentConfigs.KubeProxy != nil && cfg.ComponentConfigs.KubeProxy.Mode == ipvsutil.IPVSProxyMode {
checks = append(checks, checks = append(checks,
ipvsutil.RequiredIPVSKernelModulesAvailableCheck{Executor: execer}, ipvsutil.RequiredIPVSKernelModulesAvailableCheck{Executor: execer},
) )
} }
// Check if Bridge-netfilter and IPv6 relevant flags are set
if ip := net.ParseIP(cfg.LocalAPIEndpoint.AdvertiseAddress); ip != nil {
if ip.To4() == nil && ip.To16() != nil {
checks = append(checks,
FileContentCheck{Path: bridgenf6, Content: []byte{'1'}},
FileContentCheck{Path: ipv6DefaultForwarding, Content: []byte{'1'}},
)
}
}
}
if cfg.Etcd.Local != nil { if cfg.Etcd.Local != nil {
// Only do etcd related checks when no external endpoints were specified // Only do etcd related checks when no external endpoints were specified
checks = append(checks, checks = append(checks,
@ -927,14 +944,6 @@ func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigura
checks = append(checks, ExternalEtcdVersionCheck{Etcd: cfg.Etcd}) checks = append(checks, ExternalEtcdVersionCheck{Etcd: cfg.Etcd})
} }
if ip := net.ParseIP(cfg.LocalAPIEndpoint.AdvertiseAddress); ip != nil {
if ip.To4() == nil && ip.To16() != nil {
checks = append(checks,
FileContentCheck{Path: bridgenf6, Content: []byte{'1'}},
FileContentCheck{Path: ipv6DefaultForwarding, Content: []byte{'1'}},
)
}
}
return RunChecks(checks, os.Stderr, ignorePreflightErrors) return RunChecks(checks, os.Stderr, ignorePreflightErrors)
} }

View File

@ -232,7 +232,7 @@ func TestRunInitNodeChecks(t *testing.T) {
} }
for _, rt := range tests { for _, rt := range tests {
// TODO: Make RunInitNodeChecks accept a ClusterConfiguration object instead of InitConfiguration // TODO: Make RunInitNodeChecks accept a ClusterConfiguration object instead of InitConfiguration
actual := RunInitNodeChecks(exec.New(), rt.cfg, sets.NewString()) actual := RunInitNodeChecks(exec.New(), rt.cfg, sets.NewString(), false)
if (actual == nil) != rt.expected { if (actual == nil) != rt.expected {
t.Errorf( t.Errorf(
"failed RunInitNodeChecks:\n\texpected: %t\n\t actual: %t\n\t error: %v", "failed RunInitNodeChecks:\n\texpected: %t\n\t actual: %t\n\t error: %v",