Skip to content

Commit

Permalink
fix: panic in talosctl cluster show
Browse files Browse the repository at this point in the history
This might happen with docker provisioner if the network is not found.

Fixes #6793

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Feb 3, 2023
1 parent 38a5119 commit 56d9453
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/provision/providers/docker/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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,
Expand All @@ -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,
})
}

Expand Down

0 comments on commit 56d9453

Please sign in to comment.