Skip to content

Conversation

medyagh
Copy link
Member

@medyagh medyagh commented Sep 26, 2025

Based on this PR #21623

  • bootstrapper: rename func to KubeadmCmdWithPath**
  • move sudo before bash -c everywhere we invoke kubeadms to ensure gets the correct path**

nirs and others added 4 commits September 23, 2025 04:36
We want to use it to build kubeadm command in other packages.
Previously we ran:

    bash -c 'sudo env PATH="/path/to/minikube/binaries:$PATH" kubeadm init ...'

The shell expanding $PATH is running as a normal user, which does not
include /usr/sbin:

    $ out/minikube ssh -- printenv PATH
    /usr/local/bin:/usr/bin:/bin:/usr/games

This breaks kubeadm since it expects to find losetup in the PATH[1].

Now we run:

    sudo bash -c 'env PATH="/path/to/minikube/binaries:$PATH" kubeadm init ...'

The shell expanding $PATH is running as root, so it uses root PATH that
includes /usr/sbin:

    $ out/minikube ssh -- sudo printenv PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

With this change kubeadm init can find losetup in the PATH, and creating
a clusters succeeds.

More work is needed to fix other invocations of kubeadm.

[1] kubernetes/kubernetes#129450
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: medyagh

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 26, 2025
@k8s-ci-robot k8s-ci-robot requested a review from prezha September 26, 2025 19:49
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 26, 2025
@medyagh
Copy link
Member Author

medyagh commented Sep 26, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 26, 2025
@medyagh medyagh changed the title Refactor Ivoking Kubeadm command to prepare for debian 12 Refactor Invoking Kubeadm command to prepare for debian 12 Sep 26, 2025
@minikube-pr-bot

This comment has been minimized.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 26, 2025
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Sep 26, 2025

@medyagh: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-minikube-integration 14b81fa link true /test pull-minikube-integration

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21642 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 43.4s    │ 43.1s                  │
│ enable ingress │ 15.8s    │ 16.0s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube ingress: 15.8s 15.8s 15.8s 15.8s 15.9s
Times for minikube (PR 21642) ingress: 16.3s 15.8s 15.8s 15.8s 16.3s

Times for minikube start: 42.3s 43.6s 45.0s 40.9s 45.3s
Times for minikube (PR 21642) start: 44.0s 41.8s 41.8s 44.4s 43.6s

docker driver with docker runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21642 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 21.5s    │ 21.4s                  │
│ enable ingress │ 11.2s    │ 12.4s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube start: 22.8s 21.6s 21.4s 19.8s 21.8s
Times for minikube (PR 21642) start: 20.8s 21.8s 22.9s 20.9s 20.6s

Times for minikube ingress: 10.6s 10.6s 11.6s 10.6s 12.6s
Times for minikube (PR 21642) ingress: 12.6s 13.6s 12.6s 10.6s 12.6s

docker driver with containerd runtime

┌────────────────┬──────────┬────────────────────────┐
│    COMMAND     │ MINIKUBE │ MINIKUBE  ( PR 21642 ) │
├────────────────┼──────────┼────────────────────────┤
│ minikube start │ 20.7s    │ 20.0s                  │
│ enable ingress │ 26.3s    │ 26.5s                  │
└────────────────┴──────────┴────────────────────────┘

Times for minikube start: 20.9s 21.8s 21.2s 19.5s 20.1s
Times for minikube (PR 21642) start: 20.4s 20.5s 19.9s 19.2s 20.0s

Times for minikube (PR 21642) ingress: 23.1s 24.1s 23.1s 23.1s 39.1s
Times for minikube ingress: 23.1s 23.1s 39.1s 23.1s 23.1s

@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot
Copy link

Here are the number of top 10 failed tests in each environments with lowest flake rate.

Environment Test Name Flake Rate

Besides the following environments also have failed tests:

To see the flake rates of all tests by environment, click here.

}

if _, err := k.c.RunCmd(exec.Command("/bin/bash", "-c", "sudo systemctl daemon-reload && sudo systemctl enable kubelet && sudo systemctl start kubelet")); err != nil {
if _, err := k.c.RunCmd(exec.Command("sudo", "/bin/bash", "-c", "systemctl daemon-reload && systemctl enable kubelet && systemctl start kubelet")); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not needed since we don't use env PATH= in the command.

kubeadmPath := path.Join(vmpath.GuestPersistentDir, "binaries", cc.KubernetesConfig.KubernetesVersion)
bashCmd := fmt.Sprintf("sudo env PATH=\"%s:$PATH\" kubeadm certs renew all --config %s", kubeadmPath, constants.KubeadmYamlPath)
bashCmd := fmt.Sprintf("%s certs renew all --config %s", bsutil.KubeadmCmdWithPath(cc.KubernetesConfig.KubernetesVersion), constants.KubeadmYamlPath)
if _, err := cmd.RunCmd(exec.Command("/bin/bash", "-c", bashCmd)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing sudo

defer func() {
if err := f.Close(); err != nil {
klog.Warningf("error closing the file %s: %v", f.GetSourcePath(), err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The asset is opened for reading, and close error is not very interesting. But the issue was not introduced by your change.

@nirs
Copy link
Contributor

nirs commented Oct 1, 2025

@medyagh can you squash the fixup commits so we can have clean git history?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants