Ensure docker-compose runs down process if any error setting up service or agents#3207
Conversation
|
test integrations |
|
Created or updated PR in integrations repository to test this version. Check elastic/integrations#16956 |
|
Checking the Buildkite output of PR elastic/integrations#16956
|
|
/test |
| } | ||
| logger.Debug("Tearing down service due to setup error") | ||
| // Update svcInfo with the latest info before tearing down | ||
| agent.agentInfo = agentInfo |
There was a problem hiding this comment.
teardown process requires agent.agentInfo.Name and depending on where the error was raised that value is not set yet in agent.agentInfo but it is in agentInfo variable.
Same applies for service deployer changes.
| if err != nil { | ||
| processAgentContainerLogs(ctx, p, compose.CommandOptions{ | ||
| Env: opts.Env, | ||
| }, agentName) |
There was a problem hiding this comment.
Don't we need to process logs?
There was a problem hiding this comment.
agent.TearDown and service.TearDown methods perform the logs processing too and they write those logs to a file. So those log files are still created with this change.
For instance:
https://buildkite.com/elastic/integrations/builds/36477#019bc194-6d6a-4f7c-9dc9-9fc250eef030/L1819-L1827
2026/01/15 12:31:23 DEBUG Tearing down service due to setup error
2026/01/15 12:31:23 DEBUG tearing down service using Docker Compose runner
Container elastic-package-service-25ac85762-uploader-1 Stopping
Container elastic-package-service-25ac85762-gcs-mock-service-1 Stopping
Container elastic-package-service-25ac85762-uploader-1 Stopped
Container elastic-package-service-25ac85762-azure-blob-storage-emulator-1 Stopping
Container elastic-package-service-25ac85762-gcs-mock-service-1 Stopped
Container elastic-package-service-25ac85762-azure-blob-storage-emulator-1 Stopped
2026/01/15 12:31:24 INFO Write container logs to file: /opt/buildkite-agent/builds/bk-agent-prod-gcp-1768479315190015396/elastic/integrations/build/container-logs/gcs-mock-service-1768480284898784890.log
Just realized that if the --no-provision flag is set, those logs are not processed and they could be interesting too. I'll work on adding those.
|
/test |
💚 Build Succeeded
History
cc @mrodm |
| defer func() { | ||
| if err == nil { | ||
| return | ||
| } | ||
| logger.Debug("Tearing down service due to setup error") | ||
| // Update svcInfo with the latest info before tearing down | ||
| service.svcInfo = svcInfo | ||
| service.TearDown(context.WithoutCancel(ctx)) | ||
| }() |
There was a problem hiding this comment.
Terraform service deployer does not support to run system tests by steps (--setup, --no-provision , --tear-down flags):
elastic-package/internal/servicedeployer/factory.go
Lines 121 to 123 in f03edb6
Ensures that
docker-compose downprocess is executed if there is any failure in the SetUp process of Service and Agent deployers based on docker-compose.Fixes elastic/integrations#16941
Author's Checklist
--setup,--no-provisionor--tear-downflags).How to test this package locally