Skip to content

Internalize github.com/docker/machine/libmachine#21647

Merged
medyagh merged 6 commits intokubernetes:masterfrom
afbjorklund:internal-machine
Jan 8, 2026
Merged

Internalize github.com/docker/machine/libmachine#21647
medyagh merged 6 commits intokubernetes:masterfrom
afbjorklund:internal-machine

Conversation

@afbjorklund
Copy link
Copy Markdown
Collaborator

@afbjorklund afbjorklund commented Sep 28, 2025

The libmachine API is not public anymore, it is minikube private.

To make things easier, move from minikube-machine to minikube:

Skip the host version v2-v3 migration code and os provisioners.
Also skip all the version handling, for downloading boot2docker.

Only copy the hyperv and virtualbox drivers actually being used.

This PR goes well with dropping hyperkit and internalizing kvm:


Issue #21619

Previous #21637

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 28, 2025
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: afbjorklund
Once this PR has been reviewed and has the lgtm label, please assign comradeprogrammer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 28, 2025
@afbjorklund afbjorklund force-pushed the internal-machine branch 2 times, most recently from 6ae4e88 to 130c636 Compare September 28, 2025 16:02
@afbjorklund afbjorklund requested a review from nirs September 28, 2025 16:26
Copy link
Copy Markdown
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

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

@afbjorklund are we leaving out the vmware and parellles drivers ? if yes, could we import them too ?

@afbjorklund
Copy link
Copy Markdown
Collaborator Author

afbjorklund commented Sep 30, 2025

are we leaving out the vmware and parellles drivers ?

In this PR, they are included (with their original LICENSE)

But in order to test them, you would probably need to get some CI licenses from the vendor?

Only the machine drivers are included, not the actual hypervisor and their control programs...

@medyagh
Copy link
Copy Markdown
Member

medyagh commented Oct 1, 2025

@afbjorklund we would need to fix the licenses, maybe we can slap our own boilerplate on the top of the file ? could a file have two linceses ?

@afbjorklund

This comment was marked as resolved.

@afbjorklund
Copy link
Copy Markdown
Collaborator Author

afbjorklund commented Oct 1, 2025

https://opensource.stackexchange.com/questions/7384/proper-way-of-migrating-mit-licensed-code-to-apache-2-0-license

When the project is under both the MIT and Apache license, then it is sufficient to call your project Apache 2 licensed: the terms of the Apache license are a superset of the MIT license terms. However, you still have to keep any existing MIT license notices intact.

Copyright (c) 2015-2020 Parallels IP Holdings GmbH.

Same for the Apache license notices:

Copyright 2017 VMware, Inc. All rights reserved.
Copyright 2014 Docker, Inc.

@afbjorklund afbjorklund force-pushed the internal-machine branch 2 times, most recently from 601d6d1 to 3eafd42 Compare October 1, 2025 20:35
@medyagh
Copy link
Copy Markdown
Member

medyagh commented Oct 15, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Oct 15, 2025
@medyagh
Copy link
Copy Markdown
Member

medyagh commented Oct 16, 2025

/ok-to-test

@medyagh
Copy link
Copy Markdown
Member

medyagh commented Oct 16, 2025

@afbjorklund the cross build fails, I think we might need to remove building the kvm drivers from the cross build script

14:42:06 Digest: sha256:a0655d9b3aea65de70e5391abe468634da3c7d32a234902661eff6fce7bbd669
14:43:33 Status: Downloaded newer image for quay.io/nirsof/xcgo:jammy-v2
14:43:33 GOOS=darwin CGO_ENABLED=1 go build \
14:43:33 	-ldflags="-X k8s.io/minikube/pkg/drivers/hyperkit.version=v1.37.0 -X k8s.io/minikube/pkg/drivers/hyperkit.gitCommitID="97234082a2b717645e4c65b81176aa798a9226b4""   \
14:43:43 	-o out/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit
14:43:43 chmod +X out/docker-machine-driver-kvm2-amd64
14:43:43 chmod +X out/docker-machine-driver-kvm2-amd64
14:43:43 cp out/docker-machine-driver-kvm2-amd64 out/docker-machine-driver-kvm2
14:43:43 cp -r installers/linux/deb/kvm2_deb_template out/docker-machine-driver-kvm2_1.37.0
14:43:43 chmod 0755 out/docker-machine-driver-kvm2_1.37.0/DEBIAN
14:43:43 sed -E -i -e 's/--VERSION--/1.37.0/g' out/docker-machine-driver-kvm2_1.37.0/DEBIAN/control
14:43:43 sed -E -i -e 's/--ARCH--/'amd64'/g' out/docker-machine-driver-kvm2_1.37.0/DEBIAN/control
14:43:43 mkdir -p out/docker-machine-driver-kvm2_1.37.0/usr/bin
14:43:43 cp out/docker-machine-driver-kvm2-amd64 out/docker-machine-driver-kvm2_1.37.0/usr/bin/docker-machine-driver-kvm2
14:43:43 fakeroot dpkg-deb --build out/docker-machine-driver-kvm2_1.37.0 out/docker-machine-driver-kvm2_1.37.0-0_amd64.deb
14:43:43 dpkg-deb: building package 'docker-machine-driver-kvm2' in 'out/docker-machine-driver-kvm2_1.37.0-0_amd64.deb'.
14:43:43 rm -rf out/docker-machine-driver-kvm2_1.37.0
14:43:43 cp out/docker-machine-driver-kvm2_1.37.0-0_amd64.deb out/docker-machine-driver-kvm2_1.37.0.deb
14:43:43 make: 'out/docker-machine-driver-kvm2_1.37.0-0_amd64.deb' is up to date.
14:43:45 # k8s.io/minikube/pkg/libmachine/shell
14:43:45 pkg/libmachine/shell/shell_windows.go:68:6: Detect redeclared in this block
14:43:45 	pkg/libmachine/shell/shell.go:33:6: other declaration of Detect
14:43:46 make: *** [Makefile:280: out/minikube-windows-amd64] Error 1
14:43:46 make: *** [Makefile:277: out/minikube-windows-amd64] Error 2
14:43:46 make: *** Waiting for unfinished jobs....
14:43:46 + failed=2
14:43:46 +++ go env GOOS
14:43:48 +++ go env GOARCH
14:43:48 ++ out/minikube-linux-amd64 version
14:43:48 + BUILT_VERSION='minikube version: v1.37.0
14:43:48 commit: 97234082a2b717645e4c65b81176aa798a9226b4'
14:43:49 + echo minikube version: v1.37.0 commit: 97234082a2b717645e4c65b81176aa798a9226b4
14:43:49 minikube version: v1.37.0 commit: 97234082a2b717645e4c65b81176aa798a9226b4
14:43:49 ++ echo minikube version: v1.37.0 commit: 97234082a2b717645e4c65b81176aa798a9226b4
14:43:49 ++ grep commit:
++ awk '{print $2}'
+ COMMIT=version:

Copy link
Copy Markdown
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

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

@afbjorklund the script that jenkins fails on is
hack/jenkins/minikube_cross_build_and_upload.sh

I think we will need to remove these lines

out/docker-machine-driver-kvm2_$(make deb_version_base).deb \

@afbjorklund
Copy link
Copy Markdown
Collaborator Author

afbjorklund commented Oct 17, 2025

I think we will need to remove these lines

out/docker-machine-driver-kvm2_$(make deb_version_base).deb

Why, they are for a different build step?

make: 'out/docker-machine-driver-kvm2_1.37.0-0_amd64.deb' is up to date.

I can't repeat the failure locally, normally.

GOOS="windows" GOARCH="amd64" go build -tags "" -a ./pkg/libmachine/shell/...

The only way is by provoking the compiler:

$ GOOS="windows" GOARCH="amd64" go build -tags "" -a ./pkg/libmachine/shell/*.go
# command-line-arguments
pkg/libmachine/shell/shell_windows.go:52:6: Detect redeclared in this block
	pkg/libmachine/shell/shell.go:17:6: other declaration of Detect

Since "shell.go" is supposed to be ignored:

// +build !windows

package shell
GOOS="windows" GOARCH="amd64"  \
go build -tags "" -ldflags="-X k8s.io/minikube/pkg/version.version=v1.37.0 -X k8s.io/minikube/pkg/version.isoVersion=v1.37.0-1760609724-21757 -X k8s.io/minikube/pkg/version.gitCommitID="75d6e112bff2fff720b9eff8eb12aff9a42ec072" -X k8s.io/minikube/pkg/version.storageProvisionerVersion=v5" -a -o out/minikube-windows-amd64 k8s.io/minikube/cmd/minikube

@afbjorklund
Copy link
Copy Markdown
Collaborator Author

afbjorklund commented Oct 17, 2025

Ah, it was the "boilerplate" copyright script that broke it - by adding itself before the +build line.

PASS 130c636
FAIL 3eafd42

Apparently the script only handles the new-style go:build, but not the old-style +build used here.

--- a/pkg/libmachine/shell/shell.go
+++ b/pkg/libmachine/shell/shell.go
@@ -1,3 +1,5 @@
+//go:build !windows
+
 /*
 Copyright 2022 The Kubernetes Authors All rights reserved.
 
@@ -14,8 +16,6 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-// +build !windows
-
 package shell
 
 import (

I fixed the other places, but didn't test windows.

@minikube-pr-bot

This comment has been minimized.

@minikube-pr-bot

This comment has been minimized.

@medyagh
Copy link
Copy Markdown
Member

medyagh commented Oct 17, 2025

@afbjorklund
Copy link
Copy Markdown
Collaborator Author

afbjorklund commented Oct 18, 2025

Something is wrong with the existing state:

host status: load: driver "" does not exist

Possibly related to the old config migration.

@@ -117,12 +133,7 @@ func (s Filestore) loadConfig(h *host.Ho
        // struct in the migration.
        name := h.Name
 
-       migratedHost, migrationPerformed, err := host.MigrateHost(h, data)
-       if err != nil {
-               return fmt.Errorf("Error getting migrated host: %s", err)
-       }
-
-       *h = *migratedHost
+       migrationPerformed := false
 
        h.Name = name
 

@afbjorklund
Copy link
Copy Markdown
Collaborator Author

afbjorklund commented Oct 31, 2025

Maybe take a look at the updated libmachine, and include that?

@medyagh
Copy link
Copy Markdown
Member

medyagh commented Nov 4, 2025

@afbjorklund merged that one, this would we could merge once rebased

@afbjorklund
Copy link
Copy Markdown
Collaborator Author

More cleanup, removing the unused "crashreport" directory:

@afbjorklund

This comment was marked as resolved.

@afbjorklund afbjorklund changed the title Internalize vendor/github.com/docker/machine Internalize vendor/github.com/docker/machine/libmachine Nov 22, 2025
@afbjorklund afbjorklund changed the title Internalize vendor/github.com/docker/machine/libmachine Internalize github.com/docker/machine/libmachine Nov 22, 2025
@afbjorklund afbjorklund marked this pull request as draft December 7, 2025 09:48
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 7, 2025
@afbjorklund
Copy link
Copy Markdown
Collaborator Author

afbjorklund commented Jan 7, 2026

@afbjorklund afbjorklund self-assigned this Jan 7, 2026
Only add libmachine directory, without examples.

Don't include docker-machine commands or version.
Change the github.com/docker/machine/libmachine API
to internal package k8s.io/minikube/pkg/libmachine.

It is no longer available for any external drivers,
all drivers are now internal and builtin to minikube.
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 8, 2026
@afbjorklund afbjorklund marked this pull request as ready for review January 8, 2026 16:39
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 8, 2026
@afbjorklund
Copy link
Copy Markdown
Collaborator Author

afbjorklund commented Jan 8, 2026

Split the copying, the boilerplate and the gofmt into separate commits so that they can be ignored while reviewing.

The only code change here is in 46066f1, to stop using "mcndirs" and "version". And removing virtualbox example.

commands/
└── mcndirs
    ├── utils.go
    └── utils_test.go
version/
└── version.go
libmachine/examples/
└── main.go

When compared with https://github.com/minikube-machine/machine (the drivers had already been copied earlier)

@afbjorklund afbjorklund removed their assignment Jan 8, 2026
@medyagh
Copy link
Copy Markdown
Member

medyagh commented Jan 8, 2026

/ok-to-test

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@afbjorklund: The following tests 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 f5f0858 link true /test pull-minikube-integration
integration-kvm-crio-linux-x86-64 f5f0858 link true /test integration-kvm-crio-linux-x86-64
integration-none-docker-linux-x86-64 f5f0858 link true /test integration-none-docker-linux-x86-64
integration-docker-crio-linux-x86-64 f5f0858 link true /test integration-docker-crio-linux-x86-64
integration-kvm-containerd-linux-x86-64 f5f0858 link true /test integration-kvm-containerd-linux-x86-64
integration-kvm-docker-linux-x86-64 f5f0858 link true /test integration-kvm-docker-linux-x86-64
integration-docker-docker-linux-x86-64 f5f0858 link true /test integration-docker-docker-linux-x86-64
integration-docker-containerd-linux-x86-64 f5f0858 link true /test integration-docker-containerd-linux-x86-64
integration-docker-docker-linux-arm64 f5f0858 link true /test integration-docker-docker-linux-arm64
integration-vfkit-docker-macos-arm efe7659 link false /test integration-vfkit-docker-macos-arm
integration-docker-crio-linux-x86 efe7659 link false /test integration-docker-crio-linux-x86
integration-kvm-containerd-linux-x86 efe7659 link true /test integration-kvm-containerd-linux-x86
integration-kvm-crio-linux-x86 efe7659 link false /test integration-kvm-crio-linux-x86

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.

Details

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.

@medyagh medyagh merged commit a836fb0 into kubernetes:master Jan 8, 2026
35 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants