Skip to content

Commit

Permalink
[EDR Workflows] Catch docker container deletion error (elastic#168982)
Browse files Browse the repository at this point in the history
## Summary

This PR will have our `after:run` task catch potential errors when
cleaning up the docker container used.

There were instances where our tests were failing to complete properly
because we were failing at this step:
https://buildkite.com/elastic/kibana-pull-request/builds/168052#018b37fc-b2b1-4986-8c11-0701f447d972/6-2209

```
An error was thrown in your plugins file while executing the handler for the after:run event.
--
  |  
  | The error we received was:
  |  
  | Error: Command failed with exit code 1: docker kill 4080ac06a71871298f2a3163c915f0170e8f3dd9f6814e022d727e9958401361
  | Error response from daemon: Cannot kill container: 4080ac06a71871298f2a3163c915f0170e8f3dd9f6814e022d727e9958401361: No such container: 4080ac06a71871298f2a3163c915f0170e8f3dd9f6814e022d727e9958401361
  | at makeError (/opt/local-ssd/buildkite/builds/kb-n2-4-virt-debbcb53f059032d/elastic/kibana-pull-request/kibana/node_modules/execa/lib/error.js:60:11)
  | at Function.module.exports.sync (/opt/local-ssd/buildkite/builds/kb-n2-4-virt-debbcb53f059032d/elastic/kibana-pull-request/kibana/node_modules/execa/index.js:194:17)
  | at Object.handler (/opt/local-ssd/buildkite/builds/kb-n2-4-virt-debbcb53f059032d/elastic/kibana-pull-request/kibana/x-pack/plugins/security_solution/public/management/cypress/support/data_loaders.ts:321:13)
  | at invoke (/var/lib/buildkite-agent/.cache/Cypress/13.3.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:183:18)
  | at /var/lib/buildkite-agent/.cache/Cypress/13.3.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:59:14
  | at tryCatcher (/var/lib/buildkite-agent/.cache/Cypress/13.3.0/Cypress/resources/app/node_modules/bluebird/js/release/util.js:16:23)
  | at Function.Promise.attempt.Promise.try (/var/lib/buildkite-agent/.cache/Cypress/13.3.0/Cypress/resources/app/node_modules/bluebird/js/release/method.js:39:29)
  | at Object.wrapChildPromise (/var/lib/buildkite-agent/.cache/Cypress/13.3.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:58:23)
  | at RunPlugins.execute (/var/lib/buildkite-agent/.cache/Cypress/13.3.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:164:21)
  | at EventEmitter.<anonymous> (/var/lib/buildkite-agent/.cache/Cypress/13.3.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:56:12)
  | at EventEmitter.emit (node:events:514:28)
  | at EventEmitter.emit (node:domain:489:12)
  | at process.<anonymous> (/var/lib/buildkite-agent/.cache/Cypress/13.3.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)
  | at process.emit (node:events:514:28)
  | at process.emit (node:domain:489:12)
  | at process.emit.sharedData.processEmitHook.installedValue [as emit] (/var/lib/buildkite-agent/.cache/Cypress/13.3.0/Cypress/resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)
  | at emit (node:internal/child_process:937:14)
  | at processTicksAndRejections (node:internal/process/task_queues:83:21)
```

In addition, I have a flaky test runner to ensure that we don't fail due
to this error again:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3527

2nd flaky run:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3535

3rd flaky run ✅ :
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3592#_
- Note this run has a couple failures but they are on unrelated flaky
tests that are being addressed in other PRs.

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Patryk Kopyciński <[email protected]>
  • Loading branch information
3 people authored Oct 23, 2023
1 parent 4bf4c05 commit 8805e74
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,14 @@ export const dataLoadersForRealEndpoints = (
fleetServerContainerId = data?.fleetServerContainerId;
});

on('after:run', () => {
on('after:run', async () => {
const { log } = await stackServicesPromise;
if (fleetServerContainerId) {
execa.sync('docker', ['kill', fleetServerContainerId]);
try {
execa.sync('docker', ['kill', fleetServerContainerId]);
} catch (error) {
log.error(error);
}
}
});

Expand Down

0 comments on commit 8805e74

Please sign in to comment.