Skip to content

Commit

Permalink
Add expected 3rd party binaries commit ids to info
Browse files Browse the repository at this point in the history
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
  • Loading branch information
mlaventure committed Nov 9, 2016
1 parent 5125484 commit 2790ac6
Show file tree
Hide file tree
Showing 21 changed files with 157 additions and 13 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \

# Install tomlv, vndr, runc, containerd, tini, docker-proxy
# Please edit hack/dockerfile/install-binaries.sh to update them.
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy

Expand Down
1 change: 1 addition & 0 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \

# Install tomlv, vndr, runc, containerd, tini, docker-proxy
# Please edit hack/dockerfile/install-binaries.sh to update them.
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy

Expand Down
1 change: 1 addition & 0 deletions Dockerfile.armhf
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \

# Install tomlv, vndr, runc, containerd, tini, docker-proxy
# Please edit hack/dockerfile/install-binaries.sh to update them.
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy

Expand Down
1 change: 1 addition & 0 deletions Dockerfile.ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \

# Install tomlv, vndr, runc, containerd, tini, docker-proxy
# Please edit hack/dockerfile/install-binaries.sh to update them.
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy

Expand Down
1 change: 1 addition & 0 deletions Dockerfile.s390x
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \

# Install tomlv, vndr, runc, containerd, tini, docker-proxy
# Please edit hack/dockerfile/install-binaries.sh to update them.
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy

Expand Down
1 change: 1 addition & 0 deletions Dockerfile.simple
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ENV CGO_LDFLAGS -L/lib

# Install runc, containerd, tini and docker-proxy
# Please edit hack/dockerfile/install-binaries.sh to update them.
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
RUN /tmp/install-binaries.sh runc containerd tini proxy

Expand Down
11 changes: 11 additions & 0 deletions api/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ type Version struct {
BuildTime string `json:",omitempty"`
}

// Commit records a external tool actual commit id version along the
// one expect by dockerd as set at build time
type Commit struct {
ID string
Expected string
}

// InfoBase contains the base response of Remote API:
// GET "/info"
type InfoBase struct {
Expand Down Expand Up @@ -207,6 +214,10 @@ type InfoBase struct {
// running containers are detected
LiveRestoreEnabled bool
Isolation container.Isolation
InitBinary string
ContainerdCommit Commit
RuncCommit Commit
InitCommit Commit
}

// SecurityOpt holds key/value pair about a security option
Expand Down
16 changes: 16 additions & 0 deletions cli/command/system/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,22 @@ func prettyPrintInfo(dockerCli *command.DockerCli, info types.Info) error {
}

if info.OSType == "linux" {
fmt.Fprintf(dockerCli.Out(), "Init Binary: %v\n", info.InitBinary)

for _, ci := range []struct {
Name string
Commit types.Commit
}{
{"containerd", info.ContainerdCommit},
{"runc", info.RuncCommit},
{"init", info.InitCommit},
} {
fmt.Fprintf(dockerCli.Out(), "%s version: %s", ci.Name, ci.Commit.ID)
if ci.Commit.ID != ci.Commit.Expected {
fmt.Fprintf(dockerCli.Out(), " (expected: %s)", ci.Commit.Expected)
}
fmt.Fprintf(dockerCli.Out(), "\n")
}
if len(info.SecurityOptions) != 0 {
fmt.Fprintf(dockerCli.Out(), "Security Options:\n")
for _, o := range info.SecurityOptions {
Expand Down
10 changes: 10 additions & 0 deletions daemon/config_common_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,13 @@ func (config *Config) GetAllRuntimes() map[string]types.Runtime {
func (config *Config) GetExecRoot() string {
return config.ExecRoot
}

// GetInitPath returns the configure docker-init path
func (config *Config) GetInitPath() string {
config.reloadLock.Lock()
defer config.reloadLock.Unlock()
if config.InitPath != "" {
return config.InitPath
}
return DefaultInitBinary
}
5 changes: 5 additions & 0 deletions daemon/config_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func (config *Config) GetRuntime(name string) *types.Runtime {
return nil
}

// GetInitPath returns the configure docker-init path
func (config *Config) GetInitPath() string {
return ""
}

// GetDefaultRuntimeName returns the current default runtime
func (config *Config) GetDefaultRuntimeName() string {
return stockRuntimeName
Expand Down
3 changes: 3 additions & 0 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ var (
// containerd if none is specified
DefaultRuntimeBinary = "docker-runc"

// DefaultInitBinary is the name of the default init binary
DefaultInitBinary = "docker-init"

errSystemNotSupported = fmt.Errorf("The Docker daemon is not supported on this platform.")
)

Expand Down
44 changes: 44 additions & 0 deletions daemon/info.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package daemon

import (
"context"
"os"
"os/exec"
"runtime"
"strings"
"sync/atomic"
"time"

Expand Down Expand Up @@ -147,6 +150,47 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
v.CPUSet = sysInfo.Cpuset
v.Runtimes = daemon.configStore.GetAllRuntimes()
v.DefaultRuntime = daemon.configStore.GetDefaultRuntimeName()
v.InitBinary = daemon.configStore.GetInitPath()

v.ContainerdCommit.Expected = dockerversion.ContainerdCommitID
if sv, err := daemon.containerd.GetServerVersion(context.Background()); err == nil {
v.ContainerdCommit.ID = sv.Revision
} else {
logrus.Warnf("failed to retrieve containerd version: %v", err)
v.ContainerdCommit.ID = "N/A"
}

v.RuncCommit.Expected = dockerversion.RuncCommitID
if rv, err := exec.Command(DefaultRuntimeBinary, "--version").Output(); err == nil {
parts := strings.Split(strings.TrimSpace(string(rv)), "\n")
if len(parts) == 3 {
parts = strings.Split(parts[1], ": ")
if len(parts) == 2 {
v.RuncCommit.ID = strings.TrimSpace(parts[1])
}
}
} else {
logrus.Warnf("failed to retrieve %s version: %v", DefaultRuntimeBinary, err)
v.RuncCommit.ID = "N/A"
}
if v.RuncCommit.ID == "" {
logrus.Warnf("failed to retrieve %s version: unknown output format", DefaultRuntimeBinary)
v.RuncCommit.ID = "N/A"
}

v.InitCommit.Expected = dockerversion.InitCommitID
if rv, err := exec.Command(DefaultInitBinary, "--version").Output(); err == nil {
parts := strings.Split(string(rv), " ")
if len(parts) == 3 {
v.InitCommit.ID = strings.TrimSpace(parts[2])
} else {
logrus.Warnf("failed to retrieve %s version: unknown output format", DefaultInitBinary)
v.InitCommit.ID = "N/A"
}
} else {
logrus.Warnf("failed to retrieve %s version", DefaultInitBinary)
v.InitCommit.ID = "N/A"
}
}

hostname := ""
Expand Down
2 changes: 1 addition & 1 deletion daemon/oci_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ func (daemon *Daemon) populateCommonSpec(s *specs.Spec, c *container.Container)
s.Process.Args = append([]string{"/dev/init", c.Path}, c.Args...)
var path string
if daemon.configStore.InitPath == "" && c.HostConfig.InitPath == "" {
path, err = exec.LookPath("docker-init")
path, err = exec.LookPath(DefaultInitBinary)
if err != nil {
return err
}
Expand Down
8 changes: 8 additions & 0 deletions hack/dockerfile/binaries-commits
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

TOMLV_COMMIT=9baf8a8a9f2ed20a8e54160840c492f937eeaf9a
RUNC_COMMIT=ac031b5bf1cc92239461125f4c1ffb760522bbf2
CONTAINERD_COMMIT=8517738ba4b82aff5662c97ca4627e7e4d03b531
TINI_COMMIT=v0.13.0
LIBNETWORK_COMMIT=0f534354b813003a754606689722fe253101bc4e
VNDR_COMMIT=f56bd4504b4fad07a357913687fb652ee54bb3b0
7 changes: 1 addition & 6 deletions hack/dockerfile/install-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
set -e
set -x

TOMLV_COMMIT=9baf8a8a9f2ed20a8e54160840c492f937eeaf9a
RUNC_COMMIT=ac031b5bf1cc92239461125f4c1ffb760522bbf2
CONTAINERD_COMMIT=8517738ba4b82aff5662c97ca4627e7e4d03b531
TINI_COMMIT=v0.13.0
LIBNETWORK_COMMIT=0f534354b813003a754606689722fe253101bc4e
VNDR_COMMIT=f56bd4504b4fad07a357913687fb652ee54bb3b0
. $(dirname "$0")/binaries-commits

RM_GOPATH=0

Expand Down
16 changes: 11 additions & 5 deletions hack/make/.go-autogen
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

rm -rf autogen

source hack/dockerfile/binaries-commits

cat > dockerversion/version_autogen.go <<DVEOF
// +build autogen
Expand All @@ -11,12 +13,16 @@ package dockerversion
// Default build-time variable for library-import.
// This file is overridden on build with build-time informations.
const (
GitCommit string = "$GITCOMMIT"
Version string = "$VERSION"
BuildTime string = "$BUILDTIME"
IAmStatic string = "${IAMSTATIC:-true}"
GitCommit string = "$GITCOMMIT"
Version string = "$VERSION"
BuildTime string = "$BUILDTIME"
IAmStatic string = "${IAMSTATIC:-true}"
ContainerdCommitID string = "${CONTAINERD_COMMIT}"
RuncCommitID string = "${RUNC_COMMIT}"
InitCommitID string = "${TINI_COMMIT}"
)
// AUTOGENERATED FILE; see $BASH_SOURCE
// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
DVEOF

# Compile the Windows resources into the sources
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
}

if daemonPlatform == "linux" {
stringsToCheck = append(stringsToCheck, "Security Options:")
stringsToCheck = append(stringsToCheck, "Init Binary:", "Security Options:", "containerd version:", "runc version:", "init version:")
}

if DaemonIsLinux.Condition() {
Expand Down
14 changes: 14 additions & 0 deletions libcontainerd/client_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ type client struct {
liveRestore bool
}

// GetServerVersion returns the connected server version information
func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error) {
resp, err := clnt.remote.apiClient.GetServerVersion(ctx, &containerd.GetServerVersionRequest{})
if err != nil {
return nil, err
}

sv := &ServerVersion{
GetServerVersionResponse: *resp,
}

return sv, nil
}

// AddProcess is the handler for adding a process to an already running
// container. It's called through docker exec. It returns the system pid of the
// exec'd process.
Expand Down
14 changes: 14 additions & 0 deletions libcontainerd/client_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ type client struct {
liveRestore bool
}

// GetServerVersion returns the connected server version information
func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error) {
resp, err := clnt.remote.apiClient.GetServerVersion(ctx, &containerd.GetServerVersionRequest{})
if err != nil {
return nil, err
}

sv := &ServerVersion{
GetServerVersionResponse: *resp,
}

return sv, nil
}

func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendlyName string, specp Process, attachStdio StdioCallback) (int, error) {
return -1, nil
}
Expand Down
4 changes: 4 additions & 0 deletions libcontainerd/client_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,3 +614,7 @@ func (clnt *client) DeleteCheckpoint(containerID string, checkpointID string, ch
func (clnt *client) ListCheckpoints(containerID string, checkpointDir string) (*Checkpoints, error) {
return nil, errors.New("Windows: Containers do not support checkpoints")
}

func (clnt *client) GetServerVersion(ctx context.Context) (*ServerVersion, error) {
return &ServerVersion{}, nil
}
8 changes: 8 additions & 0 deletions libcontainerd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package libcontainerd
import (
"io"

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

// Client provides access to containerd features.
type Client interface {
GetServerVersion(ctx context.Context) (*ServerVersion, error)
Create(containerID string, checkpoint string, checkpointDir string, spec specs.Spec, attachStdio StdioCallback, options ...CreateOption) error
Signal(containerID string, sig int) error
SignalProcess(containerID string, processFriendlyName string, sig int) error
Expand Down Expand Up @@ -65,3 +67,9 @@ type IOPipe struct {
Stderr io.ReadCloser
Terminal bool // Whether stderr is connected on Windows
}

// ServerVersion contains version information as retrieved from the
// server
type ServerVersion struct {
containerd.GetServerVersionResponse
}

0 comments on commit 2790ac6

Please sign in to comment.