From 56d9453261d47c0739be21cb7a5fe6beb25cb92c Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 3 Feb 2023 14:45:52 +0400 Subject: [PATCH] fix: panic in talosctl cluster show This might happen with docker provisioner if the network is not found. Fixes #6793 Signed-off-by: Andrey Smirnov --- pkg/provision/providers/docker/reflect.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/provision/providers/docker/reflect.go b/pkg/provision/providers/docker/reflect.go index ad182ce68f..0663ff4bcc 100644 --- a/pkg/provision/providers/docker/reflect.go +++ b/pkg/provision/providers/docker/reflect.go @@ -14,6 +14,7 @@ import ( "github.com/siderolabs/talos/pkg/provision" ) +//nolint:gocyclo func (p *provisioner) Reflect(ctx context.Context, clusterName, stateDirectory string) (provision.Cluster, error) { res := &result{ clusterInfo: provision.ClusterInfo{ @@ -67,9 +68,15 @@ func (p *provisioner) Reflect(ctx context.Context, clusterName, stateDirectory s return nil, err } - addr, err := netip.ParseAddr(node.NetworkSettings.Networks[res.clusterInfo.Network.Name].IPAddress) - if err != nil { - return nil, err + var ips []netip.Addr + + if network, ok := node.NetworkSettings.Networks[res.clusterInfo.Network.Name]; ok { + addr, err := netip.ParseAddr(network.IPAddress) + if err != nil { + return nil, err + } + + ips = append(ips, addr) } res.clusterInfo.Nodes = append(res.clusterInfo.Nodes, @@ -78,7 +85,7 @@ func (p *provisioner) Reflect(ctx context.Context, clusterName, stateDirectory s Name: strings.TrimLeft(node.Names[0], "/"), Type: t, - IPs: []netip.Addr{addr}, + IPs: ips, }) }