summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2014-10-10 14:25:47 -0400
committerJoey Hess <joey@kitenet.net>2014-10-10 14:25:47 -0400
commitadbc70b768068657ed2c1942d8eb998f784c6f70 (patch)
tree9834475f5d2557d3687f4fd2d1ae381bfb2b12f3
parent498769e232091d18f2b0dbd8f8392b3abbebf1e7 (diff)
parent4182cae2351e1251bdb22eeb63a4402bc51cc2de (diff)
Merge branch 'joeyconfig'debian/0.9.0
-rw-r--r--config-joey.hs2
-rw-r--r--debian/changelog1
-rw-r--r--src/Propellor/Property/Docker.hs37
3 files changed, 26 insertions, 14 deletions
diff --git a/config-joey.hs b/config-joey.hs
index 2e0a757e..3bf01114 100644
--- a/config-joey.hs
+++ b/config-joey.hs
@@ -53,6 +53,7 @@ darkstar = host "darkstar.kitenet.net"
& Apt.buildDep ["git-annex"] `period` Daily
& Docker.configured
! Docker.docked hosts "android-git-annex"
+ ! Docker.docked hosts "webserver"
clam :: Host
clam = standardSystem "clam.kitenet.net" Unstable "amd64"
@@ -362,7 +363,6 @@ standardContainer :: Docker.ContainerName -> DebianSuite -> Architecture -> Host
standardContainer name suite arch = Docker.container name (dockerImage system)
& os system
& Apt.stdSourcesList `onChange` Apt.upgrade
- & Apt.installed ["systemd"]
& Apt.unattendedUpgrades
& Apt.cacheCleaned
& Docker.tweaked
diff --git a/debian/changelog b/debian/changelog
index 2df7a57f..012826bd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,7 @@ propellor (0.9.0) unstable; urgency=medium
immediate upgrades to the next stable release.
* debCdn switched from cdn.debian.net to http.debian.net, which seems to be
better managed now.
+ * Docker: Avoid committing container every time it's started up.
-- Joey Hess <joeyh@debian.org> Fri, 10 Oct 2014 11:37:45 -0400
diff --git a/src/Propellor/Property/Docker.hs b/src/Propellor/Property/Docker.hs
index f441197e..8c2f3701 100644
--- a/src/Propellor/Property/Docker.hs
+++ b/src/Propellor/Property/Docker.hs
@@ -314,30 +314,38 @@ runningContainer :: ContainerId -> Image -> [RunParam] -> Property
runningContainer cid@(ContainerId hn cn) image runps = containerDesc cid $ property "running" $ do
l <- liftIO $ listContainers RunningContainers
if cid `elem` l
- then do
- -- Check if the ident has changed; if so the
- -- parameters of the container differ and it must
- -- be restarted.
- runningident <- liftIO $ getrunningident
- if runningident == Just ident
- then noChange
- else do
- void $ liftIO $ stopContainer cid
- restartcontainer
+ then checkident =<< liftIO (getrunningident simpleShClient)
else ifM (liftIO $ elem cid <$> listContainers AllContainers)
- ( restartcontainer
+ ( do
+ -- The container exists, but is not
+ -- running. Its parameters may have
+ -- changed, but we cannot tell without
+ -- starting it up first.
+ void $ liftIO $ startContainer cid
+ -- 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
)
where
ident = ContainerIdent image hn cn runps
+ -- Check if the ident has changed; if so the
+ -- parameters of the container differ and it must
+ -- be restarted.
+ checkident runningident
+ | runningident == Just ident = noChange
+ | otherwise = do
+ void $ liftIO $ stopContainer cid
+ restartcontainer
+
restartcontainer = do
oldimage <- liftIO $ fromMaybe image <$> commitContainer cid
void $ liftIO $ removeContainer cid
go oldimage
- getrunningident :: IO (Maybe ContainerIdent)
- getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \rs -> do
+ getrunningident shclient = shclient (namedPipe cid) "cat" [propellorIdent] $ \rs -> do
let !v = extractident rs
return v
@@ -433,6 +441,9 @@ provisionContainer cid = containerDesc cid $ property "provisioned" $ liftIO $ d
stopContainer :: ContainerId -> IO Bool
stopContainer cid = boolSystem dockercmd [Param "stop", Param $ fromContainerId cid ]
+startContainer :: ContainerId -> IO Bool
+startContainer cid = boolSystem dockercmd [Param "start", Param $ fromContainerId cid ]
+
stoppedContainer :: ContainerId -> Property
stoppedContainer cid = containerDesc cid $ property desc $
ifM (liftIO $ elem cid <$> listContainers RunningContainers)