Added an unarchive script (#89)

This commit is contained in:
iko 2021-09-07 14:12:41 +03:00 committed by GitHub
parent 4ce72d3408
commit f0b4e4950f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -144,6 +144,7 @@ in
export DEPLOYMENT_KEYS_COMMAND=${infoScript}
export APPLICATION_OVERRIDES_COMMAND=${infoScript}
export APPLICATION_KEYS_COMMAND=${infoScript}
export UNARCHIVE_COMMAND=${writeScript}
export POWER_AUTHORIZATION_HEADER="123"
${hsPkgs.octopod-backend.components.exes.octopod-exe}/bin/octopod-exe \
--port 4443 \

View File

@ -114,6 +114,7 @@ data AppState = AppState
, deploymentOverrideKeysCommand :: Command
, applicationOverridesCommand :: Command
, applicationOverrideKeysCommand :: Command
, unarchiveCommand :: Command
, -- | Deployments currently being processed which has not yet been
-- recorded in the database.
lockedDeployments :: LockedDeployments
@ -171,6 +172,7 @@ runOctopodServer = do
dKeysCmd <- Command . pack <$> getEnvOrDie "DEPLOYMENT_KEYS_COMMAND"
aOverridesCmd <- Command . pack <$> getEnvOrDie "APPLICATION_OVERRIDES_COMMAND"
aKeysCmd <- Command . pack <$> getEnvOrDie "APPLICATION_KEYS_COMMAND"
unarchiveCmd <- Command . pack <$> getEnvOrDie "UNARCHIVE_COMMAND"
powerAuthorizationHeader <- AuthHeader . BSC.pack <$> getEnvOrDie "POWER_AUTHORIZATION_HEADER"
notificationCmd <-
(fmap . fmap) (Command . pack) $
@ -212,6 +214,7 @@ runOctopodServer = do
dKeysCmd
aOverridesCmd
aKeysCmd
unarchiveCmd
lockedDs
app' = app appSt
wsApp' = wsApp channel
@ -573,7 +576,7 @@ transitionStatus :: DeploymentStatusTransition -> DeploymentStatus
transitionStatus TransitionArchived {} = Archived
transitionStatus TransitionCreate {} = Running
transitionStatus TransitionUpdate {} = Running
transitionStatus TransitionRestore {} = Running
transitionStatus TransitionRestore {} = CreatePending
transitionStatus TransitionArchivePending {} = ArchivePending
transitionStatus TransitionUpdatePending {} = UpdatePending
transitionStatus TransitionCreatePending {} = CreatePending
@ -984,11 +987,12 @@ restoreH dName = do
runDeploymentBgWorker (Just CreatePending) dName (pure ()) $ \() -> do
dep' <- getDeploymentS dName
updateDeploymentInfo dName
(ec, out, err) <- createDeployment $ dep' ^. #deployment
dCfg <- getDefaultConfig dName
(ec, out, err) <- runCommandArgs unarchiveCommand =<< unarchiveCommandArgs dCfg (dep' ^. #deployment)
t2 <- liftBase getCurrentTime
let elTime = elapsedTime t2 t1
transitionToStatusS dName $
TransitionCreatePending
TransitionRestore
StatusTransitionProcessOutput
{ exitCode = ec
, duration = elTime

View File

@ -5,6 +5,7 @@
--This module contains control script utils.
module Octopod.Server.ControlScriptUtils
( infoCommandArgs,
unarchiveCommandArgs,
notificationCommandArgs,
runCommand,
runCommandWithoutPipes,
@ -79,6 +80,9 @@ type GenericDeploymentCommandArgsNoConfig m r =
) =>
m ControlScriptArgs
unarchiveCommandArgs :: GenericDeploymentCommandArgs m r
unarchiveCommandArgs = genericDeploymentCommandArgs
genericDeploymentCommandArgsNoConfig :: GenericDeploymentCommandArgsNoConfig m r
genericDeploymentCommandArgsNoConfig = do
(Namespace namespace) <- asks getTyped