Skip to content

@kbn/cleanup-before-exit: don't pass in undefined exit code#243499

Merged
kobelb merged 9 commits intoelastic:mainfrom
dgieselaar:cleanup-before-exit-code
Nov 19, 2025
Merged

@kbn/cleanup-before-exit: don't pass in undefined exit code#243499
kobelb merged 9 commits intoelastic:mainfrom
dgieselaar:cleanup-before-exit-code

Conversation

@dgieselaar
Copy link
Copy Markdown
Contributor

@dgieselaar dgieselaar commented Nov 19, 2025

@kbn/cleanup-before-exit previously called process.exit(exitCode) even when the exitCode is undefined. Passing in undefined actually overrides a previously set process.exitCode. This unintentionally causes the exitCode to be 0 when process.exitCode has been set to a non-zero value. After #228692 was merged, @kbn/cleanup-before-exit became active for FTR runs because initMetrics uses this function, and FTR uses process.exitCode, which caused false positives in CI.

We're skipping test suites to allow the fix to roll in, and prevent further unnoticed errors going to main.

Skipped suites / cases in:

@dgieselaar dgieselaar requested a review from a team as a code owner November 19, 2025 12:27
@dgieselaar dgieselaar added release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels v9.2.0 v9.3.0 labels Nov 19, 2025
@delanni delanni requested review from a team as code owners November 19, 2025 15:42
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Nov 19, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/fleet (Team:Fleet)

@delanni delanni force-pushed the cleanup-before-exit-code branch from 83916c0 to 43670ea Compare November 19, 2025 16:04
@dgieselaar dgieselaar enabled auto-merge (squash) November 19, 2025 16:44
@delanni delanni requested a review from a team as a code owner November 19, 2025 17:42
@delanni delanni requested a review from a team November 19, 2025 17:42
@jbudz jbudz requested a review from a team as a code owner November 19, 2025 19:41
jbudz added a commit that referenced this pull request Nov 20, 2025
…3499) (#243579)

#243499

Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Co-authored-by: Alex Szabo <alex.szabo@elastic.co>
Co-authored-by: Nick Partridge <nicholas.partridge@elastic.co>
jbudz added a commit that referenced this pull request Nov 20, 2025
Checking for build failures seen in
https://buildkite.com/elastic/kibana-on-merge/builds/82173.

May be unrelated, failing tests were not propagating previously - see
#243499
csr added a commit that referenced this pull request Nov 20, 2025
…3630)

This PR adds two integration tests to verify that FTR preserves exit
codes correctly when cleanup handlers are registered via
`@kbn/cleanup-before-exit`.

This test would have caught the bug fixed in #243499, where
`cleanupBeforeExit` was accidentally resetting the exit code to 0 when
tests failed.
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 20, 2025
…stic#243630)

This PR adds two integration tests to verify that FTR preserves exit
codes correctly when cleanup handlers are registered via
`@kbn/cleanup-before-exit`.

This test would have caught the bug fixed in elastic#243499, where
`cleanupBeforeExit` was accidentally resetting the exit code to 0 when
tests failed.

(cherry picked from commit 71a871a)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 20, 2025
…stic#243630)

This PR adds two integration tests to verify that FTR preserves exit
codes correctly when cleanup handlers are registered via
`@kbn/cleanup-before-exit`.

This test would have caught the bug fixed in elastic#243499, where
`cleanupBeforeExit` was accidentally resetting the exit code to 0 when
tests failed.

(cherry picked from commit 71a871a)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 20, 2025
…stic#243630)

This PR adds two integration tests to verify that FTR preserves exit
codes correctly when cleanup handlers are registered via
`@kbn/cleanup-before-exit`.

This test would have caught the bug fixed in elastic#243499, where
`cleanupBeforeExit` was accidentally resetting the exit code to 0 when
tests failed.

(cherry picked from commit 71a871a)
nreese added a commit that referenced this pull request Nov 20, 2025
…st (#243568)

Fixes and unskips test skipped in
#243499

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
andrimal pushed a commit to andrimal/kibana that referenced this pull request Nov 20, 2025
…243499)

`@kbn/cleanup-before-exit` previously called `process.exit(exitCode)`
even when the exitCode is undefined. Passing in `undefined` actually
overrides a previously set `process.exitCode`. This unintentionally
causes the exitCode to be 0 when process.exitCode has been set to a
non-zero value. After elastic#228692 was
merged, `@kbn/cleanup-before-exit` became active for FTR runs because
`initMetrics` uses this function, and FTR uses `process.exitCode`, which
caused false positives in CI.

We're skipping test suites to allow the fix to roll in, and prevent
further unnoticed errors going to main.

Skipped suites / cases in: 
- [ ] .buildkite/ftr_platform_stateful_configs.yml /
x-pack/performance/journeys_e2e/aiops_log_rate_analysis.ts
- [ ]
src/platform/test/api_integration/apis/dashboards/get_dashboard/main.ts
 - [x] src/platform/test/functional/apps/discover/group10/_lens_vis.ts
- [ ]
x-pack/platform/test/fleet_api_integration/apis/package_policy/delete.ts
- [ ]
x-pack/platform/test/functional_execution_context/tests/log_correlation.ts
- [ ]
x-pack/solutions/search/test/functional_search/tests/classic_navigation.basic.ts
- [ ]
x-pack/solutions/search/test/functional_search/tests/classic_navigation.ts
- [ ]
x-pack/solutions/security/test/api_integration/apis/cloud_security_posture/benchmark/v2.ts
- [ ]
x-pack/solutions/security/test/serverless/api_integration/test_suites/platform_security/authorization.ts
- [ ]
x-pack/platform/test/functional/apps/aiops/change_point_detection.ts
- [ ]
src/platform/test/api_integration/apis/metrics_experience/fields.ts
- [ ]
x-pack/solutions/security/test/security_solution_api_integration/test_suites/genai/attack_discovery/schedules/trial_license_complete_tier/find/find.ts
- [ ]
x-pack/platform/test/reporting_functional/reporting_and_security/management.ts

---------

Co-authored-by: Alex Szabo <alex.szabo@elastic.co>
Co-authored-by: Jonathan Budzenski <jon@elastic.co>
Co-authored-by: Nick Partridge <nicholas.partridge@elastic.co>
andrimal pushed a commit to andrimal/kibana that referenced this pull request Nov 20, 2025
…lastic#243586)

Checking for build failures seen in
https://buildkite.com/elastic/kibana-on-merge/builds/82173.

May be unrelated, failing tests were not propagating previously - see
elastic#243499
andrimal pushed a commit to andrimal/kibana that referenced this pull request Nov 20, 2025
…stic#243630)

This PR adds two integration tests to verify that FTR preserves exit
codes correctly when cleanup handlers are registered via
`@kbn/cleanup-before-exit`.

This test would have caught the bug fixed in elastic#243499, where
`cleanupBeforeExit` was accidentally resetting the exit code to 0 when
tests failed.
andrimal pushed a commit to andrimal/kibana that referenced this pull request Nov 20, 2025
…st (elastic#243568)

Fixes and unskips test skipped in
elastic#243499

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Nov 20, 2025
#243630) (#243673)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[FTR] Add integration tests to verify FTR exit code preservation
(#243630)](#243630)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Cesare de
Cal","email":"cesare.decal@elastic.co"},"sourceCommit":{"committedDate":"2025-11-20T14:46:51Z","message":"[FTR]
Add integration tests to verify FTR exit code preservation
(#243630)\n\nThis PR adds two integration tests to verify that FTR
preserves exit\ncodes correctly when cleanup handlers are registered
via\n`@kbn/cleanup-before-exit`.\n\nThis test would have caught the bug
fixed in #243499, where\n`cleanupBeforeExit` was accidentally resetting
the exit code to 0 when\ntests
failed.","sha":"71a871a3c402387be2b4040f2728f850eea17f7e","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","v9.3.0"],"title":"[FTR]
Add integration tests to verify FTR exit code
preservation","number":243630,"url":"https://github.com/elastic/kibana/pull/243630","mergeCommit":{"message":"[FTR]
Add integration tests to verify FTR exit code preservation
(#243630)\n\nThis PR adds two integration tests to verify that FTR
preserves exit\ncodes correctly when cleanup handlers are registered
via\n`@kbn/cleanup-before-exit`.\n\nThis test would have caught the bug
fixed in #243499, where\n`cleanupBeforeExit` was accidentally resetting
the exit code to 0 when\ntests
failed.","sha":"71a871a3c402387be2b4040f2728f850eea17f7e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/243630","number":243630,"mergeCommit":{"message":"[FTR]
Add integration tests to verify FTR exit code preservation
(#243630)\n\nThis PR adds two integration tests to verify that FTR
preserves exit\ncodes correctly when cleanup handlers are registered
via\n`@kbn/cleanup-before-exit`.\n\nThis test would have caught the bug
fixed in #243499, where\n`cleanupBeforeExit` was accidentally resetting
the exit code to 0 when\ntests
failed.","sha":"71a871a3c402387be2b4040f2728f850eea17f7e"}}]}]
BACKPORT-->

Co-authored-by: Cesare de Cal <cesare.decal@elastic.co>
kibanamachine added a commit that referenced this pull request Nov 20, 2025
#243630) (#243674)

# Backport

This will backport the following commits from `main` to `9.2`:
- [[FTR] Add integration tests to verify FTR exit code preservation
(#243630)](#243630)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Cesare de
Cal","email":"cesare.decal@elastic.co"},"sourceCommit":{"committedDate":"2025-11-20T14:46:51Z","message":"[FTR]
Add integration tests to verify FTR exit code preservation
(#243630)\n\nThis PR adds two integration tests to verify that FTR
preserves exit\ncodes correctly when cleanup handlers are registered
via\n`@kbn/cleanup-before-exit`.\n\nThis test would have caught the bug
fixed in #243499, where\n`cleanupBeforeExit` was accidentally resetting
the exit code to 0 when\ntests
failed.","sha":"71a871a3c402387be2b4040f2728f850eea17f7e","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","v9.3.0"],"title":"[FTR]
Add integration tests to verify FTR exit code
preservation","number":243630,"url":"https://github.com/elastic/kibana/pull/243630","mergeCommit":{"message":"[FTR]
Add integration tests to verify FTR exit code preservation
(#243630)\n\nThis PR adds two integration tests to verify that FTR
preserves exit\ncodes correctly when cleanup handlers are registered
via\n`@kbn/cleanup-before-exit`.\n\nThis test would have caught the bug
fixed in #243499, where\n`cleanupBeforeExit` was accidentally resetting
the exit code to 0 when\ntests
failed.","sha":"71a871a3c402387be2b4040f2728f850eea17f7e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/243630","number":243630,"mergeCommit":{"message":"[FTR]
Add integration tests to verify FTR exit code preservation
(#243630)\n\nThis PR adds two integration tests to verify that FTR
preserves exit\ncodes correctly when cleanup handlers are registered
via\n`@kbn/cleanup-before-exit`.\n\nThis test would have caught the bug
fixed in #243499, where\n`cleanupBeforeExit` was accidentally resetting
the exit code to 0 when\ntests
failed.","sha":"71a871a3c402387be2b4040f2728f850eea17f7e"}}]}]
BACKPORT-->

Co-authored-by: Cesare de Cal <cesare.decal@elastic.co>
kibanamachine added a commit that referenced this pull request Nov 20, 2025
…on (#243630) (#243672)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[FTR] Add integration tests to verify FTR exit code preservation
(#243630)](#243630)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Cesare de
Cal","email":"cesare.decal@elastic.co"},"sourceCommit":{"committedDate":"2025-11-20T14:46:51Z","message":"[FTR]
Add integration tests to verify FTR exit code preservation
(#243630)\n\nThis PR adds two integration tests to verify that FTR
preserves exit\ncodes correctly when cleanup handlers are registered
via\n`@kbn/cleanup-before-exit`.\n\nThis test would have caught the bug
fixed in #243499, where\n`cleanupBeforeExit` was accidentally resetting
the exit code to 0 when\ntests
failed.","sha":"71a871a3c402387be2b4040f2728f850eea17f7e","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","v9.3.0"],"title":"[FTR]
Add integration tests to verify FTR exit code
preservation","number":243630,"url":"https://github.com/elastic/kibana/pull/243630","mergeCommit":{"message":"[FTR]
Add integration tests to verify FTR exit code preservation
(#243630)\n\nThis PR adds two integration tests to verify that FTR
preserves exit\ncodes correctly when cleanup handlers are registered
via\n`@kbn/cleanup-before-exit`.\n\nThis test would have caught the bug
fixed in #243499, where\n`cleanupBeforeExit` was accidentally resetting
the exit code to 0 when\ntests
failed.","sha":"71a871a3c402387be2b4040f2728f850eea17f7e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/243630","number":243630,"mergeCommit":{"message":"[FTR]
Add integration tests to verify FTR exit code preservation
(#243630)\n\nThis PR adds two integration tests to verify that FTR
preserves exit\ncodes correctly when cleanup handlers are registered
via\n`@kbn/cleanup-before-exit`.\n\nThis test would have caught the bug
fixed in #243499, where\n`cleanupBeforeExit` was accidentally resetting
the exit code to 0 when\ntests
failed.","sha":"71a871a3c402387be2b4040f2728f850eea17f7e"}}]}]
BACKPORT-->

Co-authored-by: Cesare de Cal <cesare.decal@elastic.co>
eokoneyo pushed a commit to eokoneyo/kibana that referenced this pull request Dec 2, 2025
…243499)

`@kbn/cleanup-before-exit` previously called `process.exit(exitCode)`
even when the exitCode is undefined. Passing in `undefined` actually
overrides a previously set `process.exitCode`. This unintentionally
causes the exitCode to be 0 when process.exitCode has been set to a
non-zero value. After elastic#228692 was
merged, `@kbn/cleanup-before-exit` became active for FTR runs because
`initMetrics` uses this function, and FTR uses `process.exitCode`, which
caused false positives in CI.

We're skipping test suites to allow the fix to roll in, and prevent
further unnoticed errors going to main.

Skipped suites / cases in: 
- [ ] .buildkite/ftr_platform_stateful_configs.yml /
x-pack/performance/journeys_e2e/aiops_log_rate_analysis.ts
- [ ]
src/platform/test/api_integration/apis/dashboards/get_dashboard/main.ts
 - [x] src/platform/test/functional/apps/discover/group10/_lens_vis.ts
- [ ]
x-pack/platform/test/fleet_api_integration/apis/package_policy/delete.ts
- [ ]
x-pack/platform/test/functional_execution_context/tests/log_correlation.ts
- [ ]
x-pack/solutions/search/test/functional_search/tests/classic_navigation.basic.ts
- [ ]
x-pack/solutions/search/test/functional_search/tests/classic_navigation.ts
- [ ]
x-pack/solutions/security/test/api_integration/apis/cloud_security_posture/benchmark/v2.ts
- [ ]
x-pack/solutions/security/test/serverless/api_integration/test_suites/platform_security/authorization.ts
- [ ]
x-pack/platform/test/functional/apps/aiops/change_point_detection.ts
- [ ]
src/platform/test/api_integration/apis/metrics_experience/fields.ts
- [ ]
x-pack/solutions/security/test/security_solution_api_integration/test_suites/genai/attack_discovery/schedules/trial_license_complete_tier/find/find.ts
- [ ]
x-pack/platform/test/reporting_functional/reporting_and_security/management.ts

---------

Co-authored-by: Alex Szabo <alex.szabo@elastic.co>
Co-authored-by: Jonathan Budzenski <jon@elastic.co>
Co-authored-by: Nick Partridge <nicholas.partridge@elastic.co>
eokoneyo pushed a commit to eokoneyo/kibana that referenced this pull request Dec 2, 2025
…lastic#243586)

Checking for build failures seen in
https://buildkite.com/elastic/kibana-on-merge/builds/82173.

May be unrelated, failing tests were not propagating previously - see
elastic#243499
eokoneyo pushed a commit to eokoneyo/kibana that referenced this pull request Dec 2, 2025
…stic#243630)

This PR adds two integration tests to verify that FTR preserves exit
codes correctly when cleanup handlers are registered via
`@kbn/cleanup-before-exit`.

This test would have caught the bug fixed in elastic#243499, where
`cleanupBeforeExit` was accidentally resetting the exit code to 0 when
tests failed.
eokoneyo pushed a commit to eokoneyo/kibana that referenced this pull request Dec 2, 2025
…st (elastic#243568)

Fixes and unskips test skipped in
elastic#243499

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v9.2.0 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants