From a2cfcf5177aceaf2c777d506fd32d3d176934b48 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 5 May 2014 23:23:14 +0000 Subject: [PATCH] propagate errors write Docker-DCO-1.1-Signed-off-by: Victor Vieux (github: vieux) Upstream-commit: 55f3e72d7f6b996c0874d402c95f4b8c9a7d80d9 Component: engine --- components/engine/daemon/container.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/engine/daemon/container.go b/components/engine/daemon/container.go index 2a17ff1ece..20a320307b 100644 --- a/components/engine/daemon/container.go +++ b/components/engine/daemon/container.go @@ -487,18 +487,18 @@ func (container *Container) StderrLogPipe() io.ReadCloser { return utils.NewBufReader(reader) } -func (container *Container) buildHostname() { +func (container *Container) buildHostnameFile() error { container.HostnamePath = path.Join(container.root, "hostname") - if container.Config.Domainname != "" { - ioutil.WriteFile(container.HostnamePath, []byte(fmt.Sprintf("%s.%s\n", container.Config.Hostname, container.Config.Domainname)), 0644) - } else { - ioutil.WriteFile(container.HostnamePath, []byte(container.Config.Hostname+"\n"), 0644) + return ioutil.WriteFile(container.HostnamePath, []byte(fmt.Sprintf("%s.%s\n", container.Config.Hostname, container.Config.Domainname)), 0644) } + return ioutil.WriteFile(container.HostnamePath, []byte(container.Config.Hostname+"\n"), 0644) } func (container *Container) buildHostnameAndHostsFiles(IP string) error { - container.buildHostname() + if err := container.buildHostnameFile(); err != nil { + return err + } container.HostsPath = path.Join(container.root, "hosts") return etchosts.Build(container.HostsPath, IP, container.Config.Hostname, container.Config.Domainname) @@ -998,7 +998,7 @@ func (container *Container) initializeNetworking() error { } container.HostsPath = "/etc/hosts" - container.buildHostname() + return container.buildHostnameFile() } else if container.hostConfig.NetworkMode.IsContainer() { // we need to get the hosts files from the container to join nc, err := container.getNetworkedContainer()