Skip to content

Commit eee0cf9

Browse files
authored
Merge pull request #6078 from vvoland/info-devices
system/info: Show discovered devices
2 parents 628b2f1 + f6a077a commit eee0cf9

File tree

21 files changed

+227
-135
lines changed

21 files changed

+227
-135
lines changed

cli/command/builder/client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ package builder
33
import (
44
"context"
55

6-
"github.com/docker/docker/api/types"
6+
"github.com/docker/docker/api/types/build"
77
"github.com/docker/docker/client"
88
)
99

1010
type fakeClient struct {
1111
client.Client
12-
builderPruneFunc func(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error)
12+
builderPruneFunc func(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error)
1313
}
1414

15-
func (c *fakeClient) BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) {
15+
func (c *fakeClient) BuildCachePrune(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error) {
1616
if c.builderPruneFunc != nil {
1717
return c.builderPruneFunc(ctx, opts)
1818
}

cli/command/builder/prune.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/docker/cli/cli/command/completion"
1212
"github.com/docker/cli/internal/prompt"
1313
"github.com/docker/cli/opts"
14-
"github.com/docker/docker/api/types"
14+
"github.com/docker/docker/api/types/build"
1515
"github.com/docker/docker/errdefs"
1616
units "github.com/docker/go-units"
1717
"github.com/spf13/cobra"
@@ -79,7 +79,7 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
7979
}
8080
}
8181

82-
report, err := dockerCli.Client().BuildCachePrune(ctx, types.BuildCachePruneOptions{
82+
report, err := dockerCli.Client().BuildCachePrune(ctx, build.CachePruneOptions{
8383
All: options.all,
8484
KeepStorage: options.keepStorage.Value(), // FIXME(thaJeztah): rewrite to use new options; see https://github.com/moby/moby/pull/48720
8585
Filters: pruneFilters,

cli/command/builder/prune_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import (
77
"testing"
88

99
"github.com/docker/cli/internal/test"
10-
"github.com/docker/docker/api/types"
10+
"github.com/docker/docker/api/types/build"
1111
)
1212

1313
func TestBuilderPromptTermination(t *testing.T) {
1414
ctx, cancel := context.WithCancel(context.Background())
1515
t.Cleanup(cancel)
1616

1717
cli := test.NewFakeCli(&fakeClient{
18-
builderPruneFunc: func(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) {
18+
builderPruneFunc: func(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error) {
1919
return nil, errors.New("fakeClient builderPruneFunc should not be called")
2020
},
2121
})

cli/command/system/info.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,13 @@ func prettyPrintServerInfo(streams command.Streams, info *dockerInfo) []error {
281281
}
282282
}
283283

284+
if len(info.DiscoveredDevices) > 0 {
285+
fprintln(output, " Discovered Devices:")
286+
for _, device := range info.DiscoveredDevices {
287+
fprintf(output, " %s: %s\n", device.Source, device.ID)
288+
}
289+
}
290+
284291
fprintln(output, " Swarm:", info.Swarm.LocalNodeState)
285292
printSwarmInfo(output, *info.Info)
286293

cli/command/system/info_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ func TestPrettyPrintInfo(t *testing.T) {
260260
sampleInfoLabelsEmpty := sampleInfoNoSwarm
261261
sampleInfoLabelsEmpty.Labels = []string{}
262262

263+
sampleInfoWithDevices := sampleInfoNoSwarm
264+
sampleInfoWithDevices.DiscoveredDevices = []system.DeviceInfo{
265+
{Source: "cdi", ID: "com.example.device1"},
266+
{Source: "cdi", ID: "nvidia.com/gpu=gpu0"},
267+
}
268+
263269
for _, tc := range []struct {
264270
doc string
265271
dockerInfo dockerInfo
@@ -366,6 +372,14 @@ func TestPrettyPrintInfo(t *testing.T) {
366372
warningsGolden: "docker-info-badsec-stderr",
367373
expectedError: "errors pretty printing info",
368374
},
375+
{
376+
doc: "info with devices",
377+
dockerInfo: dockerInfo{
378+
Info: &sampleInfoWithDevices,
379+
},
380+
prettyGolden: "docker-info-with-devices",
381+
jsonGolden: "docker-info-with-devices",
382+
},
369383
} {
370384
t.Run(tc.doc, func(t *testing.T) {
371385
cli := test.NewFakeCli(&fakeClient{})
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Client:
2+
3+
Server:
4+
Containers: 0
5+
Running: 0
6+
Paused: 0
7+
Stopped: 0
8+
Images: 0
9+
Server Version: 17.06.1-ce
10+
Storage Driver: overlay2
11+
Backing Filesystem: extfs
12+
Supports d_type: true
13+
Using metacopy: false
14+
Native Overlay Diff: true
15+
Logging Driver: json-file
16+
Cgroup Driver: cgroupfs
17+
Plugins:
18+
Volume: local
19+
Network: bridge host macvlan null overlay
20+
Log: awslogs fluentd gcplogs gelf journald json-file splunk syslog
21+
CDI spec directories:
22+
/etc/cdi
23+
/var/run/cdi
24+
Discovered Devices:
25+
cdi: com.example.device1
26+
cdi: nvidia.com/gpu=gpu0
27+
Swarm: inactive
28+
Runtimes: runc
29+
Default Runtime: runc
30+
Init Binary: docker-init
31+
containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170
32+
runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2
33+
init version: 949e6fa
34+
Security Options:
35+
apparmor
36+
seccomp
37+
Profile: default
38+
Kernel Version: 4.4.0-87-generic
39+
Operating System: Ubuntu 16.04.3 LTS
40+
OSType: linux
41+
Architecture: x86_64
42+
CPUs: 2
43+
Total Memory: 1.953GiB
44+
Name: system-sample
45+
ID: EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX
46+
Docker Root Dir: /var/lib/docker
47+
Debug Mode: true
48+
File Descriptors: 33
49+
Goroutines: 135
50+
System Time: 2017-08-24T17:44:34.077811894Z
51+
EventsListeners: 0
52+
Labels:
53+
provider=digitalocean
54+
Experimental: false
55+
Insecure Registries:
56+
127.0.0.0/8
57+
Live Restore Enabled: false
58+
Default Address Pools:
59+
Base: 10.123.0.0/16, Size: 24
60+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"ID":"EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX","Containers":0,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":0,"Images":0,"Driver":"overlay2","DriverStatus":[["Backing Filesystem","extfs"],["Supports d_type","true"],["Using metacopy","false"],["Native Overlay Diff","true"]],"Plugins":{"Volume":["local"],"Network":["bridge","host","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"PidsLimit":false,"IPv4Forwarding":true,"BridgeNfIptables":false,"BridgeNfIp6tables":false,"Debug":true,"NFd":33,"OomKillDisable":true,"NGoroutines":135,"SystemTime":"2017-08-24T17:44:34.077811894Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":0,"KernelVersion":"4.4.0-87-generic","OperatingSystem":"Ubuntu 16.04.3 LTS","OSVersion":"","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"IndexConfigs":{"docker.io":{"Mirrors":null,"Name":"docker.io","Official":true,"Secure":true}},"InsecureRegistryCIDRs":["127.0.0.0/8"],"Mirrors":null},"NCPU":2,"MemTotal":2097356800,"GenericResources":null,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"system-sample","Labels":["provider=digitalocean"],"ExperimentalBuild":false,"ServerVersion":"17.06.1-ce","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"6e23458c129b551d5c9871e5174f6b1b7f6d1170","Expected":"6e23458c129b551d5c9871e5174f6b1b7f6d1170"},"RuncCommit":{"ID":"810190ceaa507aa2727d7ae6f4790c76ec150bd2","Expected":"810190ceaa507aa2727d7ae6f4790c76ec150bd2"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=apparmor","name=seccomp,profile=default"],"DefaultAddressPools":[{"Base":"10.123.0.0/16","Size":24}],"CDISpecDirs":["/etc/cdi","/var/run/cdi"],"DiscoveredDevices":[{"Source":"cdi","ID":"com.example.device1"},{"Source":"cdi","ID":"nvidia.com/gpu=gpu0"}],"Warnings":null}

vendor.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/distribution/reference v0.6.0
1616
github.com/docker/cli-docs-tool v0.9.0
1717
github.com/docker/distribution v2.8.3+incompatible
18-
github.com/docker/docker v28.1.2-0.20250516114456-c04dec11437f+incompatible // master, v28.x dev
18+
github.com/docker/docker v28.1.2-0.20250516164234-b45aa469cac7+incompatible // master, v28.x dev
1919
github.com/docker/docker-credential-helpers v0.9.3
2020
github.com/docker/go-connections v0.5.0
2121
github.com/docker/go-units v0.5.0

vendor.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ github.com/docker/cli-docs-tool v0.9.0/go.mod h1:ClrwlNW+UioiRyH9GiAOe1o3J/TsY3T
5555
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
5656
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
5757
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
58-
github.com/docker/docker v28.1.2-0.20250516114456-c04dec11437f+incompatible h1:0jSTstSvJ1S0l/wH/vJ5JMnsSNpWx6dmqblTwe87dVc=
59-
github.com/docker/docker v28.1.2-0.20250516114456-c04dec11437f+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
58+
github.com/docker/docker v28.1.2-0.20250516164234-b45aa469cac7+incompatible h1:xtuKFtxaqylpM2HVDGIJn11TYgIbo7B6aW+PwVFvZj8=
59+
github.com/docker/docker v28.1.2-0.20250516164234-b45aa469cac7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
6060
github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8=
6161
github.com/docker/docker-credential-helpers v0.9.3/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
6262
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=

vendor/github.com/docker/docker/api/common.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)