Skip to content

Commit

Permalink
Stop the containers storage if it fails to start, fixes issue #844
Browse files Browse the repository at this point in the history
Signed-off-by: René Jochum <rene@jochums.at>
  • Loading branch information
jochumdev committed Aug 1, 2015
1 parent f832129 commit 61e47da
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lxd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,23 +505,27 @@ func (c *containerLXD) Start() error {

f, err := ioutil.TempFile("", "lxd_lxc_startconfig_")
if err != nil {
c.Storage.ContainerStop(c)
return err
}
configPath := f.Name()
if err = f.Chmod(0600); err != nil {
f.Close()
os.Remove(configPath)
c.Storage.ContainerStop(c)
return err
}
f.Close()

err = c.c.SaveConfigFile(configPath)
if err != nil {
c.Storage.ContainerStop(c)
return err
}

err = c.TemplateApply("start")
if err != nil {
c.Storage.ContainerStop(c)
return err
}

Expand All @@ -533,6 +537,7 @@ func (c *containerLXD) Start() error {
configPath).Run()

if err != nil {
c.Storage.ContainerStop(c)
err = fmt.Errorf(
"Error calling 'lxd forkstart %s %s %s': err='%v'",
c.name,
Expand Down

0 comments on commit 61e47da

Please sign in to comment.