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

fix: disable DNS fix in hostnetwork mode #1492

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion pkg/client/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ func NodeCreate(ctx context.Context, runtime runtimes.Runtime, node *k3d.Node, c
}
}

if _, any := fixes.GetFixes(runtime); any {
if _, anyFixEnabled := fixes.GetFixes(runtime); anyFixEnabled {
node.K3dEntrypoint = true
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/config/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ THE SOFTWARE.
package config

import (
"os"
"strings"

conf "github.com/k3d-io/k3d/v5/pkg/config/v1alpha5"
l "github.com/k3d-io/k3d/v5/pkg/logger"
runtimeutil "github.com/k3d-io/k3d/v5/pkg/runtimes/util"
k3d "github.com/k3d-io/k3d/v5/pkg/types"
"github.com/k3d-io/k3d/v5/pkg/types/fixes"
"github.com/k3d-io/k3d/v5/pkg/types/k3s"
)

Expand All @@ -40,6 +42,12 @@ func ProcessSimpleConfig(simpleConfig *conf.SimpleConfig) error {

l.Log().Debugf("Host network was chosen, changing provided/random api port to k3s:%s", k3d.DefaultAPIPort)
simpleConfig.ExposeAPI.HostPort = k3d.DefaultAPIPort

l.Log().Debugln("Host network was chosen, disabling DNS fix as no gateway will be available/required.")
err := os.Setenv(string(fixes.EnvFixDNS), "false")
if err != nil {
return err
}
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/types/fixes/fixes.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var fixNeeded = map[K3DFixEnv]func(runtime runtimes.Runtime) bool{
func GetFixes(runtime runtimes.Runtime) (map[K3DFixEnv]bool, bool) {
if EnabledFixes == nil {
result := make(map[K3DFixEnv]bool, len(FixEnvs))
any := false
anyEnabled := false
for _, fixEnv := range FixEnvs {
enabled := false
if v, isSet := os.LookupEnv(string(fixEnv)); !isSet {
Expand All @@ -128,11 +128,11 @@ func GetFixes(runtime runtimes.Runtime) (map[K3DFixEnv]bool, bool) {
}
result[fixEnv] = enabled
if enabled {
any = true
anyEnabled = true
}
}
EnabledFixes = result
AnyFixEnabled = any
AnyFixEnabled = anyEnabled
}
return EnabledFixes, AnyFixEnabled
}
Loading