Commit 8b473ff2 authored by Valentin Reis's avatar Valentin Reis

clean_config management simplified.

parent 88c18e58
Pipeline #5920 passed with stages
in 2 minutes and 20 seconds
......@@ -60,17 +60,27 @@ prepareDaemon
-> PowerCap
-> Shell Instrumentation
prepareDaemon out stdErr test v powercap = do
_ <- myWhich "daemon"
daemonPath <- myWhich "daemon"
let confPath' = "/tmp/argo_nodeos_config"
cleanContainers confPath' 1 2
cleanContainers confPath'
export "ARGO_NODEOS_CONFIG" (format fp confPath')
return $ Instrumentation
(P.proc "daemon"
(["--nrm_log", "./nrm_log"] ++ toOption v ++ toOption powercap)
)
out
stdErr
test
return $ case powercap of
None -> Instrumentation
(P.proc "daemon" (["--nrm_log", "./nrm_log"] ++ toOption v))
out
stdErr
test
_ -> Instrumentation
(P.proc
"sudo"
( [encodeString daemonPath, "--nrm_log", "./nrm_log"]
++ toOption v
++ toOption powercap
)
)
out
stdErr
test
where
nodeOsFailure n = do
printError ("argo_nodeos_config failed with exit code :" <> repr n)
......@@ -79,43 +89,15 @@ prepareDaemon out stdErr test v powercap = do
printInfo "Contents of .argo_nodeos_config_exit_message: "
view $ input ".argo_nodeos_config_exit_message"
False -> die ("argo_nodeos_config failed with exit code " <> repr n)
cleanContainers :: FilePath -> NominalDiffTime -> Integer -> Shell ()
cleanContainers argo_nodeos_config retryTime remainingRetries = do
let showConfig =
inshell (format (fp % " --show_config") argo_nodeos_config) empty
cleanContainers :: FilePath -> Shell ()
cleanContainers argo_nodeos_config =
verboseShell'
(format (fp % " --clean_config=kill_content:true") argo_nodeos_config)
empty
>>= \case
(ExitFailure n, _, _) -> do
when (remainingRetries == 0) $ nodeOsFailure n
printWarning
( "the argo_nodeos_config call failed with exit code "
<> repr n
<> ". Retrying.."
)
liftIO $ sleep (retryTime * 2)
cleanContainers argo_nodeos_config
(retryTime * 2)
(remainingRetries - 1)
(ExitSuccess, _, _) -> do
printInfo "Cleaned the argo config."
len <- liftIO $ Turtle.Shell.fold
(grep (has "CONTAINER") showConfig)
Fold.length
if len > 0
then do
printWarning
$ "the argo_nodeos_config call did not remove containers, "
<> "at least not fast enough. Retrying.."
liftIO $ sleep retryTime
cleanContainers argo_nodeos_config
(retryTime * 2)
(remainingRetries - 1)
else
printInfo
$ "argo_nodeos_config successfully cleaned the container "
<> "config."
(format ("sudo" % fp % " --clean_config=kill_content:true")
argo_nodeos_config
)
empty >>= \case
(ExitFailure n,_,_) -> nodeOsFailure n
(ExitSuccess,_,_) -> return ()
cmdRunI
:: AppName
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment