Skip to content

Commit 4da3ced

Browse files
prezhaminikube-bot
andauthored
Fix KVM driver (tests) timeouts (#20852)
* Fix KVM driver tests timeouts Rewrite KVM driver waiting logic for domain start, getting ip address and shutting domain down. Add more config/state outputs to aid future debugging. Bump go/libvirt to v1.11002.0 and set the minimum memory required for running all tests to 3GB to avoid some really weird system behaviour. * revert reduction of timelimit for TestCert tests run * set memory and debug output in TestNoKubernetes tests * extend kvm waitForStaticIP timeout * add console log to debug output * Updating ISO to v1.36.0-1748823857-20852 --------- Co-authored-by: minikube-bot <[email protected]>
1 parent 2ca8686 commit 4da3ced

34 files changed

+326
-201
lines changed

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ KIC_VERSION ?= $(shell grep -E "Version =" pkg/drivers/kic/types.go | cut -d \"
2424
HUGO_VERSION ?= $(shell grep -E "HUGO_VERSION = \"" netlify.toml | cut -d \" -f2)
2525

2626
# Default to .0 for higher cache hit rates, as build increments typically don't require new ISO versions
27-
ISO_VERSION ?= v1.36.0
27+
ISO_VERSION ?= v1.36.0-1748823857-20852
2828

2929
# Dashes are valid in semver, but not Linux packaging. Use ~ to delimit alpha/beta
3030
DEB_VERSION ?= $(subst -,~,$(RAW_VERSION))
@@ -103,7 +103,7 @@ $(shell mkdir -p $(BUILD_DIR))
103103
CURRENT_GIT_BRANCH ?= $(shell git branch | grep \* | cut -d ' ' -f2)
104104

105105
# Use system python if it exists, otherwise use Docker.
106-
PYTHON := $(shell command -v python || echo "docker run --rm -it -v $(shell pwd):/minikube:Z -w /minikube python python")
106+
PYTHON := $(shell command -v python || echo "docker run --rm -it -v $(shell pwd):/minikube -w /minikube python python")
107107
BUILD_OS := $(shell uname -s)
108108

109109
SHA512SUM=$(shell command -v sha512sum || echo "shasum -a 512")
@@ -189,7 +189,7 @@ endef
189189

190190
# $(call DOCKER, image, command)
191191
define DOCKER
192-
docker run --rm -e GOCACHE=/app/.cache -e IN_DOCKER=1 --user $(shell id -u):$(shell id -g) -w /app -v $(PWD):/app:Z -v $(GOPATH):/go --init $(1) /bin/bash -c '$(2)'
192+
docker run --rm -e GOCACHE=/app/.cache -e IN_DOCKER=1 --user $(shell id -u):$(shell id -g) -w /app -v $(PWD):/app -v $(GOPATH):/go --init $(1) /bin/bash -c '$(2)'
193193
endef
194194

195195
ifeq ($(BUILD_IN_DOCKER),y)
@@ -341,13 +341,13 @@ out/minikube-%.iso: $(shell find "deploy/iso/minikube-iso" -type f)
341341
ifeq ($(IN_DOCKER),1)
342342
$(MAKE) minikube-iso-$*
343343
else
344-
docker run --rm --workdir /mnt --volume $(CURDIR):/mnt:Z $(ISO_DOCKER_EXTRA_ARGS) \
344+
docker run --rm --workdir /mnt --volume $(CURDIR):/mnt $(ISO_DOCKER_EXTRA_ARGS) \
345345
--user $(shell id -u):$(shell id -g) --env HOME=/tmp --env IN_DOCKER=1 \
346346
$(ISO_BUILD_IMAGE) /bin/bash -lc '/usr/bin/make minikube-iso-$*'
347347
endif
348348

349349
iso_in_docker:
350-
docker run -it --rm --workdir /mnt --volume $(CURDIR):/mnt:Z $(ISO_DOCKER_EXTRA_ARGS) \
350+
docker run -it --rm --workdir /mnt --volume $(CURDIR):/mnt $(ISO_DOCKER_EXTRA_ARGS) \
351351
--user $(shell id -u):$(shell id -g) --env HOME=/tmp --env IN_DOCKER=1 \
352352
$(ISO_BUILD_IMAGE) /bin/bash
353353

@@ -523,7 +523,7 @@ out/linters/golangci-lint-$(GOLINT_VERSION):
523523
.PHONY: lint
524524
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
525525
lint:
526-
docker run --rm -v `pwd`:/app:Z -w /app golangci/golangci-lint:$(GOLINT_VERSION) \
526+
docker run --rm -v `pwd`:/app -w /app golangci/golangci-lint:$(GOLINT_VERSION) \
527527
golangci-lint run ${GOLINT_OPTIONS} ./..."
528528
# --skip-dirs "cmd/drivers/kvm|cmd/drivers/hyperkit|pkg/drivers/kvm|pkg/drivers/hyperkit"
529529
# The "--skip-dirs" parameter is no longer supported in the V2 version. If you need to skip the directory,
@@ -657,7 +657,7 @@ out/docker-machine-driver-hyperkit:
657657
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
658658
docker run --rm -e GOCACHE=/app/.cache -e IN_DOCKER=1 \
659659
--user $(shell id -u):$(shell id -g) -w /app \
660-
-v $(PWD):/app:Z -v $(GOPATH):/go:Z --init --entrypoint "" \
660+
-v $(PWD):/app -v $(GOPATH):/go --init --entrypoint "" \
661661
$(HYPERKIT_BUILD_IMAGE) /bin/bash -c 'CC=o64-clang CXX=o64-clang++ /usr/bin/make $@'
662662
else
663663
$(if $(quiet),@echo " GO $@")

cmd/minikube/cmd/start.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,8 +1098,8 @@ func suggestMemoryAllocation(sysLimit, containerLimit, nodes int) int {
10981098
return mem
10991099
}
11001100

1101-
const fallback = 2200
1102-
maximum := 6000
1101+
const fallback = 3072
1102+
maximum := 6144
11031103

11041104
if sysLimit > 0 && fallback > sysLimit {
11051105
return sysLimit

cmd/minikube/cmd/start_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,26 +277,26 @@ func TestSuggestMemoryAllocation(t *testing.T) {
277277
nodes int
278278
want int
279279
}{
280-
{"128GB sys", 128000, 0, 1, 6000},
281-
{"64GB sys", 64000, 0, 1, 6000},
282-
{"32GB sys", 32768, 0, 1, 6000},
280+
{"128GB sys", 128000, 0, 1, 6144},
281+
{"64GB sys", 64000, 0, 1, 6144},
282+
{"32GB sys", 32768, 0, 1, 6144},
283283
{"16GB sys", 16384, 0, 1, 4000},
284284
{"odd sys", 14567, 0, 1, 3600},
285-
{"4GB sys", 4096, 0, 1, 2200},
285+
{"4GB sys", 4096, 0, 1, 3072},
286286
{"2GB sys", 2048, 0, 1, 2048},
287-
{"Unable to poll sys", 0, 0, 1, 2200},
287+
{"Unable to poll sys", 0, 0, 1, 3072},
288288
{"128GB sys, 16GB container", 128000, 16384, 1, 16336},
289289
{"64GB sys, 16GB container", 64000, 16384, 1, 16000},
290290
{"16GB sys, 4GB container", 16384, 4096, 1, 4000},
291291
{"4GB sys, 3.5GB container", 16384, 3500, 1, 3452},
292292
{"16GB sys, 2GB container", 16384, 2048, 1, 2048},
293293
{"16GB sys, unable to poll container", 16384, 0, 1, 4000},
294-
{"128GB sys 2 nodes", 128000, 0, 2, 6000},
295-
{"8GB sys 3 nodes", 8192, 0, 3, 2200},
296-
{"16GB sys 2 nodes", 16384, 0, 2, 2200},
294+
{"128GB sys 2 nodes", 128000, 0, 2, 6144},
295+
{"8GB sys 3 nodes", 8192, 0, 3, 3072},
296+
{"16GB sys 2 nodes", 16384, 0, 2, 3072},
297297
{"32GB sys 2 nodes", 32768, 0, 2, 4050},
298-
{"odd sys 2 nodes", 14567, 0, 2, 2200},
299-
{"4GB sys 2 nodes", 4096, 0, 2, 2200},
298+
{"odd sys 2 nodes", 14567, 0, 2, 3072},
299+
{"4GB sys 2 nodes", 4096, 0, 2, 3072},
300300
{"2GB sys 3 nodes", 2048, 0, 3, 2048},
301301
}
302302
for _, test := range tests {

deploy/iso/minikube-iso/go.hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ sha256 36930162a93df417d90bd22c6e14daff4705baac2b02418edda671cdfa9cd07f go1.23
3535
sha256 8d6a77332487557c6afa2421131b50f83db4ae3c579c3bc72e670ee1f6968599 go1.23.3.src.tar.gz
3636
sha256 ad345ac421e90814293a9699cca19dd5238251c3f687980bbcae28495b263531 go1.23.4.src.tar.gz
3737
sha256 d14120614acb29d12bcab72bd689f257eb4be9e0b6f88a8fb7e41ac65f8556e5 go1.24.0.src.tar.gz
38-
sha256 6924efde5de86fe277676e929dc9917d466efa02fb934197bc2eba35d5680971 go1.23.4.linux-amd64.tar.gz
38+
sha256 6924efde5de86fe277676e929dc9917d466efa02fb934197bc2eba35d5680971 go1.23.4.linux-amd64.tar.gz

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ require (
8787
k8s.io/klog/v2 v2.130.1
8888
k8s.io/kubectl v0.32.2
8989
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
90-
libvirt.org/go/libvirt v1.11001.0
90+
libvirt.org/go/libvirt v1.11002.0
9191
sigs.k8s.io/sig-storage-lib-external-provisioner/v6 v6.3.0
9292
)
9393

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,8 +3219,8 @@ k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
32193219
k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
32203220
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro=
32213221
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
3222-
libvirt.org/go/libvirt v1.11001.0 h1:QJgpslxY7qkpXZIDxdMHpkDl7FfhgQJwqRTGBbg/S8E=
3223-
libvirt.org/go/libvirt v1.11001.0/go.mod h1:1WiFE8EjZfq+FCVog+rvr1yatKbKZ9FaFMZgEqxEJqQ=
3222+
libvirt.org/go/libvirt v1.11002.0 h1:cb8KJG3D97pc/hxQ2n6P82hRX3rlgdzO7bih6W1AAQ8=
3223+
libvirt.org/go/libvirt v1.11002.0/go.mod h1:1WiFE8EjZfq+FCVog+rvr1yatKbKZ9FaFMZgEqxEJqQ=
32243224
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
32253225
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
32263226
modernc.org/cc/v3 v3.36.0/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=

hack/metrics/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func getLabels(containerRuntime string) *stackdriver.Labels {
145145
func minikubeStartTime(ctx context.Context, projectID, minikubePath, containerRuntime string) (float64, error) {
146146
defer deleteMinikube(ctx, minikubePath)
147147

148-
cmd := exec.CommandContext(ctx, minikubePath, "start", "--driver=docker", "-p", profile, "--memory=2048", "--trace=gcp", fmt.Sprintf("--container-runtime=%s", containerRuntime))
148+
cmd := exec.CommandContext(ctx, minikubePath, "start", "--driver=docker", "-p", profile, "--memory=3072", "--trace=gcp", fmt.Sprintf("--container-runtime=%s", containerRuntime))
149149
cmd.Env = append(os.Environ(), fmt.Sprintf("%s=%s", pkgtrace.ProjectEnvVar, projectID))
150150
cmd.Stdout = os.Stderr
151151
cmd.Stderr = os.Stderr

pkg/drivers/kvm/domain.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ import (
3131
func (d *Driver) getDomain() (*libvirt.Domain, *libvirt.Connect, error) {
3232
conn, err := getConnection(d.ConnectionURI)
3333
if err != nil {
34-
return nil, nil, errors.Wrap(err, "getting libvirt connection")
34+
return nil, nil, fmt.Errorf("failed opening libvirt connection: %w", err)
3535
}
3636

3737
dom, err := conn.LookupDomainByName(d.MachineName)
3838
if err != nil {
39-
return nil, nil, errors.Wrap(err, "looking up domain")
39+
return nil, nil, fmt.Errorf("failed looking up domain: %w", lvErr(err))
4040
}
4141

4242
return dom, conn, nil
@@ -45,13 +45,17 @@ func (d *Driver) getDomain() (*libvirt.Domain, *libvirt.Connect, error) {
4545
func getConnection(connectionURI string) (*libvirt.Connect, error) {
4646
conn, err := libvirt.NewConnect(connectionURI)
4747
if err != nil {
48-
return nil, errors.Wrap(err, "connecting to libvirt socket")
48+
return nil, fmt.Errorf("failed connecting to libvirt socket: %w", lvErr(err))
4949
}
5050

5151
return conn, nil
5252
}
5353

5454
func closeDomain(dom *libvirt.Domain, conn *libvirt.Connect) error {
55+
if dom == nil {
56+
return fmt.Errorf("nil domain, cannot close")
57+
}
58+
5559
if err := dom.Free(); err != nil {
5660
return err
5761
}
@@ -62,25 +66,31 @@ func closeDomain(dom *libvirt.Domain, conn *libvirt.Connect) error {
6266
return err
6367
}
6468

65-
func (d *Driver) createDomain() (*libvirt.Domain, error) {
66-
// create the XML for the domain using our domainTmpl template
69+
// defineDomain defines the XML for the domain using our domainTmpl template
70+
func (d *Driver) defineDomain() (*libvirt.Domain, error) {
6771
tmpl := template.Must(template.New("domain").Parse(domainTmpl))
6872
var domainXML bytes.Buffer
69-
if err := tmpl.Execute(&domainXML, d); err != nil {
73+
dlog := struct {
74+
Driver
75+
ConsoleLogPath string
76+
}{
77+
Driver: *d,
78+
ConsoleLogPath: consoleLogPath(*d),
79+
}
80+
if err := tmpl.Execute(&domainXML, dlog); err != nil {
7081
return nil, errors.Wrap(err, "executing domain xml")
7182
}
7283
conn, err := getConnection(d.ConnectionURI)
7384
if err != nil {
74-
return nil, errors.Wrap(err, "getting libvirt connection")
85+
return nil, fmt.Errorf("failed opening libvirt connection: %w", err)
7586
}
7687
defer func() {
7788
if _, err := conn.Close(); err != nil {
78-
log.Errorf("unable to close libvirt connection: %v", err)
89+
log.Errorf("failed closing libvirt connection: %v", lvErr(err))
7990
}
8091
}()
8192

82-
log.Infof("define libvirt domain using xml: %v", domainXML.String())
83-
// define the domain in libvirt using the generated XML
93+
log.Infof("defining domain using XML: %v", domainXML.String())
8494
dom, err := conn.DomainDefineXML(domainXML.String())
8595
if err != nil {
8696
return nil, errors.Wrapf(err, "error defining domain xml: %s", domainXML.String())

pkg/drivers/kvm/domain_definition_arm64.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ const domainTmpl = `
2727
<acpi/>
2828
<apic/>
2929
<pae/>
30-
{{if .Hidden}}
30+
{{- if .Hidden}}
3131
<kvm>
3232
<hidden state='on'/>
3333
</kvm>
34-
{{end}}
34+
{{- end}}
3535
</features>
3636
<cpu mode='host-passthrough'>
37-
{{if gt .NUMANodeCount 1}}
37+
{{- if gt .NUMANodeCount 1}}
3838
{{.NUMANodeXML}}
39-
{{end}}
39+
{{- end}}
4040
</cpu>
4141
<os>
4242
<type machine='virt-4.2' arch='aarch64'>hvm</type>
@@ -75,12 +75,12 @@ const domainTmpl = `
7575
<rng model='virtio'>
7676
<backend model='random'>/dev/random</backend>
7777
</rng>
78-
{{if .GPU}}
78+
{{- if .GPU}}
7979
{{.DevicesXML}}
80-
{{end}}
81-
{{if gt .ExtraDisks 0}}
80+
{{- end}}
81+
{{- if gt .ExtraDisks 0}}
8282
{{.ExtraDisksXML}}
83-
{{end}}
83+
{{- end}}
8484
</devices>
8585
</domain>
8686
`

pkg/drivers/kvm/domain_definition_x86.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ const domainTmpl = `
2727
<acpi/>
2828
<apic/>
2929
<pae/>
30-
{{if .Hidden}}
30+
{{- if .Hidden}}
3131
<kvm>
3232
<hidden state='on'/>
3333
</kvm>
34-
{{end}}
34+
{{- end}}
3535
</features>
3636
<cpu mode='host-passthrough'>
37-
{{if gt .NUMANodeCount 1}}
37+
{{- if gt .NUMANodeCount 1}}
3838
{{.NUMANodeXML}}
39-
{{end}}
39+
{{- end}}
4040
</cpu>
4141
<os>
4242
<type>hvm</type>
@@ -55,6 +55,7 @@ const domainTmpl = `
5555
<source file='{{.DiskPath}}'/>
5656
<target dev='hda' bus='virtio'/>
5757
</disk>
58+
<controller type='virtio-serial'/>
5859
<interface type='network'>
5960
<source network='{{.PrivateNetwork}}'/>
6061
<model type='virtio'/>
@@ -65,19 +66,23 @@ const domainTmpl = `
6566
</interface>
6667
<serial type='pty'>
6768
<target port='0'/>
69+
<log file='{{.ConsoleLogPath}}' append='on'/>
6870
</serial>
6971
<console type='pty'>
7072
<target type='serial' port='0'/>
7173
</console>
74+
<console type='pty'>
75+
<target type="virtio" port="1"/>
76+
</console>
7277
<rng model='virtio'>
7378
<backend model='random'>/dev/random</backend>
7479
</rng>
75-
{{if .GPU}}
80+
{{- if .GPU}}
7681
{{.DevicesXML}}
77-
{{end}}
78-
{{if gt .ExtraDisks 0}}
82+
{{- end}}
83+
{{- if gt .ExtraDisks 0}}
7984
{{.ExtraDisksXML}}
80-
{{end}}
85+
{{- end}}
8186
</devices>
8287
</domain>
8388
`

0 commit comments

Comments
 (0)