Skip to content

Commit f3b3d4e

Browse files
committed
try to fix couple of more things
1 parent 5146469 commit f3b3d4e

File tree

7 files changed

+53
-29
lines changed

7 files changed

+53
-29
lines changed

pkg/minikube/cni/cni.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ func applyManifest(cc config.ClusterConfig, r Runner, f assets.CopyableFile) err
197197
// ConfigureLoopback ensures loopback has expected version ("1.0.0") and valid name ("loopback") in its config file in /etc/cni/net.d
198198
// cri-o is leaving name out atm (https://github.com/cri-o/cri-o/pull/6273)
199199
// avoid errors like:
200-
// Failed to create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "..." network for pod "...": networkPlugin cni failed to set up pod "..." network: missing network name:,
201-
// failed to clean up sandbox container "..." network for pod "...": networkPlugin cni failed to teardown pod "..." network: missing network name]
200+
// - Failed to create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "..." network for pod "...": networkPlugin cni failed to set up pod "..." network: missing network name:,
201+
// - failed to clean up sandbox container "..." network for pod "...": networkPlugin cni failed to teardown pod "..." network: missing network name]
202+
// It is caller's responsibility to restart container runtime for these changes to take effect.
202203
func ConfigureLoopback(r Runner) error {
203204
loopback := "/etc/cni/net.d/*loopback.conf*" // usually: 200-loopback.conf
204205
// turn { "cniVersion": "0.3.1", "type": "loopback" }
@@ -226,7 +227,6 @@ func ConfigureDefaultBridgeCNIs(r Runner, networkPlugin string) error {
226227
if networkPlugin != "" {
227228
return disableAllBridgeCNIs(r)
228229
}
229-
230230
return configureAllBridgeCNIs(r, DefaultPodCIDR)
231231
}
232232

@@ -241,7 +241,7 @@ func disableAllBridgeCNIs(r Runner) error {
241241
}
242242
configs := strings.Trim(out.Stdout.String(), ", ")
243243
if len(configs) == 0 {
244-
klog.Infof("no bridge cni configs found in %q - nothing to disable", configs, path)
244+
klog.Infof("no bridge cni configs found in %q - nothing to disable", path)
245245
return nil
246246
}
247247
klog.Infof("disabled [%s] bridge cni config(s)", configs)
@@ -289,7 +289,7 @@ func configureAllBridgeCNIs(r Runner, cidr string) error {
289289
}
290290

291291
if len(strings.Trim(configs, ", ")) == 0 {
292-
klog.Infof("no bridge cni configs found in %q - nothing to configure", configs, path)
292+
klog.Infof("no bridge cni configs found in %q - nothing to configure", path)
293293
return nil
294294
}
295295
klog.Infof("configured [%s] bridge cni config(s)", configs)

pkg/minikube/cruntime/containerd.go

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ func (r *Containerd) Enable(disOthers bool, cgroupDriver string, inUserNamespace
229229
currentVersion, err := r.Version()
230230
if err == nil && semver.MustParse(targetVersion).GT(semver.MustParse(currentVersion)) {
231231
klog.Infof("replacing original containerd with v%s-%s-%s", targetVersion, runtime.GOOS, runtime.GOARCH)
232+
r.Init.ForceStop("containerd")
232233
if err := updateContainerdBinary(r.Runner, targetVersion, runtime.GOOS, runtime.GOARCH); err != nil {
233234
klog.Warningf("unable to replace original containerd with v%s-%s-%s: %v", targetVersion, runtime.GOOS, runtime.GOARCH, err)
234235
}

pkg/minikube/cruntime/cri.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,11 @@ func stopCRIContainers(cr CommandRunner, ids []string) error {
232232
klog.Infof("Stopping containers: %s", ids)
233233

234234
crictl := getCrictlPath(cr)
235-
args := append([]string{crictl, "stop"}, ids...)
235+
// bring crictl stop timeout on pair with docker:
236+
// - docker stop --help => -t, --time int Seconds to wait for stop before killing it (default 10)
237+
// - crictl stop --help => --timeout value, -t value Seconds to wait to kill the container after a graceful stop is requested (default: 0)
238+
// to prevent "stuck" containers blocking ports (eg, "[ERROR Port-2379|2380]: Port 2379|2380 is in use" for etcd during "live" k8s upgrade)
239+
args := append([]string{crictl, "stop", "--timeout", "10"}, ids...)
236240
c := exec.Command("sudo", args...)
237241
if _, err := cr.RunCmd(c); err != nil {
238242
return errors.Wrap(err, "crictl")

pkg/minikube/node/start.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,21 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
418418
exit.Error(reason.InternalRuntime, "Failed runtime", err)
419419
}
420420

421-
disableOthers := true
422-
if driver.BareMetal(cc.Driver) {
423-
disableOthers = false
421+
// ensure loopback is properly configured
422+
// make sure container runtime is restarted afterwards for these changes to take effect
423+
if err := cni.ConfigureLoopback(runner); err != nil {
424+
klog.Warningf("unable to name loopback interface in dockerConfigureNetworkPlugin: %v", err)
425+
}
426+
// ensure all default CNI(s) are properly configured on each and every node (re)start
427+
// make sure container runtime is restarted afterwards for these changes to take effect
428+
if err := cni.ConfigureDefaultBridgeCNIs(runner, cc.KubernetesConfig.NetworkPlugin); err != nil {
429+
klog.Errorf("unable to disable preinstalled bridge CNI(s): %v", err)
430+
}
431+
432+
if kv.GTE(semver.MustParse("1.24.0-alpha.2")) {
433+
if err := cruntime.ConfigureNetworkPlugin(cr, runner, cc.KubernetesConfig.NetworkPlugin); err != nil {
434+
exit.Error(reason.RuntimeEnable, "Failed to configure network plugin", err)
435+
}
424436
}
425437

426438
// Preload is overly invasive for bare metal, and caching is not meaningful.
@@ -440,23 +452,6 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
440452
}
441453
}
442454

443-
// ensure loopback is properly configured
444-
if err := cni.ConfigureLoopback(runner); err != nil {
445-
klog.Warningf("unable to name loopback interface in dockerConfigureNetworkPlugin: %v", err)
446-
}
447-
448-
// ensure all default CNI(s) are properly configured on each and every node (re)start
449-
// make sure container runtime is restarted afterwards for these changes to take effect
450-
if err := cni.ConfigureDefaultBridgeCNIs(runner, cc.KubernetesConfig.NetworkPlugin); err != nil {
451-
klog.Errorf("unable to disable preinstalled bridge CNI(s): %v", err)
452-
}
453-
454-
if kv.GTE(semver.MustParse("1.24.0-alpha.2")) {
455-
if err := cruntime.ConfigureNetworkPlugin(cr, runner, cc.KubernetesConfig.NetworkPlugin); err != nil {
456-
exit.Error(reason.RuntimeEnable, "Failed to configure network plugin", err)
457-
}
458-
}
459-
460455
inUserNamespace := strings.Contains(cc.KubernetesConfig.FeatureGates, "KubeletInUserNamespace=true")
461456
// for docker container runtime: ensure containerd is properly configured by calling Enable(), as docker could be bound to containerd
462457
// it will also "soft" start containerd, but it will not disable others; docker will disable containerd if not used in the next step
@@ -475,6 +470,11 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
475470
klog.Warningf("cannot ensure containerd is configured properly and reloaded for docker - cluster might be unstable: %v", err)
476471
}
477472
}
473+
474+
disableOthers := true
475+
if driver.BareMetal(cc.Driver) {
476+
disableOthers = false
477+
}
478478
err = cr.Enable(disableOthers, cgroupDriver(cc), inUserNamespace)
479479
if err != nil {
480480
exit.Error(reason.RuntimeEnable, "Failed to enable container runtime", err)

test/integration/addons_test.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"github.com/blang/semver/v4"
3939
retryablehttp "github.com/hashicorp/go-retryablehttp"
4040
"k8s.io/minikube/pkg/kapi"
41+
"k8s.io/minikube/pkg/minikube/constants"
4142
"k8s.io/minikube/pkg/minikube/detect"
4243
"k8s.io/minikube/pkg/util/retry"
4344
)
@@ -68,7 +69,14 @@ func TestAddons(t *testing.T) {
6869
}
6970

7071
// MOCK_GOOGLE_TOKEN forces the gcp-auth webhook to use a mock token instead of trying to get a valid one from the credentials.
71-
t.Setenv("MOCK_GOOGLE_TOKEN", "true")
72+
os.Setenv("MOCK_GOOGLE_TOKEN", "true")
73+
74+
// for some reason, (Docker_Cloud_Shell) sets 'MINIKUBE_FORCE_SYSTEMD=true' while having cgroupfs set in docker (and probably os itself), which might make it unstable and occasionaly fail:
75+
// - I1226 15:05:24.834294 11286 out.go:177] - MINIKUBE_FORCE_SYSTEMD=true
76+
// - I1226 15:05:25.070037 11286 info.go:266] docker info: {... CgroupDriver:cgroupfs ...}
77+
// ref: https://storage.googleapis.com/minikube-builds/logs/15463/27154/Docker_Cloud_Shell.html
78+
// so we override that here to let minikube auto-detect appropriate cgroup driver
79+
os.Setenv(constants.MinikubeForceSystemdEnv, "")
7280

7381
args := append([]string{"start", "-p", profile, "--wait=true", "--memory=4000", "--alsologtostderr", "--addons=registry", "--addons=metrics-server", "--addons=volumesnapshots", "--addons=csi-hostpath-driver", "--addons=gcp-auth", "--addons=cloud-spanner"}, StartArgs()...)
7482
if !NoneDriver() { // none driver does not support ingress

test/integration/json_output_test.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func validateDistinctCurrentSteps(ctx context.Context, t *testing.T, ces []*clou
120120
// validateIncreasingCurrentSteps verifies that for a successful minikube start, 'current step' should be increasing
121121
func validateIncreasingCurrentSteps(ctx context.Context, t *testing.T, ces []*cloudEvent) {
122122
step := -1
123-
for _, ce := range ces {
123+
for i, ce := range ces {
124124
currentStep, exists := ce.data["currentstep"]
125125
if !exists || ce.Type() != "io.k8s.sigs.minikube.step" {
126126
continue
@@ -130,6 +130,17 @@ func validateIncreasingCurrentSteps(ctx context.Context, t *testing.T, ces []*cl
130130
t.Fatalf("current step is not an integer: %v\n%v", currentStep, ce)
131131
}
132132
if cs <= step {
133+
// check if steps are mixed because of goroutines complete in unusual order, but still ok
134+
// eg, "Enabling Addons" (goroutine) might complete before or after "Verifying Kubernetes" finishes
135+
if i > 0 {
136+
prev := ces[i-1].data["name"]
137+
cur := ce.data["name"]
138+
if cur == "Verifying Kubernetes" && prev == "Enabling Addons" {
139+
t.Logf("unusual order of steps, might be ok: %q event came before %q", prev, cur)
140+
step = cs
141+
continue
142+
}
143+
}
133144
t.Fatalf("current step is not in increasing order: %v", ces)
134145
}
135146
step = cs

test/integration/preload_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ func TestPreload(t *testing.T) {
7878
t.Fatalf("%s failed: %v", rr.Command(), err)
7979
}
8080
if !strings.Contains(rr.Output(), image) {
81-
t.Fatalf("Expected to find %s in output of `docker images`, instead got %s", image, rr.Output())
81+
t.Fatalf("Expected to find %s in image list output, instead got %s", image, rr.Output())
8282
}
8383
}

0 commit comments

Comments
 (0)