summaryrefslogtreecommitdiff
path: root/Propellor/Property
diff options
context:
space:
mode:
authorJoey Hess2014-04-04 15:26:16 -0400
committerJoey Hess2014-04-04 15:26:16 -0400
commitb9e7721db0fedbbc6d1d32f54fbf011e0514e9df (patch)
tree396da3958e37fa4bd06b2b6a3cf0635ac2c24b6d /Propellor/Property
parentbbca48d44bdecc7698a7c05a5d2d3f64c925a96e (diff)
propellor spin
Diffstat (limited to 'Propellor/Property')
-rw-r--r--Propellor/Property/Docker.hs19
1 files changed, 14 insertions, 5 deletions
diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs
index 9bdf3e54..bcd27c59 100644
--- a/Propellor/Property/Docker.hs
+++ b/Propellor/Property/Docker.hs
@@ -236,15 +236,24 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci
oldimage <- fromMaybe image <$> commitContainer cid
void $ removeContainer cid
go oldimage
- else go image
+ else do
+ ifM (elem cid <$> listContainers AllContainers)
+ ( do
+ -- Contaner may be stopped, or
+ -- may not exist.
+ void $ stopContainer cid
+ oldimage <- fromMaybe image <$> commitContainer cid
+ void $ removeContainer cid
+ go oldimage
+ , go image
+ )
where
ident = ContainerIdent image hn cn runps
getrunningident :: IO (Maybe ContainerIdent)
- getrunningident = catchDefaultIO Nothing $
- simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \rs -> do
- print (rs, extractident rs)
- return $ extractident rs
+ getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \rs -> do
+ print (rs, extractident rs)
+ return $ extractident rs
extractident :: [Resp] -> Maybe ContainerIdent
extractident = headMaybe . catMaybes . map (readish :: String -> Maybe ContainerIdent) . catMaybes . map getStdout