1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix version detection for docker-init

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2016-11-11 08:02:44 -08:00
parent 0bb6bac793
commit 69f0402585

View file

@ -169,22 +169,35 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
v.RuncCommit.ID = strings.TrimSpace(parts[1])
}
}
} else {
logrus.Warnf("failed to retrieve %s version: %v", DefaultRuntimeBinary, err)
if v.RuncCommit.ID == "" {
logrus.Warnf("failed to retrieve %s version: unknown output format: %s", DefaultRuntimeBinary, string(rv))
v.RuncCommit.ID = "N/A"
}
if v.RuncCommit.ID == "" {
logrus.Warnf("failed to retrieve %s version: unknown output format", DefaultRuntimeBinary)
} else {
logrus.Warnf("failed to retrieve %s version: %v", DefaultRuntimeBinary, err)
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])
parts := strings.Split(strings.TrimSpace(string(rv)), " - ")
if len(parts) == 2 {
if dockerversion.InitCommitID[0] == 'v' {
vs := strings.TrimPrefix(parts[0], "tini version ")
v.InitCommit.ID = "v" + vs
} else {
logrus.Warnf("failed to retrieve %s version: unknown output format", DefaultInitBinary)
// Get the sha1
gitParts := strings.Split(parts[1], ".")
if len(gitParts) == 2 && gitParts[0] == "git" {
v.InitCommit.ID = gitParts[1]
v.InitCommit.Expected = dockerversion.InitCommitID[0:len(gitParts[1])]
}
}
}
if v.InitCommit.ID == "" {
logrus.Warnf("failed to retrieve %s version: unknown output format: %s", DefaultInitBinary, string(rv))
v.InitCommit.ID = "N/A"
}
} else {