Skip to content

Commit

Permalink
Fix error state
Browse files Browse the repository at this point in the history
  • Loading branch information
dorianim committed Nov 11, 2021
1 parent 5aa03e7 commit 941c28c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions launcher/internal/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,30 +149,34 @@ func newContainer(image string, containerID string, containerEnv []string, conta

// Launch launches the container
func (c *LaunchableContainer) Launch() error {

var err error
c.setState(LaunchingState)
c.isLaunching = true

defer func() {
c.isLaunching = false
if err != nil {
c.setState(StoppingState)
}
}()

if err := c.Stop(); err != nil {
if err = c.Stop(); err != nil {
return err
}

if err := c.Remove(); err != nil {
if err = c.Remove(); err != nil {
return err
}

if err := c.Pull(); err != nil {
if err = c.Pull(); err != nil {
return err
}

if err := c.Start(); err != nil {
if err = c.Start(); err != nil {
return err
}

if err := c.Attach(); err != nil {
if err = c.Attach(); err != nil {
return err
}

Expand Down

0 comments on commit 941c28c

Please sign in to comment.