Skip to content

Commit 2790ac6

Browse files
committedNov 9, 2016
Add expected 3rd party binaries commit ids to info
Signed-off-by: Kenfe-Mickael Laventure <[email protected]>
1 parent 5125484 commit 2790ac6

21 files changed

+157
-13
lines changed
 

‎Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
236236

237237
# Install tomlv, vndr, runc, containerd, tini, docker-proxy
238238
# Please edit hack/dockerfile/install-binaries.sh to update them.
239+
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
239240
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
240241
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy
241242

‎Dockerfile.aarch64

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
164164

165165
# Install tomlv, vndr, runc, containerd, tini, docker-proxy
166166
# Please edit hack/dockerfile/install-binaries.sh to update them.
167+
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
167168
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
168169
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy
169170

‎Dockerfile.armhf

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
168168

169169
# Install tomlv, vndr, runc, containerd, tini, docker-proxy
170170
# Please edit hack/dockerfile/install-binaries.sh to update them.
171+
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
171172
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
172173
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy
173174

‎Dockerfile.ppc64le

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
187187

188188
# Install tomlv, vndr, runc, containerd, tini, docker-proxy
189189
# Please edit hack/dockerfile/install-binaries.sh to update them.
190+
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
190191
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
191192
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy
192193

‎Dockerfile.s390x

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
179179

180180
# Install tomlv, vndr, runc, containerd, tini, docker-proxy
181181
# Please edit hack/dockerfile/install-binaries.sh to update them.
182+
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
182183
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
183184
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy
184185

‎Dockerfile.simple

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ENV CGO_LDFLAGS -L/lib
6060

6161
# Install runc, containerd, tini and docker-proxy
6262
# Please edit hack/dockerfile/install-binaries.sh to update them.
63+
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
6364
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
6465
RUN /tmp/install-binaries.sh runc containerd tini proxy
6566

‎api/types/types.go

+11
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ type Version struct {
150150
BuildTime string `json:",omitempty"`
151151
}
152152

153+
// Commit records a external tool actual commit id version along the
154+
// one expect by dockerd as set at build time
155+
type Commit struct {
156+
ID string
157+
Expected string
158+
}
159+
153160
// InfoBase contains the base response of Remote API:
154161
// GET "/info"
155162
type InfoBase struct {
@@ -207,6 +214,10 @@ type InfoBase struct {
207214
// running containers are detected
208215
LiveRestoreEnabled bool
209216
Isolation container.Isolation
217+
InitBinary string
218+
ContainerdCommit Commit
219+
RuncCommit Commit
220+
InitCommit Commit
210221
}
211222

212223
// SecurityOpt holds key/value pair about a security option

‎cli/command/system/info.go

+16
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,22 @@ func prettyPrintInfo(dockerCli *command.DockerCli, info types.Info) error {
143143
}
144144

145145
if info.OSType == "linux" {
146+
fmt.Fprintf(dockerCli.Out(), "Init Binary: %v\n", info.InitBinary)
147+
148+
for _, ci := range []struct {
149+
Name string
150+
Commit types.Commit
151+
}{
152+
{"containerd", info.ContainerdCommit},
153+
{"runc", info.RuncCommit},
154+
{"init", info.InitCommit},
155+
} {
156+
fmt.Fprintf(dockerCli.Out(), "%s version: %s", ci.Name, ci.Commit.ID)
157+
if ci.Commit.ID != ci.Commit.Expected {
158+
fmt.Fprintf(dockerCli.Out(), " (expected: %s)", ci.Commit.Expected)
159+
}
160+
fmt.Fprintf(dockerCli.Out(), "\n")
161+
}
146162
if len(info.SecurityOptions) != 0 {
147163
fmt.Fprintf(dockerCli.Out(), "Security Options:\n")
148164
for _, o := range info.SecurityOptions {

‎daemon/config_common_unix.go

+10
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,13 @@ func (config *Config) GetAllRuntimes() map[string]types.Runtime {
7878
func (config *Config) GetExecRoot() string {
7979
return config.ExecRoot
8080
}
81+
82+
// GetInitPath returns the configure docker-init path
83+
func (config *Config) GetInitPath() string {
84+
config.reloadLock.Lock()
85+
defer config.reloadLock.Unlock()
86+
if config.InitPath != "" {
87+
return config.InitPath
88+
}
89+
return DefaultInitBinary
90+
}

‎daemon/config_windows.go

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ func (config *Config) GetRuntime(name string) *types.Runtime {
4646
return nil
4747
}
4848

49+
// GetInitPath returns the configure docker-init path
50+
func (config *Config) GetInitPath() string {
51+
return ""
52+
}
53+
4954
// GetDefaultRuntimeName returns the current default runtime
5055
func (config *Config) GetDefaultRuntimeName() string {
5156
return stockRuntimeName

‎daemon/daemon.go

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ var (
6666
// containerd if none is specified
6767
DefaultRuntimeBinary = "docker-runc"
6868

69+
// DefaultInitBinary is the name of the default init binary
70+
DefaultInitBinary = "docker-init"
71+
6972
errSystemNotSupported = fmt.Errorf("The Docker daemon is not supported on this platform.")
7073
)
7174

‎daemon/info.go

+44
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package daemon
22

33
import (
4+
"context"
45
"os"
6+
"os/exec"
57
"runtime"
8+
"strings"
69
"sync/atomic"
710
"time"
811

@@ -147,6 +150,47 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
147150
v.CPUSet = sysInfo.Cpuset
148151
v.Runtimes = daemon.configStore.GetAllRuntimes()
149152
v.DefaultRuntime = daemon.configStore.GetDefaultRuntimeName()
153+
v.InitBinary = daemon.configStore.GetInitPath()
154+
155+
v.ContainerdCommit.Expected = dockerversion.ContainerdCommitID
156+
if sv, err := daemon.containerd.GetServerVersion(context.Background()); err == nil {
157+
v.ContainerdCommit.ID = sv.Revision
158+
} else {
159+
logrus.Warnf("failed to retrieve containerd version: %v", err)
160+
v.ContainerdCommit.ID = "N/A"
161+
}
162+
163+
v.RuncCommit.Expected = dockerversion.RuncCommitID
164+
if rv, err := exec.Command(DefaultRuntimeBinary, "--version").Output(); err == nil {
165+
parts := strings.Split(strings.TrimSpace(string(rv)), "\n")
166+
if len(parts) == 3 {
167+
parts = strings.Split(parts[1], ": ")
168+
if len(parts) == 2 {
169+
v.RuncCommit.ID = strings.TrimSpace(parts[1])
170+
}
171+
}
172+
} else {
173+
logrus.Warnf("failed to retrieve %s version: %v", DefaultRuntimeBinary, err)
174+
v.RuncCommit.ID = "N/A"
175+
}
176+
if v.RuncCommit.ID == "" {
177+
logrus.Warnf("failed to retrieve %s version: unknown output format", DefaultRuntimeBinary)
178+
v.RuncCommit.ID = "N/A"
179+
}
180+
181+
v.InitCommit.Expected = dockerversion.InitCommitID
182+
if rv, err := exec.Command(DefaultInitBinary, "--version").Output(); err == nil {
183+
parts := strings.Split(string(rv), " ")
184+
if len(parts) == 3 {
185+
v.InitCommit.ID = strings.TrimSpace(parts[2])
186+
} else {
187+
logrus.Warnf("failed to retrieve %s version: unknown output format", DefaultInitBinary)
188+
v.InitCommit.ID = "N/A"
189+
}
190+
} else {
191+
logrus.Warnf("failed to retrieve %s version", DefaultInitBinary)
192+
v.InitCommit.ID = "N/A"
193+
}
150194
}
151195

152196
hostname := ""

‎daemon/oci_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ func (daemon *Daemon) populateCommonSpec(s *specs.Spec, c *container.Container)
596596
s.Process.Args = append([]string{"/dev/init", c.Path}, c.Args...)
597597
var path string
598598
if daemon.configStore.InitPath == "" && c.HostConfig.InitPath == "" {
599-
path, err = exec.LookPath("docker-init")
599+
path, err = exec.LookPath(DefaultInitBinary)
600600
if err != nil {
601601
return err
602602
}

‎hack/dockerfile/binaries-commits

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
TOMLV_COMMIT=9baf8a8a9f2ed20a8e54160840c492f937eeaf9a
4+
RUNC_COMMIT=ac031b5bf1cc92239461125f4c1ffb760522bbf2
5+
CONTAINERD_COMMIT=8517738ba4b82aff5662c97ca4627e7e4d03b531
6+
TINI_COMMIT=v0.13.0
7+
LIBNETWORK_COMMIT=0f534354b813003a754606689722fe253101bc4e
8+
VNDR_COMMIT=f56bd4504b4fad07a357913687fb652ee54bb3b0

‎hack/dockerfile/install-binaries.sh

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
set -e
33
set -x
44

5-
TOMLV_COMMIT=9baf8a8a9f2ed20a8e54160840c492f937eeaf9a
6-
RUNC_COMMIT=ac031b5bf1cc92239461125f4c1ffb760522bbf2
7-
CONTAINERD_COMMIT=8517738ba4b82aff5662c97ca4627e7e4d03b531
8-
TINI_COMMIT=v0.13.0
9-
LIBNETWORK_COMMIT=0f534354b813003a754606689722fe253101bc4e
10-
VNDR_COMMIT=f56bd4504b4fad07a357913687fb652ee54bb3b0
5+
. $(dirname "$0")/binaries-commits
116

127
RM_GOPATH=0
138

‎hack/make/.go-autogen

+11-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
rm -rf autogen
44

5+
source hack/dockerfile/binaries-commits
6+
57
cat > dockerversion/version_autogen.go <<DVEOF
68
// +build autogen
79
@@ -11,12 +13,16 @@ package dockerversion
1113
// Default build-time variable for library-import.
1214
// This file is overridden on build with build-time informations.
1315
const (
14-
GitCommit string = "$GITCOMMIT"
15-
Version string = "$VERSION"
16-
BuildTime string = "$BUILDTIME"
17-
IAmStatic string = "${IAMSTATIC:-true}"
16+
GitCommit string = "$GITCOMMIT"
17+
Version string = "$VERSION"
18+
BuildTime string = "$BUILDTIME"
19+
IAmStatic string = "${IAMSTATIC:-true}"
20+
ContainerdCommitID string = "${CONTAINERD_COMMIT}"
21+
RuncCommitID string = "${RUNC_COMMIT}"
22+
InitCommitID string = "${TINI_COMMIT}"
1823
)
19-
// AUTOGENERATED FILE; see $BASH_SOURCE
24+
25+
// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
2026
DVEOF
2127

2228
# Compile the Windows resources into the sources

‎integration-cli/docker_cli_info_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
3636
}
3737

3838
if daemonPlatform == "linux" {
39-
stringsToCheck = append(stringsToCheck, "Security Options:")
39+
stringsToCheck = append(stringsToCheck, "Init Binary:", "Security Options:", "containerd version:", "runc version:", "init version:")
4040
}
4141

4242
if DaemonIsLinux.Condition() {

‎libcontainerd/client_linux.go

+14
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ type client struct {
2828
liveRestore bool
2929
}
3030

31+
// GetServerVersion returns the connected server version information
32+
func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error) {
33+
resp, err := clnt.remote.apiClient.GetServerVersion(ctx, &containerd.GetServerVersionRequest{})
34+
if err != nil {
35+
return nil, err
36+
}
37+
38+
sv := &ServerVersion{
39+
GetServerVersionResponse: *resp,
40+
}
41+
42+
return sv, nil
43+
}
44+
3145
// AddProcess is the handler for adding a process to an already running
3246
// container. It's called through docker exec. It returns the system pid of the
3347
// exec'd process.

‎libcontainerd/client_solaris.go

+14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ type client struct {
1212
liveRestore bool
1313
}
1414

15+
// GetServerVersion returns the connected server version information
16+
func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error) {
17+
resp, err := clnt.remote.apiClient.GetServerVersion(ctx, &containerd.GetServerVersionRequest{})
18+
if err != nil {
19+
return nil, err
20+
}
21+
22+
sv := &ServerVersion{
23+
GetServerVersionResponse: *resp,
24+
}
25+
26+
return sv, nil
27+
}
28+
1529
func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, specp Process, attachStdio StdioCallback) (int, error) {
1630
return -1, nil
1731
}

‎libcontainerd/client_windows.go

+4
Original file line numberDiff line numberDiff line change
@@ -614,3 +614,7 @@ func (clnt *client) DeleteCheckpoint(containerID string, checkpointID string, ch
614614
func (clnt *client) ListCheckpoints(containerID string, checkpointDir string) (*Checkpoints, error) {
615615
return nil, errors.New("Windows: Containers do not support checkpoints")
616616
}
617+
618+
func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error) {
619+
return &ServerVersion{}, nil
620+
}

‎libcontainerd/types.go

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package libcontainerd
33
import (
44
"io"
55

6+
containerd "github.com/docker/containerd/api/grpc/types"
67
"github.com/opencontainers/runtime-spec/specs-go"
78
"golang.org/x/net/context"
89
)
@@ -33,6 +34,7 @@ type Backend interface {
3334

3435
// Client provides access to containerd features.
3536
type Client interface {
37+
GetServerVersion(ctx context.Context) (*ServerVersion, error)
3638
Create(containerID string, checkpoint string, checkpointDir string, spec specs.Spec, attachStdio StdioCallback, options ...CreateOption) error
3739
Signal(containerID string, sig int) error
3840
SignalProcess(containerID string, processFriendlyName string, sig int) error
@@ -65,3 +67,9 @@ type IOPipe struct {
6567
Stderr io.ReadCloser
6668
Terminal bool // Whether stderr is connected on Windows
6769
}
70+
71+
// ServerVersion contains version information as retrieved from the
72+
// server
73+
type ServerVersion struct {
74+
containerd.GetServerVersionResponse
75+
}

0 commit comments

Comments
 (0)
Please sign in to comment.