handle error when getting hostname in info api

Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
allencloud 2016-05-03 15:26:32 +08:00
parent 9a9ebc7f85
commit a1c950913f

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
}