git.iko.soy/typeable/octopod
on master help sign in
Added an unarchive script (#89)
commitf0b4e4950f73747a0eeb4bd8b61d8ebaed974dbe authoriko <ilyakooo0@gmail.com> dateTue 7 Sep 2021, 14:12 (5 years ago) parent4ce72d3
3 files changed+12−3
dev/default.nix+1 octopod-backend/src/Octopod/Server.hs+7−3 octopod-backend/src/Octopod/Server/ControlScriptUtils.hs+4
dev/default.nix+1
@@ -144,6 +144,7 @@ in
144144 export DEPLOYMENT_KEYS_COMMAND=${infoScript}
145145 export APPLICATION_OVERRIDES_COMMAND=${infoScript}
146146 export APPLICATION_KEYS_COMMAND=${infoScript}
147+ export UNARCHIVE_COMMAND=${writeScript}
147148 export POWER_AUTHORIZATION_HEADER="123"
148149 ${hsPkgs.octopod-backend.components.exes.octopod-exe}/bin/octopod-exe \
149150 --port 4443 \
octopod-backend/src/Octopod/Server.hs+7−3
@@ -114,6 +114,7 @@ data AppState = AppState
114114 , deploymentOverrideKeysCommand :: Command
115115 , applicationOverridesCommand :: Command
116116 , applicationOverrideKeysCommand :: Command
117+ , unarchiveCommand :: Command
117118 , -- | Deployments currently being processed which has not yet been
118119 -- recorded in the database.
119120 lockedDeployments :: LockedDeployments
@@ -171,6 +172,7 @@ runOctopodServer = do
171172 dKeysCmd <- Command . pack <$> getEnvOrDie "DEPLOYMENT_KEYS_COMMAND"
172173 aOverridesCmd <- Command . pack <$> getEnvOrDie "APPLICATION_OVERRIDES_COMMAND"
173174 aKeysCmd <- Command . pack <$> getEnvOrDie "APPLICATION_KEYS_COMMAND"
175+ unarchiveCmd <- Command . pack <$> getEnvOrDie "UNARCHIVE_COMMAND"
174176 powerAuthorizationHeader <- AuthHeader . BSC.pack <$> getEnvOrDie "POWER_AUTHORIZATION_HEADER"
175177 notificationCmd <-
176178 (fmap . fmap) (Command . pack) $
@@ -212,6 +214,7 @@ runOctopodServer = do
212214 dKeysCmd
213215 aOverridesCmd
214216 aKeysCmd
217+ unarchiveCmd
215218 lockedDs
216219 app' = app appSt
217220 wsApp' = wsApp channel
@@ -573,7 +576,7 @@ transitionStatus :: DeploymentStatusTransition -> DeploymentStatus
573576transitionStatus TransitionArchived {} = Archived
574577transitionStatus TransitionCreate {} = Running
575578transitionStatus TransitionUpdate {} = Running
576−transitionStatus TransitionRestore {} = Running
579+transitionStatus TransitionRestore {} = CreatePending
577580transitionStatus TransitionArchivePending {} = ArchivePending
578581transitionStatus TransitionUpdatePending {} = UpdatePending
579582transitionStatus TransitionCreatePending {} = CreatePending
@@ -984,11 +987,12 @@ restoreH dName = do
984987 runDeploymentBgWorker (Just CreatePending) dName (pure ()) $ \() -> do
985988 dep' <- getDeploymentS dName
986989 updateDeploymentInfo dName
987− (ec, out, err) <- createDeployment $ dep' ^. #deployment
990+ dCfg <- getDefaultConfig dName
991+ (ec, out, err) <- runCommandArgs unarchiveCommand =<< unarchiveCommandArgs dCfg (dep' ^. #deployment)
988992 t2 <- liftBase getCurrentTime
989993 let elTime = elapsedTime t2 t1
990994 transitionToStatusS dName $
991− TransitionCreatePending
995+ TransitionRestore
992996 StatusTransitionProcessOutput
993997 { exitCode = ec
994998 , duration = elTime
octopod-backend/src/Octopod/Server/ControlScriptUtils.hs+4
@@ -5,6 +5,7 @@
55--This module contains control script utils.
66module Octopod.Server.ControlScriptUtils
77 ( infoCommandArgs,
8+ unarchiveCommandArgs,
89 notificationCommandArgs,
910 runCommand,
1011 runCommandWithoutPipes,
@@ -79,6 +80,9 @@ type GenericDeploymentCommandArgsNoConfig m r =
7980 ) =>
8081 m ControlScriptArgs
8182
83+unarchiveCommandArgs :: GenericDeploymentCommandArgs m r
84+unarchiveCommandArgs = genericDeploymentCommandArgs
85+
8286genericDeploymentCommandArgsNoConfig :: GenericDeploymentCommandArgsNoConfig m r
8387genericDeploymentCommandArgsNoConfig = do
8488 (Namespace namespace) <- asks getTyped