From 75a824c7883e53c75dafa7bc5144ee44e51d3cd2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 Nov 2014 17:57:04 -0400 Subject: fix display of progress etc lines before protocol line --- src/Propellor/Protocol.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Propellor/Protocol.hs') diff --git a/src/Propellor/Protocol.hs b/src/Propellor/Protocol.hs index 99afb31f..198b3f32 100644 --- a/src/Propellor/Protocol.hs +++ b/src/Propellor/Protocol.hs @@ -1,7 +1,7 @@ -- | This is a simple line-based protocol used for communication between -- a local and remote propellor. It's sent over a ssh channel, and lines of -- the protocol can be interspersed with other, non-protocol lines --- that should be ignored. +-- that should be passed through to be displayed. module Propellor.Protocol where @@ -48,7 +48,9 @@ getMarked h marker = go =<< catchMaybeIO (hGetLine h) where go Nothing = return Nothing go (Just l) = case fromMarked marker l of - Nothing -> getMarked h marker + Nothing -> do + hPutStrLn stderr l + getMarked h marker Just v -> return (Just v) req :: Stage -> Marker -> (String -> IO ()) -> IO () -- cgit v1.3-2-g0d8e From 18903ad30c9a94b03c445eda2e15d6acb885e794 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 Nov 2014 18:13:42 -0400 Subject: display improvements --- src/Propellor/CmdLine.hs | 10 ++++++---- src/Propellor/Protocol.hs | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src/Propellor/Protocol.hs') diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs index d863ed35..6716e361 100644 --- a/src/Propellor/CmdLine.hs +++ b/src/Propellor/CmdLine.hs @@ -100,7 +100,9 @@ defaultMain hostlist = do ( onlyProcess $ withhost hn mainProperties , go True (Spin hn) ) - go False (Boot _) = onlyProcess boot + go False (Boot _) = do + forceConsole + onlyProcess boot withhost :: HostName -> (Host -> IO ()) -> IO () withhost hn a = maybe (unknownhost hn hostlist) a (findHost hostlist hn) @@ -196,18 +198,18 @@ getCurrentGitSha1 branchref = readProcess "git" ["show-ref", "--hash", branchref -- updated, it's run. spin :: HostName -> Host -> IO () spin hn hst = do - void $ actionMessage "git commit (signed)" $ + void $ actionMessage "Git commit (signed)" $ gitCommit [Param "--allow-empty", Param "-a", Param "-m", Param "propellor spin"] -- Push to central origin repo first, if possible. -- The remote propellor will pull from there, which avoids -- us needing to send stuff directly to the remote host. whenM hasOrigin $ - void $ actionMessage "pushing to central git repository" $ + void $ actionMessage "Push to central git repository" $ boolSystem "git" [Param "push"] cacheparams <- toCommand <$> sshCachingParams hn comm cacheparams =<< hostprivdata - unlessM (boolSystem "ssh" (map Param (cacheparams ++ ["-t", user, runcmd]))) $ + unlessM (boolSystem "ssh" (map Param (cacheparams ++ [user, runcmd]))) $ error $ "remote propellor failed (running: " ++ runcmd ++")" where hostprivdata = show . filterPrivData hst <$> decryptPrivData diff --git a/src/Propellor/Protocol.hs b/src/Propellor/Protocol.hs index 198b3f32..7249e2b1 100644 --- a/src/Propellor/Protocol.hs +++ b/src/Propellor/Protocol.hs @@ -49,7 +49,8 @@ getMarked h marker = go =<< catchMaybeIO (hGetLine h) go Nothing = return Nothing go (Just l) = case fromMarked marker l of Nothing -> do - hPutStrLn stderr l + unless (null l) $ + hPutStrLn stderr l getMarked h marker Just v -> return (Just v) -- cgit v1.3-2-g0d8e From 65d3f085dcd86c53549a3b126e0888f09c5e1925 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 Nov 2014 19:33:11 -0400 Subject: remove what should be dead code While old propellor's can emit Ready, they won't if they've managed to updateFirst. If updateFirst fails due to eg, inaccessiable central repo, those old propellor's are not able to receive inline git pushes anyway, so are not going to update no matter what, so no point in making --spin work in that case. --- src/Propellor/CmdLine.hs | 10 ---------- src/Propellor/Protocol.hs | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'src/Propellor/Protocol.hs') diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs index df4d44a6..66da6339 100644 --- a/src/Propellor/CmdLine.hs +++ b/src/Propellor/CmdLine.hs @@ -233,16 +233,6 @@ spin hn hst = do hClose fromh sendGitClone hn comm cacheparams privdata - -- Ready is only sent by old versions of - -- propellor. They expect to get privdata, - -- and then no more protocol communication. - dispatch (Just Ready) = do - sendprivdata toh privdata - hClose toh - -- Display remaining output. - void $ tryIO $ forever $ - putStrLn =<< hGetLine fromh - hClose fromh dispatch Nothing = return () user = "root@"++hn diff --git a/src/Propellor/Protocol.hs b/src/Propellor/Protocol.hs index 7249e2b1..f8b706cc 100644 --- a/src/Propellor/Protocol.hs +++ b/src/Propellor/Protocol.hs @@ -9,7 +9,7 @@ import Data.List import Propellor -data Stage = Ready | NeedGitClone | NeedRepoUrl | NeedPrivData | NeedGitPush +data Stage = NeedGitClone | NeedRepoUrl | NeedPrivData | NeedGitPush deriving (Read, Show, Eq) type Marker = String -- cgit v1.3-2-g0d8e