Post-deploy abra.sh hooks #292
Reference in New Issue
Block a user
No description provided.
Delete Branch "post_deploy_cmds"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This solves coop-cloud/organising#235
To execute commands after each
abra app deployadd the env:POST_DEPLOY_CMDS="<container> <command> <arguments>|<container> <command2> <arguments2>|... "To execute commands after each
abra app upgradeadd the env:POST_UPGRADE_CMDS="<container> <command> <arguments>|..."It is important that the health checks are working correctly and the timeout is high enough, because the commands are only executed after the services converged successfully.
LGTM! Some minor comments. Can you also throw up some docs for this new functionality as well? Thanks!
@ -207,1 +207,4 @@postDeployCmds, ok := app.Env["POST_UPGRADE_CMDS"]if ok && !internal.DontWaitConverge {logrus.Debugf("Run the following post-deploy commands: %s", postDeployCmds)nitpick:
Run->runsince the rest of the codebase uses lowercase@ -208,0 +209,4 @@if ok && !internal.DontWaitConverge {logrus.Debugf("Run the following post-deploy commands: %s", postDeployCmds)if err := internal.PostCmds(cl, app, postDeployCmds); err != nil {logrus.Fatal(err)logrus.Fatalf("attempting to run post deploy commands, saw: %s", err)?@ -7,2 +20,4 @@"github.com/sirupsen/logrus")func RunCmdRemote(cl *dockerClient.Client, app config.App, abraSh, serviceName, cmdName, cmdArgs string) error {Missing docstring?
@ -8,1 +22,4 @@func RunCmdRemote(cl *dockerClient.Client, app config.App, abraSh, serviceName, cmdName, cmdArgs string) error {filters := filters.NewArgs()filters.Add("name", fmt.Sprintf("^%s_%s", app.StackName(), serviceName))I'd recommend using the
app.Filtersif possible due to the often bizarre handling of filters in the Docker API. You'd passexactMatch = truewhich I think is more readable for our future selves.I just moved this function from
cli/app/cmd.gowithout touching it.I think
app.Filtersdoesn't make sense here, because it filters for all services and in this case only a filter forserviceNameis required.@ -166,1 +167,4 @@postDeployCmds, ok := app.Env["POST_DEPLOY_CMDS"]if ok && !DontWaitConverge {logrus.Debugf("Run the following post-deploy commands: %s", postDeployCmds)nitpick: Run -> run since the rest of the codebase uses lowercase
@ -167,0 +169,4 @@if ok && !DontWaitConverge {logrus.Debugf("Run the following post-deploy commands: %s", postDeployCmds)if err := PostCmds(cl, app, postDeployCmds); err != nil {logrus.Fatal(err)logrus.Fatalf("attempting to run post deploy commands, saw: %s", err)?
@ -167,0 +176,4 @@return nil}func PostCmds(cl *dockerClient.Client, app config.App, commands string) error {Missing doc string?
@ -167,0 +196,4 @@if len(commandParts) > 2 {parsedCmdArgs = fmt.Sprintf("%s ", strings.Join(commandParts[2:], " "))}logrus.Infof("Running post-command '%s %s' in container %s", cmdName, parsedCmdArgs, targetServiceName)nitpick: Running -> running since the rest of the codebase uses lowercase
6c993e812cto14bdb57ac7Some docs: https://docs.coopcloud.tech/maintainers/handbook/#global-environment-variables