Skip to content

Commit 3e4e243

Browse files
authored
Merge pull request kubernetes#130045 from carlory/kubeadm-exec-check
kubeadm: update preflight check
2 parents bd85320 + 4facb87 commit 3e4e243

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

cmd/kubeadm/app/preflight/checks_darwin.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ limitations under the License.
1919

2020
package preflight
2121

22+
import utilsexec "k8s.io/utils/exec"
23+
2224
// This is a MacOS stub
2325

2426
// Check number of memory required by kubeadm
2527
// No-op for Darwin (MacOS).
2628
func (mc MemCheck) Check() (warnings, errorList []error) {
2729
return nil, nil
2830
}
31+
32+
// addExecChecks adds checks that verify if certain binaries are in PATH
33+
// No-op for Darwin (MacOS).
34+
func addExecChecks(checks []Checker, _ utilsexec.Interface, _ string) []Checker {
35+
return checks
36+
}

cmd/kubeadm/app/preflight/checks_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,8 @@ func addExecChecks(checks []Checker, execer utilsexec.Interface, k8sVersion stri
8888

8989
// kubelet requires mount to be present in PATH for in-tree volume plugins.
9090
checks = append(checks, InPathCheck{executable: "mount", mandatory: true, exec: execer})
91+
92+
// kubeadm requires cp to be present in PATH for copying etcd directories.
93+
checks = append(checks, InPathCheck{executable: "cp", mandatory: true, exec: execer})
9194
return checks
9295
}

cmd/kubeadm/app/preflight/checks_other.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ package preflight
2121

2222
import (
2323
system "k8s.io/system-validators/validators"
24-
utilsexec "k8s.io/utils/exec"
2524
)
2625

2726
// addOSValidator adds a new OSValidator
@@ -47,9 +46,3 @@ func addIPv4Checks(checks []Checker) []Checker {
4746
func addSwapCheck(checks []Checker) []Checker {
4847
return checks
4948
}
50-
51-
// addExecChecks adds checks that verify if certain binaries are in PATH
52-
// No-op for Darwin (MacOS), Windows.
53-
func addExecChecks(checks []Checker, _ utilsexec.Interface, _ string) []Checker {
54-
return checks
55-
}

cmd/kubeadm/app/preflight/checks_windows.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package preflight
2222
import (
2323
"github.com/pkg/errors"
2424
"golang.org/x/sys/windows"
25+
utilsexec "k8s.io/utils/exec"
2526
)
2627

2728
// Check validates if a user has elevated (administrator) privileges.
@@ -38,3 +39,10 @@ func (ipuc IsPrivilegedUserCheck) Check() (warnings, errorList []error) {
3839
func (mc MemCheck) Check() (warnings, errorList []error) {
3940
return nil, nil
4041
}
42+
43+
// addExecChecks adds checks that verify if certain binaries are in PATH.
44+
func addExecChecks(checks []Checker, execer utilsexec.Interface, _ string) []Checker {
45+
// kubeadm requires xcopy to be present in PATH for copying etcd directories.
46+
checks = append(checks, InPathCheck{executable: "xcopy", mandatory: true, exec: execer})
47+
return checks
48+
}

cmd/kubeadm/app/util/initsystem/initsystem_unix.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ func GetInitSystem() (InitSystem, error) {
160160
}
161161
_, err = exec.LookPath("openrc")
162162
if err == nil {
163+
binaries := []string{"rc-service", "rc-update"}
164+
for _, binary := range binaries {
165+
_, err = exec.LookPath(binary)
166+
if err != nil {
167+
return nil, errors.Wrapf(err, "openrc detected, but missing required binary: %s", binary)
168+
}
169+
}
163170
return &OpenRCInitSystem{}, nil
164171
}
165172

0 commit comments

Comments
 (0)