Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run the post script _before_ killing the containers #707

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions internal/docker/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ func (d *Deployer) PrintLogs(dep *Deployment) {
// Destroy a deployment. This will kill all running containers.
func (d *Deployer) Destroy(dep *Deployment, printServerLogs bool, testName string, failed bool) {
for _, hsDep := range dep.HS {
result, err := d.executePostScript(hsDep, testName, failed)
if err != nil {
log.Printf("Failed to execute post test script: %s - %s", err, string(result))
}
if result != nil {
log.Printf("Post test script result: %s", string(result))
}
if printServerLogs {
// If we want the logs we gracefully stop the containers to allow
// the logs to be flushed.
Expand All @@ -224,14 +231,6 @@ func (d *Deployer) Destroy(dep *Deployment, printServerLogs bool, testName strin
}
}

result, err := d.executePostScript(hsDep, testName, failed)
if err != nil {
log.Printf("Failed to execute post test script: %s - %s", err, string(result))
}
if printServerLogs && err == nil && result != nil {
log.Printf("Post test script result: %s", string(result))
}

err = d.Docker.ContainerRemove(context.Background(), hsDep.ContainerID, types.ContainerRemoveOptions{
Force: true,
})
Expand Down
Loading