-
Notifications
You must be signed in to change notification settings - Fork 39.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove user privilege checks from preflight tests #128799
base: master
Are you sure you want to change the base?
Remove user privilege checks from preflight tests #128799
Conversation
cmd/kubeadm/app/preflight/checks.go
Outdated
manifestsDir := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.ManifestsSubDirName) | ||
checks := []Checker{ | ||
IsPrivilegedUserCheck{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be added only when this condition is true
if !isSecondaryControlPlane {
just create the checks variable earlier:
var checks []Checker
and keep the condition.
later checks must be appended.
thanks for the PR, i've added one comment. |
296a92c
to
c3060ac
Compare
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, running e2e on this PR here:
https://github.com/neolit123/kubeadm-test/actions/runs/11853015645
will also test locally as it's a behavior change.
we might still consider the idea to calling RunRootCheckOnly before Init|Join checks are called and exiting early.
before this change kubeadm exits fast on init/join when the user is not root
with this change it runs some more checks before exiting with an error:
do you think we should preserve exactly the old behavior by calling the root check before any init/join checks? |
+1 for this change. A consistent behavior makes sense. BTW, if we can show the |
maybe the best to do that is to run this check with RunRootCheckOnly first, like it was before this PR. like in upgrade
i'm +0 on this one, we could log a ticket about it. |
I shall revert the changes in |
you can do the following:
|
c3060ac
to
93ca85b
Compare
cmd/kubeadm/app/preflight/checks.go
Outdated
if err := RunRootCheckOnly(ignorePreflightErrors); err != nil { | ||
return err | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of calling the root check inside the runinit|joinnodechecks we should call RunRootCheckOnly in these places:
grep -E 'RunJoinNodeChecks|RunInitNodeChecks' * -rnI | grep -v chec
ks.go
app/cmd/phases/join/preflight.go:94: if err := preflight.RunJoinNodeChecks(utilsexec.New(), j.Cfg(), j.IgnorePreflightErrors()); err != nil {
app/cmd/phases/join/preflight.go:123: if err := preflight.RunInitNodeChecks(utilsexec.New(), initCfg, j.IgnorePreflightErrors(), true, hasCertificateKey); err != nil {
app/cmd/phases/init/preflight.go:65: if err := preflight.RunInitNodeChecks(utilsexec.New(), data.Cfg(), data.IgnorePreflightErrors(), false, false); err != nil {
before the run init/join checks are called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the flag isSecondaryControlPlane should be removed from RunInitNodeChecks
actually
app/cmd/phases/join/preflight.go:123 - should not call RunRootCheck
app/cmd/phases/init/preflight.go:65 - should call RunRootCheck
this is confirmed by the flag values which are passed ( isSecondaryControlPlane)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I called in the sub-functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the way you did it is also OK, but i think we should be more explicit about the runned root checks, similarly to how kubeadm upgrade and reset does it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. It seems it is not required for
app/cmd/phases/join/preflight.go:123: if err := preflight.RunInitNodeChecks(utilsexec.New(), initCfg, j.IgnorePreflightErrors(), true, hasCertificateKey); err != nil {
as isSecondaryControlPlane
is true
here.
93ca85b
to
9d0361a
Compare
cmd/kubeadm/app/preflight/checks.go
Outdated
@@ -933,7 +926,6 @@ func InitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfiguratio | |||
FileAvailableCheck{Path: kubeadmconstants.GetStaticPodFilepath(kubeadmconstants.Etcd, manifestsDir)}, | |||
HTTPProxyCheck{Proto: "https", Host: cfg.LocalAPIEndpoint.AdvertiseAddress}, | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't remove line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
just one more minor line nit.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: neolit123, srivastav-abhishek The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
9d0361a
to
179fa16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is passing
https://github.com/neolit123/kubeadm-test/actions/runs/11853015645
/lgtm
we are in code freeze for 1.32 so this will automatically merge after CF is lifted.
LGTM label has been added. Git tree hash: c739bf0fc621486c89ec9ea1176e4d8a76129358
|
thanks for the PR @srivastav-abhishek |
/retest |
/lgtm |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR removes user-privilege checks for some preflight tests to make sure UT behaviour is consistent and shouldn't get skipped for non-root users.
Which issue(s) this PR fixes:
Fixes kubernetes/kubeadm#3124
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: