Skip to content

Commit

Permalink
fix: docker talosctl cluster create provisioner
Browse files Browse the repository at this point in the history
Recent Docker versions seem to have changed the API in the way container
IP addresses are reported.

Also fix running Talos 1.3 image under talosctl 1.4.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Feb 17, 2023
1 parent 6e8f135 commit b5c03a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
19 changes: 15 additions & 4 deletions pkg/provision/providers/docker/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ func (p *provisioner) createNode(ctx context.Context, clusterReq provision.Clust
})
}

for _, path := range append(constants.Overlays, "/var", "/system/state") {
// constants.UdevDir is in the list to support pre-1.4 Talos versions which had it in constants.Overlays
for _, path := range append(constants.Overlays, constants.UdevDir, "/var", "/system/state") {
mounts = append(mounts, mount.Mount{
Type: mount.TypeVolume,
Target: path,
Expand Down Expand Up @@ -182,9 +183,19 @@ func (p *provisioner) createNode(ctx context.Context, clusterReq provision.Clust
}

// Get the container's IP address.
addr, err := netip.ParseAddr(info.NetworkSettings.Networks[clusterReq.Network.Name].IPAddress)
if err != nil {
return provision.NodeInfo{}, err
var addr netip.Addr

if network, ok := info.NetworkSettings.Networks[clusterReq.Network.Name]; ok {
ip := network.IPAddress

if ip == "" && network.IPAMConfig != nil {
ip = network.IPAMConfig.IPv4Address
}

addr, err = netip.ParseAddr(ip)
if err != nil {
return provision.NodeInfo{}, err
}
}

nodeInfo := provision.NodeInfo{
Expand Down
7 changes: 6 additions & 1 deletion pkg/provision/providers/docker/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ func (p *provisioner) Reflect(ctx context.Context, clusterName, stateDirectory s
var ips []netip.Addr

if network, ok := node.NetworkSettings.Networks[res.clusterInfo.Network.Name]; ok {
addr, err := netip.ParseAddr(network.IPAddress)
ip := network.IPAddress
if ip == "" && network.IPAMConfig != nil {
ip = network.IPAMConfig.IPv4Address
}

addr, err := netip.ParseAddr(ip)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit b5c03a7

Please sign in to comment.