From 338672522a0dce9f8dcff61663e53c59ab50688b Mon Sep 17 00:00:00 2001 From: Dejan Benedik Date: Thu, 9 Mar 2023 07:03:39 +0100 Subject: [PATCH] fix: handle colima host (#1228) --- pkg/client/host.go | 15 +++++++++++++++ pkg/runtimes/docker/info.go | 1 + pkg/runtimes/types/types.go | 1 + 3 files changed, 17 insertions(+) diff --git a/pkg/client/host.go b/pkg/client/host.go index 3d381c81..cd28e54b 100644 --- a/pkg/client/host.go +++ b/pkg/client/host.go @@ -91,6 +91,21 @@ func GetHostIP(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Clust } + // Colima + if rtimeInfo.InfoName == "colima" { + toolsNode, err := EnsureToolsNode(ctx, runtime, cluster) + if err != nil { + return nil, fmt.Errorf("failed to ensure that k3d-tools node is running to get host IP :%w", err) + } + + limaIP, err := resolveHostnameFromInside(ctx, runtime, toolsNode, "host.lima.internal", ResolveHostCmdGetEnt) + if err == nil { + return limaIP, nil + } + + l.Log().Debugf("[GetHostIP on colima] failed to resolve 'host.lima.internal' from inside the k3d-tools node: %v", err) + } + ip, err := runtime.GetHostIP(ctx, cluster.Network.Name) if err != nil { return nil, fmt.Errorf("runtime failed to get host IP: %w", err) diff --git a/pkg/runtimes/docker/info.go b/pkg/runtimes/docker/info.go index ea43ac32..0c66e8c0 100644 --- a/pkg/runtimes/docker/info.go +++ b/pkg/runtimes/docker/info.go @@ -53,6 +53,7 @@ func (d Docker) Info() (*runtimeTypes.RuntimeInfo, error) { CgroupVersion: info.CgroupVersion, CgroupDriver: info.CgroupDriver, Filesystem: "UNKNOWN", + InfoName: info.Name, } // Get the backing filesystem for the storage driver diff --git a/pkg/runtimes/types/types.go b/pkg/runtimes/types/types.go index 95ae7c8a..6af48dbc 100644 --- a/pkg/runtimes/types/types.go +++ b/pkg/runtimes/types/types.go @@ -31,6 +31,7 @@ type RuntimeInfo struct { CgroupVersion string `json:"cgroupversion,omitempty"` CgroupDriver string `json:"cgroupdriver,omitempty"` Filesystem string `json:"filesystem,omitempty"` + InfoName string `json:"infoname,omitempty"` } type NodeLogsOpts struct {