Post-deploy abra.sh hooks #292
Loading…
x
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 deploy
add the env:POST_DEPLOY_CMDS="<container> <command> <arguments>|<container> <command2> <arguments2>|... "
To execute commands after each
abra app upgrade
add 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
->run
since 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.Filters
if possible due to the often bizarre handling of filters in the Docker API. You'd passexactMatch = true
which I think is more readable for our future selves.I just moved this function from
cli/app/cmd.go
without touching it.I think
app.Filters
doesn't make sense here, because it filters for all services and in this case only a filter forserviceName
is 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
6c993e812c
to14bdb57ac7
Some docs: https://docs.coopcloud.tech/maintainers/handbook/#global-environment-variables