Skip to content

Commit 39a928e

Browse files
fix: fix incomplete cleanup in tunnel.json and zombie process in functional test
1 parent 981083d commit 39a928e

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

pkg/minikube/tunnel/registry.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ func (r *persistentRegistry) IsAlreadyDefinedAndRunning(tunnel *ID) (*ID, error)
6161
}
6262

6363
for _, t := range tunnels {
64+
// it is possible that different tunnel can be started for different tunnel
65+
// so we also need to check whether the machine name(profile name)
66+
// when we want to identify duplicated tunnels
6467
if t.Route.Equal(tunnel.Route) {
6568
isRunning, err := checkIfRunning(t.Pid)
6669
if err != nil {
@@ -87,7 +90,10 @@ func (r *persistentRegistry) Register(tunnel *ID) (rerr error) {
8790

8891
alreadyExists := false
8992
for i, t := range tunnels {
90-
if t.Route.Equal(tunnel.Route) {
93+
// it is allowed for multiple minikube clusters to have multiple tunnels simultaneously
94+
// it is possible that an old tunnel from an old profile has duplicated route information
95+
// so we need to check both machine name and route information
96+
if tunnel.MachineName == t.MachineName && t.Route.Equal(tunnel.Route) {
9197
isRunning, err := checkIfRunning(t.Pid)
9298
if err != nil {
9399
return fmt.Errorf("error checking whether conflicting tunnel (%v) is running: %s", t, err)

site/themes/docsy

Submodule docsy updated 75 files

test/integration/functional_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestFunctional(t *testing.T) {
7878

7979
// TestFunctionalNewestKubernetes are functionality run functional tests using NewestKubernetesVersion
8080
func TestFunctionalNewestKubernetes(t *testing.T) {
81-
if strings.Contains(*startArgs, "--kubernetes-version") {
81+
if strings.Contains(*startArgs, "--kubernetes-version") || constants.NewestKubernetesVersion == constants.DefaultKubernetesVersion {
8282
t.Skip()
8383
}
8484
k8sVersionString := constants.NewestKubernetesVersion
@@ -90,7 +90,7 @@ func TestFunctionalNewestKubernetes(t *testing.T) {
9090

9191
func testFunctional(t *testing.T, k8sVersion string) {
9292
profile := UniqueProfileName("functional")
93-
ctx := context.WithValue(context.Background(), "k8sVersion", k8sVersion)
93+
ctx := context.WithValue(context.Background(), ContextKey("k8sVersion"), k8sVersion)
9494
ctx, cancel := context.WithTimeout(ctx, Minutes(40))
9595
defer func() {
9696
if !*cleanup {

test/integration/functional_test_tunnel_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,9 @@ func validateTunnelDelete(_ context.Context, t *testing.T, _ string) {
432432
checkRoutePassword(t)
433433
// Stop tunnel
434434
tunnelSession.Stop(t)
435+
// prevent the child process from becoming a defunct zombie process
436+
if err := tunnelSession.cmd.Wait(); err != nil {
437+
t.Logf("failed to stop process: %v", err)
438+
return
439+
}
435440
}

test/integration/main_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ func StartArgs() []string {
119119
return strings.Split(*startArgs, " ")
120120
}
121121

122+
type ContextKey string
123+
122124
func StartArgsWithContext(ctx context.Context) []string {
123125
res := strings.Split(*startArgs, " ")
124-
value := ctx.Value("k8sVersion")
126+
value := ctx.Value(ContextKey("k8sVersion"))
125127
if value != nil && value != "" {
126128
res = append(res, fmt.Sprintf("--kubernetes-version=%s", value))
127129
}

0 commit comments

Comments
 (0)