mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #128799 from srivastav-abhishek/fix-preflight-tests
Remove user privilege checks from preflight tests
This commit is contained in:
		@@ -62,6 +62,10 @@ func runPreflight(c workflow.RunData) error {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fmt.Println("[preflight] Running pre-flight checks")
 | 
						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 {
 | 
						if err := preflight.RunInitNodeChecks(utilsexec.New(), data.Cfg(), data.IgnorePreflightErrors(), false, false); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,6 +91,10 @@ func runPreflight(c workflow.RunData) error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// Start with general checks
 | 
						// Start with general checks
 | 
				
			||||||
	klog.V(1).Infoln("[preflight] Running 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 {
 | 
						if err := preflight.RunJoinNodeChecks(utilsexec.New(), j.Cfg(), j.IgnorePreflightErrors()); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -909,13 +909,6 @@ func (MemCheck) Name() string {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// InitNodeChecks returns checks specific to "kubeadm init"
 | 
					// 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) {
 | 
					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)
 | 
						manifestsDir := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.ManifestsSubDirName)
 | 
				
			||||||
	checks := []Checker{
 | 
						checks := []Checker{
 | 
				
			||||||
		NumCPUCheck{NumCPU: kubeadmconstants.ControlPlaneNumCPU},
 | 
							NumCPUCheck{NumCPU: kubeadmconstants.ControlPlaneNumCPU},
 | 
				
			||||||
@@ -1030,11 +1023,6 @@ func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigura
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// JoinNodeChecks returns checks specific to "kubeadm join"
 | 
					// JoinNodeChecks returns checks specific to "kubeadm join"
 | 
				
			||||||
func JoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.JoinConfiguration, ignorePreflightErrors sets.Set[string]) ([]Checker, error) {
 | 
					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{
 | 
						checks := []Checker{
 | 
				
			||||||
		FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletKubeConfigFileName)},
 | 
							FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletKubeConfigFileName)},
 | 
				
			||||||
		FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletBootstrapKubeConfigFileName)},
 | 
							FileAvailableCheck{Path: filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.KubeletBootstrapKubeConfigFileName)},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -902,11 +902,6 @@ func TestInitIPCheck(t *testing.T) {
 | 
				
			|||||||
	if runtime.GOOS != "linux" {
 | 
						if runtime.GOOS != "linux" {
 | 
				
			||||||
		t.Skip("unsupported OS")
 | 
							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()
 | 
						internalcfg, err := configutil.DefaultedStaticInitConfiguration()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Fatalf("unexpected failure when defaulting InitConfiguration: %v", err)
 | 
							t.Fatalf("unexpected failure when defaulting InitConfiguration: %v", err)
 | 
				
			||||||
@@ -969,11 +964,6 @@ func TestJoinIPCheck(t *testing.T) {
 | 
				
			|||||||
	if runtime.GOOS != "linux" {
 | 
						if runtime.GOOS != "linux" {
 | 
				
			||||||
		t.Skip("unsupported OS")
 | 
							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{
 | 
						opts := configutil.LoadOrDefaultConfigurationOptions{
 | 
				
			||||||
		SkipCRIDetect: true,
 | 
							SkipCRIDetect: true,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user