-- cgit v1.3-2-g0d8e From a3206d45d6fe161091d008d39ec86a2263d95446 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 02:06:19 -0400 Subject: redo a change I lost somewhere fixes ghc spain in i386 container on amd64 host --- Propellor/CmdLine.hs | 2 ++ Propellor/Property/Docker/Shim.hs | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs index a9c61993..d10211f0 100644 --- a/Propellor/CmdLine.hs +++ b/Propellor/CmdLine.hs @@ -11,6 +11,7 @@ import System.PosixCompat import Propellor import qualified Propellor.Property.Docker as Docker +import qualified Propellor.Property.Docker.Shim as DockerShim import Utility.FileMode import Utility.SafeCommand @@ -53,6 +54,7 @@ processCmdLine = go =<< getArgs defaultMain :: [HostName -> Maybe [Property]] -> IO () defaultMain getprops = do + DockerShim.cleanEnv checkDebugMode cmdline <- processCmdLine debug ["command line: ", show cmdline] diff --git a/Propellor/Property/Docker/Shim.hs b/Propellor/Property/Docker/Shim.hs index 01c2b22f..c2f35d0c 100644 --- a/Propellor/Property/Docker/Shim.hs +++ b/Propellor/Property/Docker/Shim.hs @@ -3,7 +3,7 @@ -- -- Note: This is currently Debian specific, due to glibcLibs. -module Propellor.Property.Docker.Shim (setup, file) where +module Propellor.Property.Docker.Shim (setup, cleanEnv, file) where import Propellor import Utility.LinuxMkLibs @@ -44,6 +44,9 @@ setup propellorbin dest = do modifyFileMode shim (addModes executeModes) return shim +cleanEnv :: IO () +cleanEnv = void $ unsetEnv "GCONV_PATH" + file :: FilePath -> FilePath -> FilePath file propellorbin dest = dest takeFileName propellorbin -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e From 5849f43422db95e8219093ff8785a70ba8392dd6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 14:42:07 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 888e76c6..6113a294 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -224,6 +224,7 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci if cid `elem` l then do runningident <- getrunningident + print (runningident, ident2id <$> runningident, ident, ident2id ident) if (ident2id <$> runningident) == Just (ident2id ident) then return NoChange else do -- cgit v1.3-2-g0d8e From d96bc41d068b9f47273fdc9ca2f127d9ebc9d1f9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 14:45:31 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 6113a294..7a605b02 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -224,7 +224,6 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci if cid `elem` l then do runningident <- getrunningident - print (runningident, ident2id <$> runningident, ident, ident2id ident) if (ident2id <$> runningident) == Just (ident2id ident) then return NoChange else do @@ -240,8 +239,10 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci ident = ContainerIdent image hn cn runps getrunningident = catchDefaultIO Nothing $ - simpleShClient (namedPipe cid) "cat" [propellorIdent] $ - pure . headMaybe . catMaybes . map readish . catMaybes . map getStdout + simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \vs -> do + print vs + -- pure . headMaybe . catMaybes . map readish . catMaybes . map getStdout + return Nothing runps = getRunParams $ containerprops ++ -- expose propellor directory inside the container -- cgit v1.3-2-g0d8e From 0b7fb010321ecde043fa1293ef793a3f36cf2ff0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 14:55:34 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 7a605b02..e625a129 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -223,8 +223,12 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci l <- 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 <- getrunningident - if (ident2id <$> runningident) == Just (ident2id ident) + print runningident + if runningident == Just ident then return NoChange else do void $ stopContainer cid @@ -238,11 +242,10 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci where ident = ContainerIdent image hn cn runps + getrunningident :: IO (Maybe ContainerIdent) getrunningident = catchDefaultIO Nothing $ - simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \vs -> do - print vs - -- pure . headMaybe . catMaybes . map readish . catMaybes . map getStdout - return Nothing + simpleShClient (namedPipe cid) "cat" [propellorIdent] $ + pure . headMaybe . catMaybes . map readish . catMaybes . map getStdout runps = getRunParams $ containerprops ++ -- expose propellor directory inside the container -- cgit v1.3-2-g0d8e From 50a9e826a3661e2b7456997213bdf404bb7b542b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:03:03 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index e625a129..659c39eb 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -243,9 +243,14 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci ident = ContainerIdent image hn cn runps getrunningident :: IO (Maybe ContainerIdent) - getrunningident = catchDefaultIO Nothing $ - simpleShClient (namedPipe cid) "cat" [propellorIdent] $ - pure . headMaybe . catMaybes . map readish . catMaybes . map getStdout + getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \vs -> do + let l = (extractident) vs + print l + print vs + return l + + extractident :: [Resp] -> Maybe ContainerIdent + extractident = headMaybe . catMaybes . map readish . catMaybes . map getStdout runps = getRunParams $ containerprops ++ -- expose propellor directory inside the container -- cgit v1.3-2-g0d8e From 00b27119eeee67669688746e3a80347db9cf23ec Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:04:53 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 659c39eb..da9ac36d 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -231,6 +231,7 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci if runningident == Just ident then return NoChange else do + print "container parameters changed" void $ stopContainer cid oldimage <- fromMaybe image <$> commitContainer cid void $ removeContainer cid -- cgit v1.3-2-g0d8e From 4d69d83def502b3a5c75b7145dbdd92ce18f3c6c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:07:51 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index da9ac36d..149df756 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -231,7 +231,7 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci if runningident == Just ident then return NoChange else do - print "container parameters changed" + debug ["container parameters changed"] void $ stopContainer cid oldimage <- fromMaybe image <$> commitContainer cid void $ removeContainer cid @@ -244,11 +244,8 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci ident = ContainerIdent image hn cn runps getrunningident :: IO (Maybe ContainerIdent) - getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \vs -> do - let l = (extractident) vs - print l - print vs - return l + getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ + return . extractident extractident :: [Resp] -> Maybe ContainerIdent extractident = headMaybe . catMaybes . map readish . catMaybes . map getStdout -- cgit v1.3-2-g0d8e From fd9c5fa94cebcc0f182d0e8b32e413dcb4da2e4d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:09:59 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 149df756..9ab47279 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -231,7 +231,7 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci if runningident == Just ident then return NoChange else do - debug ["container parameters changed"] + print ["container parameters changed"] void $ stopContainer cid oldimage <- fromMaybe image <$> commitContainer cid void $ removeContainer cid -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e From e2512c198daf620ace4cbea0e9cb8cd34cff0744 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:14:53 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 9ab47279..87b111bd 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -231,7 +231,7 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci if runningident == Just ident then return NoChange else do - print ["container parameters changed"] + error "container parameters changed" void $ stopContainer cid oldimage <- fromMaybe image <$> commitContainer cid void $ removeContainer cid @@ -248,7 +248,7 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci return . extractident extractident :: [Resp] -> Maybe ContainerIdent - extractident = headMaybe . catMaybes . map readish . catMaybes . map getStdout + extractident = headMaybe . catMaybes . map (readish :: String -> Maybe ContainerIdent) . catMaybes . map getStdout runps = getRunParams $ containerprops ++ -- expose propellor directory inside the container -- cgit v1.3-2-g0d8e From fd1b037d452b7e9ea58beb86eb26ea397f64c28c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:15:56 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 87b111bd..0c52078c 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -244,8 +244,9 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci ident = ContainerIdent image hn cn runps getrunningident :: IO (Maybe ContainerIdent) - getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ - return . extractident + 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 -- cgit v1.3-2-g0d8e From d902a4924b6d8da24bea00b119793f90c88b238a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:21:42 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 0c52078c..8d8cc1eb 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -236,10 +236,7 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci oldimage <- fromMaybe image <$> commitContainer cid void $ removeContainer cid go oldimage - else do - whenM (elem cid <$> listContainers AllContainers) $ do - void $ removeContainer cid - go image + else go image where ident = ContainerIdent image hn cn runps -- cgit v1.3-2-g0d8e From bbca48d44bdecc7698a7c05a5d2d3f64c925a96e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:23:09 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 8d8cc1eb..9bdf3e54 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -241,9 +241,10 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci ident = ContainerIdent image hn cn runps getrunningident :: IO (Maybe ContainerIdent) - getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \rs -> do - print (rs, extractident rs) - return $ extractident rs + getrunningident = catchDefaultIO Nothing $ + 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 -- cgit v1.3-2-g0d8e From b9e7721db0fedbbc6d1d32f54fbf011e0514e9df Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:26:16 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 19 ++++++++++++++----- 1 file 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 -- cgit v1.3-2-g0d8e From e6d9c792e72848e7977020fa9a3311fefff8e710 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:47:06 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 24 ++++++++++-------------- config-joey.hs | 3 +-- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index bcd27c59..e96603f5 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -233,23 +233,19 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci else do error "container parameters changed" void $ stopContainer cid - oldimage <- fromMaybe image <$> commitContainer cid - void $ removeContainer cid - go oldimage - 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 - ) + restartcontainer + else ifM (elem cid <$> listContainers AllContainers) + ( restartcontainer + , go image + ) where ident = ContainerIdent image hn cn runps + restartcontainer = do + oldimage <- fromMaybe image <$> commitContainer cid + void $ removeContainer cid + go oldimage + getrunningident :: IO (Maybe ContainerIdent) getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \rs -> do print (rs, extractident rs) diff --git a/config-joey.hs b/config-joey.hs index cf739d82..975434d3 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -36,7 +36,6 @@ host hostname@"clam.kitenet.net" = standardSystem Unstable $ props & Tor.isBridge & JoeySites.oldUseNetshellBox & Docker.configured - ! Docker.docked container hostname "amd64-git-annex-builder" & Docker.garbageCollected -- Orca is the main git-annex build box. host hostname@"orca.kitenet.net" = standardSystem Unstable $ props @@ -45,7 +44,7 @@ host hostname@"orca.kitenet.net" = standardSystem Unstable $ props & Docker.configured & Apt.buildDep ["git-annex"] & Docker.docked container hostname "amd64-git-annex-builder" - & Docker.docked container hostname "i386-git-annex-builder" + ! Docker.docked container hostname "i386-git-annex-builder" & Docker.garbageCollected -- My laptop host _hostname@"darkstar.kitenet.net" = Just $ props -- cgit v1.3-2-g0d8e From f31f8e8358397c8fef3a8334c1b8d12810a4743a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:49:49 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index e96603f5..2ed35fb4 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -227,11 +227,9 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci -- parameters of the container differ and it must -- be restarted. runningident <- getrunningident - print runningident if runningident == Just ident then return NoChange else do - error "container parameters changed" void $ stopContainer cid restartcontainer else ifM (elem cid <$> listContainers AllContainers) @@ -247,9 +245,8 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci go oldimage getrunningident :: IO (Maybe ContainerIdent) - getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \rs -> do - print (rs, extractident rs) - return $ extractident rs + getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ + return . extractident extractident :: [Resp] -> Maybe ContainerIdent extractident = headMaybe . catMaybes . map (readish :: String -> Maybe ContainerIdent) . catMaybes . map getStdout -- cgit v1.3-2-g0d8e From 1a44d4010aabae565355943ba8684ecd1ec9d829 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:52:52 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 2ed35fb4..36e3cfcd 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -227,6 +227,7 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci -- parameters of the container differ and it must -- be restarted. runningident <- getrunningident + print runningident if runningident == Just ident then return NoChange else do -- cgit v1.3-2-g0d8e From 68ed5153aa3f8a0e50952120c3dbb2386a067ee3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:54:42 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 36e3cfcd..107c542e 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -246,8 +246,9 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci go oldimage getrunningident :: IO (Maybe ContainerIdent) - getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ - return . extractident + getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \rs -> do + print (extractident rs) + return $ extractident rs extractident :: [Resp] -> Maybe ContainerIdent extractident = headMaybe . catMaybes . map (readish :: String -> Maybe ContainerIdent) . catMaybes . map getStdout -- cgit v1.3-2-g0d8e From 075a8eac5b66f0da4e7054002155ebfddde38f7f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:58:48 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 9 ++++----- debian/changelog | 7 +++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 107c542e..6be8c4e2 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE RankNTypes, BangPatterns #-} -- | Docker support for propellor -- @@ -227,7 +227,6 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci -- parameters of the container differ and it must -- be restarted. runningident <- getrunningident - print runningident if runningident == Just ident then return NoChange else do @@ -247,11 +246,11 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci getrunningident :: IO (Maybe ContainerIdent) getrunningident = simpleShClient (namedPipe cid) "cat" [propellorIdent] $ \rs -> do - print (extractident rs) - return $ extractident rs + let !v = extractident rs + return v extractident :: [Resp] -> Maybe ContainerIdent - extractident = headMaybe . catMaybes . map (readish :: String -> Maybe ContainerIdent) . catMaybes . map getStdout + extractident = headMaybe . catMaybes . map readish . catMaybes . map getStdout runps = getRunParams $ containerprops ++ -- expose propellor directory inside the container diff --git a/debian/changelog b/debian/changelog index f4eadd22..0fdd42b2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +propellor (0.2.3) UNRELEASED; urgency=medium + + * docker: Fix laziness bug that caused running containers to be + unnecessarily stopped and committed. + + -- Joey Hess Fri, 04 Apr 2014 15:58:03 -0400 + propellor (0.2.2) unstable; urgency=medium * Now supports provisioning docker containers with architecture/libraries -- cgit v1.3-2-g0d8e From 1f783394c0f3c7796161b7fce16d2523d26c355e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 15:59:48 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 6be8c4e2..493fdf57 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -230,6 +230,7 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci if runningident == Just ident then return NoChange else do + print "stopping!" void $ stopContainer cid restartcontainer else ifM (elem cid <$> listContainers AllContainers) -- cgit v1.3-2-g0d8e From e64a66b21b30b44ce980f45e6ac65d1bebac6297 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 16:03:12 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 1 - config-joey.hs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 493fdf57..6be8c4e2 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -230,7 +230,6 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci if runningident == Just ident then return NoChange else do - print "stopping!" void $ stopContainer cid restartcontainer else ifM (elem cid <$> listContainers AllContainers) diff --git a/config-joey.hs b/config-joey.hs index 975434d3..42fb43af 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -43,8 +43,9 @@ host hostname@"orca.kitenet.net" = standardSystem Unstable $ props & Apt.unattendedUpgrades & Docker.configured & Apt.buildDep ["git-annex"] - & Docker.docked container hostname "amd64-git-annex-builder" + ! Docker.docked container hostname "amd64-git-annex-builder" ! Docker.docked container hostname "i386-git-annex-builder" + -- ! Docker.docked container hostname "armel-git-annex-builder" & Docker.garbageCollected -- My laptop host _hostname@"darkstar.kitenet.net" = Just $ props -- cgit v1.3-2-g0d8e From 776ac21c3661d4086ed7b9d3ac7b8682d85d6ffe Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 16:05:45 -0400 Subject: propellor spin --- config-joey.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config-joey.hs b/config-joey.hs index 42fb43af..0bc948b9 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -43,8 +43,8 @@ host hostname@"orca.kitenet.net" = standardSystem Unstable $ props & Apt.unattendedUpgrades & Docker.configured & Apt.buildDep ["git-annex"] - ! Docker.docked container hostname "amd64-git-annex-builder" - ! Docker.docked container hostname "i386-git-annex-builder" + & Docker.docked container hostname "amd64-git-annex-builder" + & Docker.docked container hostname "i386-git-annex-builder" -- ! Docker.docked container hostname "armel-git-annex-builder" & Docker.garbageCollected -- My laptop -- cgit v1.3-2-g0d8e From da3976b9e2f9abf0f2d37300b70bc8884e4ab2f8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 16:20:20 -0400 Subject: propellor spin --- Propellor/CmdLine.hs | 16 +++++++++++++++- debian/changelog | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs index d10211f0..3974f1d5 100644 --- a/Propellor/CmdLine.hs +++ b/Propellor/CmdLine.hs @@ -8,6 +8,8 @@ import System.Log.Formatter import System.Log.Handler (setFormatter, LogHandler) import System.Log.Handler.Simple import System.PosixCompat +import Control.Exception (bracket) +import System.Posix.IO import Propellor import qualified Propellor.Property.Docker as Docker @@ -71,7 +73,7 @@ defaultMain getprops = do go True cmdline = updateFirst cmdline $ go False cmdline go False (Spin host) = withprops host $ const $ spin host go False (Run host) = ifM ((==) 0 <$> getRealUserID) - ( withprops host ensureProperties + ( onlyProcess $ withprops host ensureProperties , go True (Spin host) ) go False (Boot host) = withprops host $ boot @@ -79,6 +81,18 @@ defaultMain getprops = do withprops host a = maybe (unknownhost host) a $ headMaybe $ catMaybes $ map (\get -> get host) getprops +onlyProcess :: IO a -> IO a +onlyProcess a = bracket lock unlock (const a) + where + lock = do + l <- openFd lockfile ReadWrite Nothing defaultFileFlags + setLock l (WriteLock, AbsoluteSeek, 0, 0) + `catchIO` (const alreadyrunning) + return l + unlock = closeFd + alreadyrunning = error "Propellor is already running on this host!" + lockfile = localdir ".lock" + unknownhost :: HostName -> IO a unknownhost h = errorMessage $ unlines [ "Unknown host: " ++ h diff --git a/debian/changelog b/debian/changelog index 0fdd42b2..a02c27d7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ propellor (0.2.3) UNRELEASED; urgency=medium * docker: Fix laziness bug that caused running containers to be unnecessarily stopped and committed. + * Add locking so only one propellor can run at a time on a host. -- Joey Hess Fri, 04 Apr 2014 15:58:03 -0400 -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e From 160b598756ad08c0d4e8d7da038a63d988e0ab7a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 16:23:20 -0400 Subject: add a lock --- Propellor/CmdLine.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs index 3974f1d5..560e774d 100644 --- a/Propellor/CmdLine.hs +++ b/Propellor/CmdLine.hs @@ -76,7 +76,7 @@ defaultMain getprops = do ( onlyProcess $ withprops host ensureProperties , go True (Spin host) ) - go False (Boot host) = withprops host $ boot + go False (Boot host) = onlyProcess $ withprops host $ boot withprops host a = maybe (unknownhost host) a $ headMaybe $ catMaybes $ map (\get -> get host) getprops -- cgit v1.3-2-g0d8e From 17d46c67fa020b79ce6d31557136a66f66d673af Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 18:21:54 -0400 Subject: docker: When running as effective init inside container, wait on zombies. --- Propellor/Property/Docker.hs | 12 ++++++++++-- Propellor/SimpleSh.hs | 9 +++++---- debian/changelog | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 6be8c4e2..0d07f82c 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -17,6 +17,7 @@ import Utility.Path import Control.Concurrent.Async import System.Posix.Directory +import System.Posix.Process import Data.List -- | Configures docker with an authentication file, so that images can be @@ -272,6 +273,9 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci -- | Called when propellor is running inside a docker container. -- The string should be the container's ContainerId. -- +-- This process is effectively init inside the container. +-- It even needs to wait on zombie processes! +-- -- Fork a thread to run the SimpleSh server in the background. -- In the foreground, run an interactive bash (or sh) shell, -- so that the user can interact with it when attached to the container. @@ -291,19 +295,23 @@ chain s = case toContainerId s of Just cid -> do changeWorkingDirectory localdir writeFile propellorIdent . show =<< readIdentFile cid + gogo reapzombies -- Run boot provisioning before starting simpleSh, -- to avoid ever provisioning twice at the same time. whenM (checkProvisionedFlag cid) $ do let shim = Shim.file (localdir "propellor") (localdir shimdir cid) unlessM (boolSystem shim [Param "--continue", Param $ show $ Chain $ fromContainerId cid]) $ warningMessage "Boot provision failed!" - void $ async $ simpleSh $ namedPipe cid + gogo $ simpleSh $ namedPipe cid forever $ do void $ ifM (inPath "bash") ( boolSystem "bash" [Param "-l"] , boolSystem "/bin/sh" [] ) putStrLn "Container is still running. Press ^P^Q to detach." + where + gogo = void . async . forever . void . tryIO + reapzombies = void $ getAnyProcessStatus True False -- | Once a container is running, propellor can be run inside -- it to provision it. @@ -335,7 +343,7 @@ provisionContainer cid = containerDesc cid $ Property "provision" $ do hPutStrLn stderr s hFlush stderr go Nothing rest - Done _ -> ret lastline + Done -> ret lastline go lastline [] = ret lastline ret lastline = return $ fromMaybe FailedChange $ diff --git a/Propellor/SimpleSh.hs b/Propellor/SimpleSh.hs index 0999be9a..99a6fc24 100644 --- a/Propellor/SimpleSh.hs +++ b/Propellor/SimpleSh.hs @@ -9,7 +9,6 @@ import Network.Socket import Control.Concurrent.Chan import Control.Concurrent.Async import System.Process (std_in, std_out, std_err) -import System.Exit import Propellor import Utility.FileMode @@ -18,7 +17,7 @@ import Utility.ThreadScheduler data Cmd = Cmd String [String] deriving (Read, Show) -data Resp = StdoutLine String | StderrLine String | Done ExitCode +data Resp = StdoutLine String | StderrLine String | Done deriving (Read, Show) simpleSh :: FilePath -> IO () @@ -49,7 +48,7 @@ simpleSh namedpipe = do v <- readChan chan hPutStrLn h (show v) case v of - Done _ -> noop + Done -> noop _ -> runwriter writer <- async runwriter @@ -58,8 +57,10 @@ simpleSh namedpipe = do void $ concurrently (mkreader StdoutLine outh) (mkreader StderrLine errh) + + void $ tryIO $ waitForProcess pid - writeChan chan . Done =<< waitForProcess pid + writeChan chan Done wait writer diff --git a/debian/changelog b/debian/changelog index a02c27d7..e2f955b0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ propellor (0.2.3) UNRELEASED; urgency=medium * docker: Fix laziness bug that caused running containers to be unnecessarily stopped and committed. * Add locking so only one propellor can run at a time on a host. + * docker: When running as effective init inside container, wait on zombies. -- Joey Hess Fri, 04 Apr 2014 15:58:03 -0400 -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e From 0636846848ce3a68c2f66cd798bf37d9afcf0877 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 18:34:03 -0400 Subject: propellor spin --- Propellor/CmdLine.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs index 560e774d..5ea982c3 100644 --- a/Propellor/CmdLine.hs +++ b/Propellor/CmdLine.hs @@ -85,9 +85,9 @@ onlyProcess :: IO a -> IO a onlyProcess a = bracket lock unlock (const a) where lock = do - l <- openFd lockfile ReadWrite Nothing defaultFileFlags + l <- createFile lockfile stdFileMode setLock l (WriteLock, AbsoluteSeek, 0, 0) - `catchIO` (const alreadyrunning) + `catchIO` const alreadyrunning return l unlock = closeFd alreadyrunning = error "Propellor is already running on this host!" -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e From ddfee66915ab3d4bb1e066e47c7f508a9f0ab2bf Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 18:46:54 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 0d07f82c..b39b5a1b 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -295,22 +295,22 @@ chain s = case toContainerId s of Just cid -> do changeWorkingDirectory localdir writeFile propellorIdent . show =<< readIdentFile cid - gogo reapzombies -- Run boot provisioning before starting simpleSh, -- to avoid ever provisioning twice at the same time. whenM (checkProvisionedFlag cid) $ do let shim = Shim.file (localdir "propellor") (localdir shimdir cid) unlessM (boolSystem shim [Param "--continue", Param $ show $ Chain $ fromContainerId cid]) $ warningMessage "Boot provision failed!" - gogo $ simpleSh $ namedPipe cid - forever $ do + void $ async $ job reapzombies + void $ async $ job $ simpleSh $ namedPipe cid + job $ do void $ ifM (inPath "bash") ( boolSystem "bash" [Param "-l"] , boolSystem "/bin/sh" [] ) putStrLn "Container is still running. Press ^P^Q to detach." where - gogo = void . async . forever . void . tryIO + job = forever . void . tryIO reapzombies = void $ getAnyProcessStatus True False -- | Once a container is running, propellor can be run inside -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e From 4dedfb0ec6f0b5e9e0db6fa2708a39817375ead0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 4 Apr 2014 18:50:54 -0400 Subject: propellor spin --- Propellor/Property/Docker.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index b39b5a1b..07c49b47 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -304,7 +304,7 @@ chain s = case toContainerId s of void $ async $ job reapzombies void $ async $ job $ simpleSh $ namedPipe cid job $ do - void $ ifM (inPath "bash") + void $ tryIO $ ifM (inPath "bash") ( boolSystem "bash" [Param "-l"] , boolSystem "/bin/sh" [] ) -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e From 4f8e8077e00ea8c1d0bda199261a0239eed36959 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Apr 2014 00:49:49 -0400 Subject: docker linked containers can have multiple names, separated by ',' Look at the name that contains a containerid --- Propellor/Property/Docker.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 07c49b47..50a816d1 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -19,6 +19,7 @@ import Control.Concurrent.Async import System.Posix.Directory import System.Posix.Process import Data.List +import Data.List.Utils -- | Configures docker with an authentication file, so that images can be -- pushed to index.docker.io. @@ -390,7 +391,8 @@ data ContainerFilter = RunningContainers | AllContainers -- | Only lists propellor managed containers. listContainers :: ContainerFilter -> IO [ContainerId] listContainers status = - catMaybes . map toContainerId . catMaybes . map (lastMaybe . words) . lines + catMaybes . map toContainerId . concat . map (split ",") + . catMaybes . map (lastMaybe . words) . lines <$> readProcess dockercmd ps where ps -- cgit v1.3-2-g0d8e From 1d07360f74a06436f669a992e5ca589f07106c4e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Apr 2014 01:10:54 -0400 Subject: adding support for linked containers --- Propellor/Property/Docker.hs | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 50a816d1..cc6f83c4 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -117,7 +117,7 @@ containerProperties findcontainer = \h -> case toContainerId h of -- container. data Container = Container Image [Containerized Property] -data Containerized a = Containerized [RunParam] a +data Containerized a = Containerized [HostName -> RunParam] a -- | Parameters to pass to `docker run` when creating a container. type RunParam = String @@ -171,6 +171,15 @@ workdir = runProp "workdir" memory :: String -> Containerized Property memory = runProp "memory" +-- | Link with another container on the same host. +link :: ContainerName -> ContainerAlias -> Containerized Property +link linkwith alias = genProp "link" $ \hn -> + fromContainerId (ContainerId hn linkwith) ++ ":" ++ alias + +-- | A short alias for a linked container. +-- Each container has its own alias namespace. +type ContainerAlias = String + -- | A container is identified by its name, and the host -- on which it's deployed. data ContainerId = ContainerId HostName ContainerName @@ -182,10 +191,10 @@ data ContainerId = ContainerId HostName ContainerName data ContainerIdent = ContainerIdent Image HostName ContainerName [RunParam] deriving (Read, Show, Eq) -getRunParams :: [Containerized a] -> [RunParam] -getRunParams l = concatMap get l +getRunParams :: HostName -> [Containerized a] -> [RunParam] +getRunParams hn l = concatMap get l where - get (Containerized ps _) = ps + get (Containerized ps _) = map (\a -> a hn ) ps fromContainerized :: forall a. [Containerized a] -> [a] fromContainerized l = map get l @@ -254,7 +263,7 @@ runningContainer cid@(ContainerId hn cn) image containerprops = containerDesc ci extractident :: [Resp] -> Maybe ContainerIdent extractident = headMaybe . catMaybes . map readish . catMaybes . map getStdout - runps = getRunParams $ containerprops ++ + runps = getRunParams hn $ containerprops ++ -- expose propellor directory inside the container [ volume (localdir++":"++localdir) -- name the container in a predictable way so we @@ -404,11 +413,17 @@ listImages :: IO [Image] listImages = lines <$> readProcess dockercmd ["images", "--all", "--quiet"] runProp :: String -> RunParam -> Containerized Property -runProp field val = - Containerized ["--" ++ param] (Property (param) (return NoChange)) +runProp field val = Containerized + [\_ -> "--" ++ param] + (Property (param) (return NoChange)) where param = field++"="++val +genProp :: String -> (HostName -> RunParam) -> Containerized Property +genProp field mkval = Containerized + [\h -> "--" ++ field ++ "=" ++ mkval h] + (Property field (return NoChange)) + -- | The ContainerIdent of a container is written to -- /.propellor-ident inside it. This can be checked to see if -- the container has the same ident later. -- cgit v1.3-2-g0d8e From c62c606c0e459fe19f258bcf5ba80958349f3e1e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Apr 2014 01:21:23 -0400 Subject: support volumes-from --- Propellor/Property/Docker.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index cc6f83c4..2014e5bd 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -158,10 +158,18 @@ publish = runProp "publish" user :: String -> Containerized Property user = runProp "user" --- | Bind mount a volume +-- | Mount a volume +-- Create a bind mount with: [host-dir]:[container-dir]:[rw|ro] +-- With just a directory, creates a volume in the container. volume :: String -> Containerized Property volume = runProp "volume" +-- | Mount a volume from the specified container into the current +-- container. +volumes_from :: ContainerName -> Containerized Property +volumes_from cn = genProp "volumes-rom" $ \hn -> + fromContainerId (ContainerId hn cn) + -- | Work dir inside the container. workdir :: String -> Containerized Property workdir = runProp "workdir" -- cgit v1.3-2-g0d8e From d8a241322e16cc55881781f06a12005395010d3e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Apr 2014 01:42:59 -0400 Subject: propellor spin --- Propellor/Property/SiteSpecific/GitAnnexBuilder.hs | 33 ++++++++++------------ config-joey.hs | 21 +++++++++++++- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs b/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs index f4e13149..149c8e6c 100644 --- a/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs +++ b/Propellor/Property/SiteSpecific/GitAnnexBuilder.hs @@ -9,8 +9,14 @@ import Propellor.Property.Cron (CronTimes) builduser :: UserName builduser = "builder" +homedir :: FilePath +homedir = "/home/builder" + +gitbuilderdir :: FilePath +gitbuilderdir = homedir "gitbuilder" + builddir :: FilePath -builddir = "gitbuilder" +builddir = gitbuilderdir "build" builder :: Architecture -> CronTimes -> Bool -> Property builder arch crontimes rsyncupload = combineProperties "gitannexbuilder" @@ -20,26 +26,22 @@ builder arch crontimes rsyncupload = combineProperties "gitannexbuilder" "liblockfile-simple-perl", "cabal-install", "vim", "less"] , serviceRunning "cron" `requires` Apt.installed ["cron"] , User.accountFor builduser - , check (lacksdir builddir) $ userScriptProperty builduser - [ "git clone git://git.kitenet.net/gitannexbuilder " ++ builddir - , "cd " ++ builddir + , check (not <$> doesDirectoryExist gitbuilderdir) $ userScriptProperty builduser + [ "git clone git://git.kitenet.net/gitannexbuilder " ++ gitbuilderdir + , "cd " ++ gitbuilderdir , "git checkout " ++ arch ] `describe` "gitbuilder setup" - , check (lacksdir $ builddir "build") $ userScriptProperty builduser - [ "cd " ++ builddir - , "git clone git://git-annex.branchable.com/ build" + , check (not <$> doesDirectoryExist builddir) $ userScriptProperty builduser + [ "git clone git://git-annex.branchable.com/ " ++ builddir ] - , Property "git-annex source build deps installed" $ do - d <- homedir - ensureProperty $ Apt.buildDepIn (d builddir "build") - , Cron.niceJob "gitannexbuilder" crontimes builduser ("~/" ++ builddir) "git pull ; ./autobuild" + , "git-annex source build deps installed" ==> Apt.buildDepIn builddir + , Cron.niceJob "gitannexbuilder" crontimes builduser gitbuilderdir "git pull ; ./autobuild" -- The builduser account does not have a password set, -- instead use the password privdata to hold the rsync server -- password used to upload the built image. , Property "rsync password" $ do - d <- homedir - let f = d "rsyncpassword" + let f = homedir "rsyncpassword" if rsyncupload then withPrivData (Password builduser) $ \p -> do oldp <- catchDefaultIO "" $ readFileStrict f @@ -52,8 +54,3 @@ builder arch crontimes rsyncupload = combineProperties "gitannexbuilder" , makeChange $ writeFile f "no password configured" ) ] - where - homedir = fromMaybe ("/home/" ++ builduser) <$> User.homedir builduser - lacksdir d = do - h <- homedir - not <$> doesDirectoryExist (h d) diff --git a/config-joey.hs b/config-joey.hs index 0bc948b9..f2cc5e78 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -45,7 +45,8 @@ host hostname@"orca.kitenet.net" = standardSystem Unstable $ props & Apt.buildDep ["git-annex"] & Docker.docked container hostname "amd64-git-annex-builder" & Docker.docked container hostname "i386-git-annex-builder" - -- ! Docker.docked container hostname "armel-git-annex-builder" + & Docker.docked container hostname "armel-git-annex-builder-companion" + & Docker.docked container hostname "armel-git-annex-builder" & Docker.garbageCollected -- My laptop host _hostname@"darkstar.kitenet.net" = Just $ props @@ -67,11 +68,29 @@ container _host name & serviceRunning "apache2" `requires` Apt.installed ["apache2"] ] + + -- armel builder has a companion container that run amd64 and + -- runs the build first to get TH splices. They share a home + -- directory, and need to have the same versions of all haskell + -- libraries installed. + | name == "armel-git-annex-builder-companion" = Just $ Docker.containerFrom + (image $ System (Debian Unstable) "amd64") + [ Docker.volume GitAnnexBuilder.homedir + ] + | name == "armel-git-annex-builder" = Just $ Docker.containerFrom + (image $ System (Debian Unstable) "armel") + [ Docker.link (name ++ "-companion") "companion" + , Docker.volumes_from (name ++ "-companion") + , Docker.inside $ props +-- & GitAnnexBuilder.builder "armel" "15 * * * *" True + ] + | "-git-annex-builder" `isSuffixOf` name = let arch = takeWhile (/= '-') name in Just $ Docker.containerFrom (image $ System (Debian Unstable) arch) [ Docker.inside $ props & GitAnnexBuilder.builder arch "15 * * * *" True ] + | otherwise = Nothing -- | Docker images I prefer to use. -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e From e579feed3d679ff664069d6baf5e6058b588bf66 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 8 Apr 2014 01:45:19 -0400 Subject: tpo --- Propellor/Property/Docker.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 2014e5bd..b573e641 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -167,7 +167,7 @@ volume = runProp "volume" -- | Mount a volume from the specified container into the current -- container. volumes_from :: ContainerName -> Containerized Property -volumes_from cn = genProp "volumes-rom" $ \hn -> +volumes_from cn = genProp "volumes-from" $ \hn -> fromContainerId (ContainerId hn cn) -- | Work dir inside the container. -- cgit v1.3-2-g0d8e -- cgit v1.3-2-g0d8e