propellor spin
This commit is contained in:
parent
d1dd4f44c4
commit
2be1255b89
|
@ -314,7 +314,7 @@ runningContainer :: ContainerId -> Image -> [RunParam] -> Property
|
||||||
runningContainer cid@(ContainerId hn cn) image runps = containerDesc cid $ property "running" $ do
|
runningContainer cid@(ContainerId hn cn) image runps = containerDesc cid $ property "running" $ do
|
||||||
l <- liftIO $ listContainers RunningContainers
|
l <- liftIO $ listContainers RunningContainers
|
||||||
if cid `elem` l
|
if cid `elem` l
|
||||||
then checkident
|
then checkident =<< liftIO (getrunningident simpleShClient)
|
||||||
else ifM (liftIO $ elem cid <$> listContainers AllContainers)
|
else ifM (liftIO $ elem cid <$> listContainers AllContainers)
|
||||||
( do
|
( do
|
||||||
-- The container exists, but is not
|
-- The container exists, but is not
|
||||||
|
@ -322,7 +322,10 @@ runningContainer cid@(ContainerId hn cn) image runps = containerDesc cid $ prope
|
||||||
-- changed, but we cannot tell without
|
-- changed, but we cannot tell without
|
||||||
-- starting it up first.
|
-- starting it up first.
|
||||||
void $ liftIO $ startContainer cid
|
void $ liftIO $ startContainer cid
|
||||||
checkident
|
-- It can take a while for the container to
|
||||||
|
-- start up enough to get its ident, so
|
||||||
|
-- retry for up to 60 seconds.
|
||||||
|
checkident =<< liftIO (getrunningident (simpleShClientRetry 60))
|
||||||
, go image
|
, go image
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
@ -331,21 +334,18 @@ runningContainer cid@(ContainerId hn cn) image runps = containerDesc cid $ prope
|
||||||
-- Check if the ident has changed; if so the
|
-- Check if the ident has changed; if so the
|
||||||
-- parameters of the container differ and it must
|
-- parameters of the container differ and it must
|
||||||
-- be restarted.
|
-- be restarted.
|
||||||
checkident = do
|
checkident runningident
|
||||||
runningident <- liftIO $ getrunningident
|
| runningident == Just ident = noChange
|
||||||
if runningident == Just ident
|
| otherwise = do
|
||||||
then noChange
|
void $ liftIO $ stopContainer cid
|
||||||
else do
|
restartcontainer
|
||||||
void $ liftIO $ stopContainer cid
|
|
||||||
restartcontainer
|
|
||||||
|
|
||||||
restartcontainer = do
|
restartcontainer = do
|
||||||
oldimage <- liftIO $ fromMaybe image <$> commitContainer cid
|
oldimage <- liftIO $ fromMaybe image <$> commitContainer cid
|
||||||
void $ liftIO $ removeContainer cid
|
void $ liftIO $ removeContainer cid
|
||||||
go oldimage
|
go oldimage
|
||||||
|
|
||||||
getrunningident :: IO (Maybe ContainerIdent)
|
getrunningident shclient = shclient (namedPipe cid) "cat" [propellorIdent] $ \rs -> do
|
||||||
getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \rs -> do
|
|
||||||
let !v = extractident rs
|
let !v = extractident rs
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue