From cea82bf05b9271a0634a8794b7bac24aa0b892f7 Mon Sep 17 00:00:00 2001 From: Lyon Hill Date: Thu, 1 Jun 2017 09:37:50 -0600 Subject: [PATCH] fix an idempotency problem when we left cruft after a faild build --- processors/code/setup.go | 5 +++++ processors/component/setup.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/processors/code/setup.go b/processors/code/setup.go index 299dfcec..9d7d18f9 100644 --- a/processors/code/setup.go +++ b/processors/code/setup.go @@ -62,6 +62,11 @@ func Setup(appModel *models.App, componentModel *models.Component, warehouseConf // create docker container config := container_generator.ComponentConfig(componentModel) + // remove any container that may have been created with this name befor + // this can happen if the process is killed after the + // container was created but before our db model was saved + docker.ContainerRemove(config.Name) + container, err := docker.CreateContainer(config) if err != nil { lumber.Error("code:Setup:createContainer:docker.CreateContainer(%+v)", config) diff --git a/processors/component/setup.go b/processors/component/setup.go index f060f2b3..6ee9bada 100644 --- a/processors/component/setup.go +++ b/processors/component/setup.go @@ -74,6 +74,12 @@ func Setup(appModel *models.App, componentModel *models.Component) error { // start the container display.StartTask("Starting docker container") config := container_generator.ComponentConfig(componentModel) + + // remove any container that may have been created with this name befor + // this can happen if the process is killed after the + // container was created but before our db model was saved + docker.ContainerRemove(config.Name) + container, err := docker.CreateContainer(config) if err != nil { lumber.Error("component:Setup:docker.CreateContainer(%+v): %s", config, err.Error())