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

Remove all minikube dependencies from drivers #4933

Merged
merged 16 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ 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: pkg/minikube/translate/translations.go
out/docker-machine-driver-hyperkit:
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
$(call DOCKER,$(HYPERKIT_BUILD_IMAGE),CC=o64-clang CXX=o64-clang++ /usr/bin/make $@)
else
Expand Down Expand Up @@ -441,18 +441,18 @@ release-minikube: out/minikube checksum
gsutil cp out/minikube-$(GOOS)-$(GOARCH) $(MINIKUBE_UPLOAD_LOCATION)/$(MINIKUBE_VERSION)/minikube-$(GOOS)-$(GOARCH)
gsutil cp out/minikube-$(GOOS)-$(GOARCH).sha256 $(MINIKUBE_UPLOAD_LOCATION)/$(MINIKUBE_VERSION)/minikube-$(GOOS)-$(GOARCH).sha256

out/docker-machine-driver-kvm2: pkg/minikube/translate/translations.go
out/docker-machine-driver-kvm2:
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
docker pull $(KVM_BUILD_IMAGE) || $(MAKE) $(KVM_BUILD_IMAGE)
$(call DOCKER,$(KVM_BUILD_IMAGE),/usr/bin/make $@ COMMIT=$(COMMIT))
# make extra sure that we are linking with the older version of libvirt (1.3.1)
test "`strings $@ | grep '^LIBVIRT_[0-9]' | sort | tail -n 1`" = "LIBVIRT_1.2.9"
else
go build \
-installsuffix "static" \
-ldflags="$(KVM2_LDFLAGS)" \
-tags "libvirt.1.3.1 without_lxc" \
-o $(BUILD_DIR)/docker-machine-driver-kvm2 \
go build \
-installsuffix "static" \
-ldflags="$(KVM2_LDFLAGS)" \
-tags "libvirt.1.3.1 without_lxc" \
-o $(BUILD_DIR)/docker-machine-driver-kvm2 \
k8s.io/minikube/cmd/drivers/kvm
endif
chmod +X $@
Expand Down
29 changes: 21 additions & 8 deletions pkg/drivers/hyperkit/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ import (
hyperkit "github.com/moby/hyperkit/go"
"github.com/pkg/errors"
pkgdrivers "k8s.io/minikube/pkg/drivers"

"k8s.io/minikube/pkg/minikube/constants"
commonutil "k8s.io/minikube/pkg/util"
)

const (
Expand All @@ -52,6 +49,7 @@ const (
permErr = "%s needs to run with elevated permissions. " +
"Please run the following command, then try again: " +
"sudo chown root:wheel %s && sudo chmod u+s %s"
driverHyperkit = "hyperkit"
Copy link
Collaborator

Choose a reason for hiding this comment

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

or just use the string?

)

// Driver is the machine driver for Hyperkit
Expand All @@ -77,7 +75,6 @@ func NewDriver(hostName, storePath string) *Driver {
SSHUser: "docker",
},
CommonDriver: &pkgdrivers.CommonDriver{},
DiskSize: commonutil.CalculateSizeInMB(constants.DefaultDiskSize),
}
}

Expand Down Expand Up @@ -121,7 +118,7 @@ func (d *Driver) Create() error {

// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return constants.DriverHyperkit
return driverHyperkit
Copy link
Collaborator

Choose a reason for hiding this comment

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

"hyperkit"

}

// GetSSHHostname returns hostname for use with ssh
Expand Down Expand Up @@ -227,7 +224,7 @@ func (d *Driver) Start() error {
h.Memory = d.Memory
h.UUID = d.UUID
// This should stream logs from hyperkit, but doesn't seem to work.
logger := golog.New(os.Stderr, constants.DriverHyperkit, golog.LstdFlags)
logger := golog.New(os.Stderr, driverHyperkit, golog.LstdFlags)
h.SetLogger(logger)

if vsockPorts, err := d.extractVSockPorts(); err != nil {
Expand Down Expand Up @@ -269,12 +266,24 @@ func (d *Driver) Start() error {

d.IPAddress, err = GetIPAddressByMACAddress(mac)
if err != nil {
return &commonutil.RetriableError{Err: err}
return &TempError{err}
}
return nil
}

if err := commonutil.RetryAfter(30, getIP, 2*time.Second); err != nil {
// Implement a retry loop without calling any minikube code
for i := 0; i < 30; i++ {
err = getIP()
if err == nil {
break
}
if _, ok := err.(*tempError); !ok {
return err
}
time.Sleep(2)
}

if err != nil {
return fmt.Errorf("IP address never found in dhcp leases file %v", err)
}
log.Debugf("IP: %s", d.IPAddress)
Expand All @@ -294,6 +303,10 @@ func (d *Driver) Start() error {
return nil
}

type tempError struct {
Err error
}

//recoverFromUncleanShutdown searches for an existing hyperkit.pid file in
//the machine directory. If it can't find it, a clean shutdown is assumed.
//If it finds the pid file, it checks for a running hyperkit process with that pid
Expand Down
4 changes: 3 additions & 1 deletion pkg/drivers/hyperkit/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const (
VMNetDomain = "/Library/Preferences/SystemConfiguration/com.apple.vmnet"
// SharedNetAddrKey is the key for the network address
SharedNetAddrKey = "Shared_Net_Address"

IPErrorMessage = "could not find an IP address for %s"
)

var (
Expand Down Expand Up @@ -78,7 +80,7 @@ func getIPAddressFromFile(mac, path string) (string, error) {
return dhcpEntry.IPAddress, nil
}
}
return "", fmt.Errorf("could not find an IP address for %s", mac)
return "", fmt.Errorf(IPErrorMessage, mac)
Copy link
Collaborator

Choose a reason for hiding this comment

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

would prefer having the printf inline here

}

func parseDHCPdLeasesFile(file io.Reader) ([]DHCPEntry, error) {
Expand Down
13 changes: 2 additions & 11 deletions pkg/drivers/kvm/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ import (
"syscall"
"time"

"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/util"

"github.com/docker/machine/libmachine/drivers"
"github.com/docker/machine/libmachine/log"
"github.com/docker/machine/libmachine/state"
Expand Down Expand Up @@ -91,6 +87,7 @@ const (
qemusystem = "qemu:///system"
defaultPrivateNetworkName = "minikube-net"
defaultNetworkName = "default"
driverKvm2 = "kvm2"
Copy link
Collaborator

Choose a reason for hiding this comment

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

or just use the string ?

)

// NewDriver creates a new driver for a host
Expand All @@ -102,14 +99,8 @@ func NewDriver(hostName, storePath string) *Driver {
SSHUser: "docker",
},
CommonDriver: &pkgdrivers.CommonDriver{},
Boot2DockerURL: constants.DefaultISOURL,
CPU: constants.DefaultCPUS,
DiskSize: util.CalculateSizeInMB(constants.DefaultDiskSize),
Memory: util.CalculateSizeInMB(constants.DefaultMemorySize),
PrivateNetwork: defaultPrivateNetworkName,
Network: defaultNetworkName,
DiskPath: filepath.Join(constants.GetMinipath(), "machines", config.GetMachineName(), fmt.Sprintf("%s.rawdisk", config.GetMachineName())),
ISO: filepath.Join(constants.GetMinipath(), "machines", config.GetMachineName(), "boot2docker.iso"),
ConnectionURI: qemusystem,
}
}
Expand Down Expand Up @@ -224,7 +215,7 @@ func (d *Driver) GetSSHHostname() (string, error) {

// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return constants.DriverKvm2
return driverKvm2
Copy link
Collaborator

Choose a reason for hiding this comment

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

"kvm2"

}

// Kill stops a host forcefully, including any containers that we are managing.
Expand Down