Skip to content

Commit

Permalink
feat: report Docker node resources in cluster show
Browse files Browse the repository at this point in the history
`talosctl cluster show` currently reports '-' in the CPU and RAM
columns because these informations are not available directly from the
container list API call.

For consistency with `talosctl cluster create`, this commit fetches the
missing information through an inspect call for each node so that these
information are available from a `Reflect` initialization.

Signed-off-by: Jean-Tiare Le Bigot <jt@yadutaf.fr>
Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
yadutaf authored and smira committed Mar 21, 2024
1 parent 84ec8c1 commit 92808e3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
github.com/coreos/go-iptables v0.7.0
github.com/cosi-project/runtime v0.4.0-alpha.9
github.com/distribution/reference v0.5.0
github.com/docker/docker v25.0.4+incompatible
github.com/docker/docker v25.0.5+incompatible
github.com/docker/go-connections v0.5.0
github.com/dustin/go-humanize v1.0.1
github.com/ecks/uefi v0.0.0-20221116212947-caef65d070eb
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ github.com/docker/cli v24.0.0+incompatible h1:0+1VshNwBQzQAx9lOl+OYCTCEAD8fKs/qe
github.com/docker/cli v24.0.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v25.0.4+incompatible h1:XITZTrq+52tZyZxUOtFIahUf3aH367FLxJzt9vZeAF8=
github.com/docker/docker v25.0.4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE=
github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A=
github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0=
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
Expand Down
8 changes: 8 additions & 0 deletions pkg/provision/providers/docker/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ func (p *provisioner) Reflect(ctx context.Context, clusterName, stateDirectory s
return nil, err
}

container, err := p.client.ContainerInspect(ctx, node.ID)
if err != nil {
return nil, err
}

var ips []netip.Addr

if network, ok := node.NetworkSettings.Networks[res.clusterInfo.Network.Name]; ok {
Expand All @@ -91,6 +96,9 @@ func (p *provisioner) Reflect(ctx context.Context, clusterName, stateDirectory s
Type: t,

IPs: ips,

NanoCPUs: container.HostConfig.Resources.NanoCPUs,
Memory: container.HostConfig.Resources.Memory,
})
}

Expand Down

0 comments on commit 92808e3

Please sign in to comment.