Skip to content
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

WIP: Initial hyperkit driver implementation. #1776

Merged
merged 5 commits into from
Aug 24, 2017
Merged

Conversation

dlorenc
Copy link
Contributor

@dlorenc dlorenc commented Aug 1, 2017

REf #1543
cc @zchee

This is an implementation of a hyperkit driver, in-tree. It still runs as a separate executable/process that needs to be installed on your path somewhere as 'docker-machine-driver-hyperkit' because it needs setuid permissions.

It uses the native hyperkit.go wrapper and vmnet for networking.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 1, 2017
@zchee
Copy link
Contributor

zchee commented Aug 2, 2017

@dlorenc SGTM. Thanks for port of my code :)

@zchee
Copy link
Contributor

zchee commented Aug 2, 2017

@dlorenc But FYI, zchee/go-vmnet is unstable. If you don't mind, it might be better to copy all file to minikube.

@dlorenc
Copy link
Contributor Author

dlorenc commented Aug 2, 2017

@dlorenc But FYI, zchee/go-vmnet is unstable. If you don't mind, it might be better to copy all file to minikube.

Thanks, I'll definitely vendor it in.

@dlorenc dlorenc force-pushed the hyperkit branch 12 times, most recently from 2ac1dd6 to f197143 Compare August 15, 2017 17:07
@dlorenc
Copy link
Contributor Author

dlorenc commented Aug 15, 2017

@minikube-bot test this please

@dlorenc dlorenc force-pushed the hyperkit branch 2 times, most recently from e1d5207 to e60bf66 Compare August 15, 2017 23:46
@codecov-io
Copy link

codecov-io commented Aug 16, 2017

Codecov Report

Merging #1776 into master will increase coverage by 0.2%.
The diff coverage is 39.13%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #1776     +/-   ##
=========================================
+ Coverage   32.73%   32.94%   +0.2%     
=========================================
  Files          66       69      +3     
  Lines        4112     4250    +138     
=========================================
+ Hits         1346     1400     +54     
- Misses       2571     2650     +79     
- Partials      195      200      +5
Impacted Files Coverage Δ
pkg/minikube/cluster/cluster.go 43.04% <0%> (-0.2%) ⬇️
pkg/minikube/cluster/cluster_non_darwin_panic.go 0% <0%> (ø) ⬆️
pkg/minikube/drivers/hyperkit/iso.go 0% <0%> (ø)
pkg/minikube/drivers/hyperkit/disk.go 29.03% <29.03%> (ø)
pkg/minikube/drivers/hyperkit/network.go 77.58% <77.58%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88fef61...a05a4fe. Read the comment docs.

@dlorenc
Copy link
Contributor Author

dlorenc commented Aug 21, 2017

@minikube-bot test this please

@zhaytee
Copy link

zhaytee commented Aug 22, 2017

Eagerly anticipating this! Thanks for your work, @dlorenc and @zchee.
I'm probably jumping the gun by trying to get it running already, but: I built minikube from your hyperkit fork/branch, @dlorenc, and built (and installed) "docker-machine-driver-hyperkit". Then I tried creating a fresh minikube cluster. It seemed to be working, at first: I saw a "hyperkit" process in Activity Monitor taking up some CPU time, but then minikube timed out with an ssh error. Looks like it wasn't able to ssh into the new cluster hosted by hyperkit:

$ minikube start --vm-driver hyperkit
Starting local Kubernetes v1.7.4 cluster...
Starting VM...
E0821 23:34:31.145147   10338 start.go:132] Error starting host: Temporary Error: Error configuring auth on host: Too many retries waiting for SSH to be available.  Last error: Maximum number of retries (60) exceeded.

Should I just be patient and wait for this to make it in for real, or is there a small tweak I can make to make it work now? 😁

@dlorenc
Copy link
Contributor Author

dlorenc commented Aug 22, 2017

I'm probably jumping the gun by trying to get it running already, but: I built minikube from your hyperkit fork/branch, @dlorenc, and built (and installed) "docker-machine-driver-hyperkit". Then I tried creating a fresh minikube cluster. It seemed to be working, at first: I saw a "hyperkit" process in Activity Monitor taking up some CPU time, but then minikube timed out with an ssh error. Looks like it wasn't able to ssh into the new cluster hosted by hyperkit:

Could you open an issue and attach the logs of minikube start --v=10 --vm-driver=hyperkit ?

@dlorenc
Copy link
Contributor Author

dlorenc commented Aug 22, 2017

@r2d4 this should be ready for a review.

Copy link
Contributor

@r2d4 r2d4 left a comment

Choose a reason for hiding this comment

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

Looks awesome. Just a few comments.

Makefile Outdated
@@ -207,6 +207,19 @@ out/minikube-installer.exe: out/minikube-windows-amd64.exe
mv out/windows_tmp/minikube-installer.exe out/minikube-installer.exe
rm -rf out/windows_tmp

out/docker-machine-driver-hyperkit:
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a

HYPERKIT_FILES := $(shell go list  -f '{{join .Deps "\n"}}' k8s.io/minikube/cmd/drivers/hyperkit | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}')

and make this rule depend on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/e2e-${OS_ARCH} out/
gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/busybox.yaml testdata/
gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/pvc.yaml testdata/
gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/busybox-mount-test.yaml testdata/

# Add the out/ directory to the PATH, for using new drivers.
export PATH=$PATH:"$(pwd)/out/"
Copy link
Contributor

Choose a reason for hiding this comment

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

I would reverse the order of these two, so $(pwd)/out/ always takes precedence.

export PATH="$(pwd)/out/":$PATH

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
file.Close()

if err := os.Truncate(diskPath, int64(diskSize*1048576)); 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.

diskSize * 10^6 instead of diskSize * 2^20. This code will give you diskSize * MiB instead of disksize * MB

I tried this out with

package main

import "os"

func main() {
	os.Create("./test")
	os.Truncate("./test", 1*1048576)
}
$ ls -l --block-size=KB
total 5kB
-rw-r----- 1 mrick eng    1kB Aug 22 13:16 main.go
-rw-r----- 1 mrick eng 1049kB Aug 22 13:16 test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

"github.com/docker/machine/libmachine/mcnutils"
)

func createDiskImage(sshKeyPath, diskPath string, diskSize int) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a comment that says diskSize is in MB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

diskPath := filepath.Join(tmpdir, "disk")

sizeInMb := 100
sizeInBytes := int64(sizeInMb) * 1048576
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here


func findFile(r *iso9660.Reader, path string) (os.FileInfo, error) {
for f, err := r.Next(); err != io.EOF; f, err = r.Next() {
// Some files get an extra ',' at the end.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain this function a little more?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

lease=0x597e1267
}`)

func Test_getIpAddressFromFile(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You might want to add a test with multiple entries with the same name but different MACs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a third entry. The code looks by MAC, so I can't really add a test for that case since name isn't part of the API at all.

@r2d4
Copy link
Contributor

r2d4 commented Aug 23, 2017

@minikube-bot retest this please

Copy link
Contributor

@r2d4 r2d4 left a comment

Choose a reason for hiding this comment

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

LGTM. Excited to use this.

@r2d4
Copy link
Contributor

r2d4 commented Aug 23, 2017

This looks fine - since its working properly, but worth it to note in the build logs:

# k8s.io/minikube/vendor/github.com/zchee/go-vmnet
ld: warning: object file (/tmp/go-build684517637/k8s.io/minikube/vendor/github.com/zchee/go-vmnet/_obj/_cgo_export.o) was built for newer OSX version (10.10) than being linked (10.6)
ld: warning: object file (/tmp/go-build684517637/k8s.io/minikube/vendor/github.com/zchee/go-vmnet/_obj/vmnet.cgo2.o) was built for newer OSX version (10.10) than being linked (10.6)
ld: warning: object file (/tmp/go-build684517637/k8s.io/minikube/vendor/github.com/zchee/go-vmnet/_obj/_cgo_main.o) was built for newer OSX version (10.10) than being linked (10.6)
# k8s.io/minikube/vendor/github.com/zchee/go-vmnet
ld: warning: object file (/tmp/go-build684517637/k8s.io/minikube/vendor/github.com/zchee/go-vmnet/_obj/_cgo_export.o) was built for newer OSX version (10.10) than being linked (10.6)
ld: warning: object file (/tmp/go-build684517637/k8s.io/minikube/vendor/github.com/zchee/go-vmnet/_obj/vmnet.cgo2.o) was built for newer OSX version (10.10) than being linked (10.6)

gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/e2e-${OS_ARCH} out/
gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/busybox.yaml testdata/
gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/pvc.yaml testdata/
gsutil cp gs://minikube-builds/${MINIKUBE_LOCATION}/testdata/busybox-mount-test.yaml testdata/

# Add the out/ directory to the PATH, for using new drivers.
export "$(pwd)/out/":PATH=$PATH
Copy link
Contributor

Choose a reason for hiding this comment

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

export PATH="$(pwd)/out/":$PATH

Copy link
Contributor

Choose a reason for hiding this comment

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

++ export /home/jenkins/workspace/Linux_Integration_Tests_KVM/out/:PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/go/bin:/home/jenkins/go/bin:/usr/local/bin:/usr/local/go/bin:/home/jenkins/google-cloud-sdk/bin:/usr/local/bin:/usr/local/go/bin:/home/jenkins/google-cloud-sdk/bin
common.sh: line 37: export: `/home/jenkins/workspace/Linux_Integration_Tests_KVM/out/:PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/go/bin:/home/jenkins/go/bin:/usr/local/bin:/usr/local/go/bin:/home/jenkins/google-cloud-sdk/bin:/usr/local/bin:/usr/local/go/bin:/home/jenkins/google-cloud-sdk/bin': not a valid identifier
Build step 'Execute shell' marked build as failure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

facepalm

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants