From bfc9828b494c21fa66bd38b82fb6b018e517d00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=A6=E5=8D=97=E8=B7=AF=E4=B9=8B=E8=8A=B1?= Date: Sun, 12 May 2024 15:45:30 +0200 Subject: [PATCH 1/7] feat: check connectivity outside minikube once it fails --- pkg/minikube/node/start.go | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 7cd789c770fc..3a8f9d93a3ef 100755 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -23,6 +23,7 @@ import ( "os/exec" "path" "regexp" + "runtime" "strconv" "strings" "sync" @@ -856,14 +857,32 @@ func tryRegistry(r command.Runner, driverName, imageRepository, ip string) { } opts = append(opts, fmt.Sprintf("https://%s/", imageRepository)) - if rr, err := r.RunCmd(exec.Command("curl", opts...)); err != nil { + exe := "curl" + if runtime.GOOS == "windows" { + exe = "curl.exe" + } + cmd := exec.Command(exe, opts...) + if rr, err := r.RunCmd(cmd); err != nil { + outside := true klog.Warningf("%s failed: %v", rr.Args, err) - out.WarningT("This {{.type}} is having trouble accessing https://{{.repository}}", out.V{"repository": imageRepository, "type": driver.MachineType(driverName)}) - out.ErrT(style.Tip, "To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/") + // using QEMU with the user network if driver.IsQEMU(driverName) && ip == "127.0.0.1" { out.WarningT("Due to DNS issues your cluster may have problems starting and you may not be able to pull images\nMore details available at: https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues") } + // now we shall also try whether this registry is reachable outside the machine + // so that we can tell in the logs that if the user's computer had any network issue or could it be related to a network module config change in minikbue ISO + if err := cmd.Run(); err != nil { + outside = false + } + if !outside { + // both inside and outside failed + out.WarningT("This {{.type}} is also having trouble accessing https://{{.repository}} both inside and outside the minikube ", out.V{"repository": imageRepository, "type": driver.MachineType(driverName)}) + } else { + // only inside the minikube failed + out.WarningT("This {{.type}} is having trouble accessing https://{{.repository}} only inside the minikube", out.V{"repository": imageRepository, "type": driver.MachineType(driverName)}) + } + out.ErrT(style.Tip, "To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/") } } From 779568bfc92dfb08d47f1815e478efc101be6aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=8C=A6=E5=8D=97=E8=B7=AF=E4=B9=8B=E8=8A=B1?= <46831212+ComradeProgrammer@users.noreply.github.com> Date: Sun, 30 Jun 2024 15:20:00 +0200 Subject: [PATCH 2/7] Update pkg/minikube/node/start.go Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com> --- pkg/minikube/node/start.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 3a8f9d93a3ef..a7c9f080ddfc 100755 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -873,14 +873,11 @@ func tryRegistry(r command.Runner, driverName, imageRepository, ip string) { // now we shall also try whether this registry is reachable outside the machine // so that we can tell in the logs that if the user's computer had any network issue or could it be related to a network module config change in minikbue ISO if err := cmd.Run(); err != nil { - outside = false - } - if !outside { // both inside and outside failed - out.WarningT("This {{.type}} is also having trouble accessing https://{{.repository}} both inside and outside the minikube ", out.V{"repository": imageRepository, "type": driver.MachineType(driverName)}) + out.WarningT("Failing to connect to {{.curlTarget}} from both inside the minikube {{.type}} and host machine", out.V{"curlTarget": curlTarget, "type": driver.MachineType(driverName)}) } else { // only inside the minikube failed - out.WarningT("This {{.type}} is having trouble accessing https://{{.repository}} only inside the minikube", out.V{"repository": imageRepository, "type": driver.MachineType(driverName)}) + out.WarningT("Failing to connect to {{.curlTarget}} from inside the minikube {{.type}}", out.V{"curlTarget": curlTarget, "type": driver.MachineType(driverName)}) } out.ErrT(style.Tip, "To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/") } From 6eec56de76c16849abf303090a0b0b5e9424256c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=8C=A6=E5=8D=97=E8=B7=AF=E4=B9=8B=E8=8A=B1?= <46831212+ComradeProgrammer@users.noreply.github.com> Date: Sun, 30 Jun 2024 15:21:24 +0200 Subject: [PATCH 3/7] Update pkg/minikube/node/start.go Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com> --- pkg/minikube/node/start.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index a7c9f080ddfc..4f2171525fd9 100755 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -856,14 +856,14 @@ func tryRegistry(r command.Runner, driverName, imageRepository, ip string) { imageRepository = images.DefaultKubernetesRepo } - opts = append(opts, fmt.Sprintf("https://%s/", imageRepository)) + curlTarget := fmt.Sprintf("https://%s/", imageRepository) + opts = append(opts, curlTarget) exe := "curl" if runtime.GOOS == "windows" { exe = "curl.exe" } cmd := exec.Command(exe, opts...) if rr, err := r.RunCmd(cmd); err != nil { - outside := true klog.Warningf("%s failed: %v", rr.Args, err) // using QEMU with the user network @@ -872,13 +872,22 @@ func tryRegistry(r command.Runner, driverName, imageRepository, ip string) { } // now we shall also try whether this registry is reachable outside the machine // so that we can tell in the logs that if the user's computer had any network issue or could it be related to a network module config change in minikbue ISO - if err := cmd.Run(); err != nil { - // both inside and outside failed - out.WarningT("Failing to connect to {{.curlTarget}} from both inside the minikube {{.type}} and host machine", out.V{"curlTarget": curlTarget, "type": driver.MachineType(driverName)}) - } else { - // only inside the minikube failed + + //We should skip the second check if the user is using the none or ssh driver since there is no different + // between an "inside" and "outside" check on the none driver, and checking the host on the ssh driver is not helpful. + if driver.IsNone(driverName) || driver.IsSSH(driverName) { out.WarningT("Failing to connect to {{.curlTarget}} from inside the minikube {{.type}}", out.V{"curlTarget": curlTarget, "type": driver.MachineType(driverName)}) + + } else { + if err := cmd.Run(); err != nil { + // both inside and outside failed + out.WarningT("Failing to connect to {{.curlTarget}} from both inside the minikube {{.type}} and host machine", out.V{"curlTarget": curlTarget, "type": driver.MachineType(driverName)}) + } else { + // only inside the minikube failed + out.WarningT("Failing to connect to {{.curlTarget}} from inside the minikube {{.type}}", out.V{"curlTarget": curlTarget, "type": driver.MachineType(driverName)}) + } } + out.ErrT(style.Tip, "To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/") } } From c4a5dd44c038948d092bd22daca79f0a2dde99f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=8C=A6=E5=8D=97=E8=B7=AF=E4=B9=8B=E8=8A=B1?= <46831212+ComradeProgrammer@users.noreply.github.com> Date: Thu, 4 Jul 2024 00:26:43 +0200 Subject: [PATCH 4/7] Update pkg/minikube/node/start.go Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com> --- pkg/minikube/node/start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 4f2171525fd9..d6ff0a0bf0b3 100755 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -873,7 +873,7 @@ func tryRegistry(r command.Runner, driverName, imageRepository, ip string) { // now we shall also try whether this registry is reachable outside the machine // so that we can tell in the logs that if the user's computer had any network issue or could it be related to a network module config change in minikbue ISO - //We should skip the second check if the user is using the none or ssh driver since there is no different + // We should skip the second check if the user is using the none or ssh driver since there is no difference // between an "inside" and "outside" check on the none driver, and checking the host on the ssh driver is not helpful. if driver.IsNone(driverName) || driver.IsSSH(driverName) { out.WarningT("Failing to connect to {{.curlTarget}} from inside the minikube {{.type}}", out.V{"curlTarget": curlTarget, "type": driver.MachineType(driverName)}) From 5bbb68fdb343a4fd0bac66b69dd2693514a1fa6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=8C=A6=E5=8D=97=E8=B7=AF=E4=B9=8B=E8=8A=B1?= <46831212+ComradeProgrammer@users.noreply.github.com> Date: Thu, 4 Jul 2024 00:26:57 +0200 Subject: [PATCH 5/7] Update pkg/minikube/node/start.go Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com> --- pkg/minikube/node/start.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index d6ff0a0bf0b3..e41978019fa6 100755 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -875,18 +875,14 @@ func tryRegistry(r command.Runner, driverName, imageRepository, ip string) { // We should skip the second check if the user is using the none or ssh driver since there is no difference // between an "inside" and "outside" check on the none driver, and checking the host on the ssh driver is not helpful. - if driver.IsNone(driverName) || driver.IsSSH(driverName) { - out.WarningT("Failing to connect to {{.curlTarget}} from inside the minikube {{.type}}", out.V{"curlTarget": curlTarget, "type": driver.MachineType(driverName)}) - - } else { + warning := "Failing to connect to {{.curlTarget}} from inside the minikube {{.type}}" + if !driver.IsNone(driverName) && !driver.IsSSH(driverName) { if err := cmd.Run(); err != nil { // both inside and outside failed - out.WarningT("Failing to connect to {{.curlTarget}} from both inside the minikube {{.type}} and host machine", out.V{"curlTarget": curlTarget, "type": driver.MachineType(driverName)}) - } else { - // only inside the minikube failed - out.WarningT("Failing to connect to {{.curlTarget}} from inside the minikube {{.type}}", out.V{"curlTarget": curlTarget, "type": driver.MachineType(driverName)}) + warning = "Failing to connect to {{.curlTarget}} from both inside the minikube {{.type}} and host machine" } } + out.WarningT(warning, out.V{"curlTarget": curlTarget, "type": driver.MachineType(driverName)}) out.ErrT(style.Tip, "To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/") } From 8319a343813a664305a4b3f894278da8e0b45d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=8C=A6=E5=8D=97=E8=B7=AF=E4=B9=8B=E8=8A=B1?= <46831212+ComradeProgrammer@users.noreply.github.com> Date: Mon, 15 Jul 2024 00:51:20 +0200 Subject: [PATCH 6/7] Update pkg/minikube/node/start.go Co-authored-by: Steven Powell <44844360+spowelljr@users.noreply.github.com> --- pkg/minikube/node/start.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index e41978019fa6..89f2273607d0 100755 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -870,11 +870,15 @@ func tryRegistry(r command.Runner, driverName, imageRepository, ip string) { if driver.IsQEMU(driverName) && ip == "127.0.0.1" { out.WarningT("Due to DNS issues your cluster may have problems starting and you may not be able to pull images\nMore details available at: https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues") } - // now we shall also try whether this registry is reachable outside the machine - // so that we can tell in the logs that if the user's computer had any network issue or could it be related to a network module config change in minikbue ISO - - // We should skip the second check if the user is using the none or ssh driver since there is no difference - // between an "inside" and "outside" check on the none driver, and checking the host on the ssh driver is not helpful. + // now we shall also try whether this registry is reachable + // outside the machine so that we can tell in the logs that if + // the user's computer had any network issue or could it be + // related to a network module config change in minikube ISO + + // We should skip the second check if the user is using the none + // or ssh driver since there is no difference between an "inside" + // and "outside" check on the none driver, and checking the host + // on the ssh driver is not helpful. warning := "Failing to connect to {{.curlTarget}} from inside the minikube {{.type}}" if !driver.IsNone(driverName) && !driver.IsSSH(driverName) { if err := cmd.Run(); err != nil { From 8e075c1e2ad9d006fd2549798ef373e219356726 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Mon, 15 Jul 2024 13:35:33 -0500 Subject: [PATCH 7/7] go fmt --- pkg/minikube/node/start.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 89f2273607d0..0ca736708d16 100755 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -870,10 +870,10 @@ func tryRegistry(r command.Runner, driverName, imageRepository, ip string) { if driver.IsQEMU(driverName) && ip == "127.0.0.1" { out.WarningT("Due to DNS issues your cluster may have problems starting and you may not be able to pull images\nMore details available at: https://minikube.sigs.k8s.io/docs/drivers/qemu/#known-issues") } - // now we shall also try whether this registry is reachable - // outside the machine so that we can tell in the logs that if - // the user's computer had any network issue or could it be - // related to a network module config change in minikube ISO + // now we shall also try whether this registry is reachable + // outside the machine so that we can tell in the logs that if + // the user's computer had any network issue or could it be + // related to a network module config change in minikube ISO // We should skip the second check if the user is using the none // or ssh driver since there is no difference between an "inside"