handle error when getting hostname in info api

Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: a1c950913f251bf1c8115a549ecb0b5174cd05de
Component: engine
This commit is contained in:
allencloud
2016-05-07 08:51:52 +08:00
parent cf5ef9f29e
commit a9e9649921
+6 -2
View File
@@ -133,9 +133,13 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
v.CPUSet = sysInfo.Cpuset
}
if hostname, err := os.Hostname(); err == nil {
v.Name = hostname
hostname := ""
if hn, err := os.Hostname(); err != nil {
logrus.Warnf("Could not get hostname: %v", err)
} else {
hostname = hn
}
v.Name = hostname
return v, nil
}