Merge pull request #128799 from srivastav-abhishek/fix-preflight-tests

Remove user privilege checks from preflight tests
This commit is contained in:
Kubernetes Prow Robot 2024-12-12 04:12:25 +00:00 committed by GitHub
commit 572eda0ac9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 22 deletions

View File

@ -62,6 +62,10 @@ func runPreflight(c workflow.RunData) error {
}
fmt.Println("[preflight] Running pre-flight checks")
// First, check if we're root separately from the other preflight checks and fail fast.
if err := preflight.RunRootCheckOnly(data.IgnorePreflightErrors()); err != nil {
return err
}
if err := preflight.RunInitNodeChecks(utilsexec.New(), data.Cfg(), data.IgnorePreflightErrors(), false, false); err != nil {
return err
}

View File

@ -91,6 +91,10 @@ func runPreflight(c workflow.RunData) error {
// Start with general checks
klog.V(1).Infoln("[preflight] Running general checks")
// First, check if we're root separately from the other preflight checks and fail fast.
if err := preflight.RunRootCheckOnly(j.IgnorePreflightErrors()); err != nil {
return err
}
if err := preflight.RunJoinNodeChecks(utilsexec.New(), j.Cfg(), j.IgnorePreflightErrors()); err != nil {
return err
}

View File

@ -909,13 +909,6 @@ func (MemCheck) Name() string {
// InitNodeChecks returns checks specific to "kubeadm init"
func InitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguration, ignorePreflightErrors sets.Set[string], isSecondaryControlPlane bool, downloadCerts bool) ([]Checker, error) {
if !isSecondaryControlPlane {
// First, check if we're root separately from the other preflight checks and fail fast
if err := RunRootCheckOnly(ignorePreflightErrors); err != nil {
return nil, err
}
}
manifestsDir := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.ManifestsSubDirName)
checks := []Checker{
NumCPUCheck{NumCPU: kubeadmconstants.ControlPlaneNumCPU},
@ -1030,11 +1023,6 @@ func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigura
// JoinNodeChecks returns checks specific to "kubeadm join"
func JoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.JoinConfiguration, ignorePreflightErrors sets.Set[string]) ([]Checker, error) {
// First, check if we're root separately from the other preflight checks and fail fast
if err := RunRootCheckOnly(ignorePreflightErrors); err != nil {
return nil, err
}
checks := []Checker{
FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletKubeConfigFileName)},
FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletBootstrapKubeConfigFileName)},

View File

@ -902,11 +902,6 @@ func TestInitIPCheck(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("unsupported OS")
}
// should be a privileged user for the `init` command, otherwise just skip it.
isPrivileged := IsPrivilegedUserCheck{}
if _, err := isPrivileged.Check(); err != nil {
t.Skip("not a privileged user")
}
internalcfg, err := configutil.DefaultedStaticInitConfiguration()
if err != nil {
t.Fatalf("unexpected failure when defaulting InitConfiguration: %v", err)
@ -969,11 +964,6 @@ func TestJoinIPCheck(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("unsupported OS")
}
// should be a privileged user for the `join` command, otherwise just skip it.
isPrivileged := IsPrivilegedUserCheck{}
if _, err := isPrivileged.Check(); err != nil {
t.Skip("not a privileged user")
}
opts := configutil.LoadOrDefaultConfigurationOptions{
SkipCRIDetect: true,