Skip to content

Commit

Permalink
[8.x] [Security Solution] Make retry messages in `retryIfDeleteB…
Browse files Browse the repository at this point in the history
…yQueryConflicts` loggable (elastic#193117) (elastic#193410)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution] Make retry messages in
`retryIfDeleteByQueryConflicts` loggable
(elastic#193117)](elastic#193117)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Maxim
Palenov","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-19T11:21:44Z","message":"[Security
Solution] Make retry messages in `retryIfDeleteByQueryConflicts`
loggable (elastic#193117)\n\n## Summary\r\n\r\nThis makes retry messages in
`retryIfDeleteByQueryConflicts()` helper function visible in CI
logs.\r\n\r\n## Details\r\n\r\nAccording to the
[implementation](https://github.com/elastic/kibana/blob/main/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/reporter.js#L71-L74)
only error messages logged via `ToolingLog` piped to the CI log. It
happens only when `mochaReporter.captureLogOutput` flag is set to
`true`. According to the
[schema](https://github.com/elastic/kibana/blob/eabb1022815a7c661a0e642c62d0a77ce338f9c9/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts#L175)
`captureLogOutput` has `true` value in CI and there is no
`DISABLE_CI_LOG_OUTPUT_CAPTURE` env variable set.\r\n\r\nIt was
[tested](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6978#01920936-b484-4dfb-a87b-ae40858c9ff5)
in flaky test runner. Error messages a logged as
expected.","sha":"067d949d2c914b87fbbe88f469e005dcf59a0310","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["test","enhancement","release_note:skip","v9.0.0","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection Rule
Management","backport:prev-minor","v8.16.0"],"title":"[Security
Solution] Make retry messages in `retryIfDeleteByQueryConflicts`
loggable","number":193117,"url":"https://github.com/elastic/kibana/pull/193117","mergeCommit":{"message":"[Security
Solution] Make retry messages in `retryIfDeleteByQueryConflicts`
loggable (elastic#193117)\n\n## Summary\r\n\r\nThis makes retry messages in
`retryIfDeleteByQueryConflicts()` helper function visible in CI
logs.\r\n\r\n## Details\r\n\r\nAccording to the
[implementation](https://github.com/elastic/kibana/blob/main/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/reporter.js#L71-L74)
only error messages logged via `ToolingLog` piped to the CI log. It
happens only when `mochaReporter.captureLogOutput` flag is set to
`true`. According to the
[schema](https://github.com/elastic/kibana/blob/eabb1022815a7c661a0e642c62d0a77ce338f9c9/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts#L175)
`captureLogOutput` has `true` value in CI and there is no
`DISABLE_CI_LOG_OUTPUT_CAPTURE` env variable set.\r\n\r\nIt was
[tested](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6978#01920936-b484-4dfb-a87b-ae40858c9ff5)
in flaky test runner. Error messages a logged as
expected.","sha":"067d949d2c914b87fbbe88f469e005dcf59a0310"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193117","number":193117,"mergeCommit":{"message":"[Security
Solution] Make retry messages in `retryIfDeleteByQueryConflicts`
loggable (elastic#193117)\n\n## Summary\r\n\r\nThis makes retry messages in
`retryIfDeleteByQueryConflicts()` helper function visible in CI
logs.\r\n\r\n## Details\r\n\r\nAccording to the
[implementation](https://github.com/elastic/kibana/blob/main/packages/kbn-test/src/functional_test_runner/lib/mocha/reporter/reporter.js#L71-L74)
only error messages logged via `ToolingLog` piped to the CI log. It
happens only when `mochaReporter.captureLogOutput` flag is set to
`true`. According to the
[schema](https://github.com/elastic/kibana/blob/eabb1022815a7c661a0e642c62d0a77ce338f9c9/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts#L175)
`captureLogOutput` has `true` value in CI and there is no
`DISABLE_CI_LOG_OUTPUT_CAPTURE` env variable set.\r\n\r\nIt was
[tested](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6978#01920936-b484-4dfb-a87b-ae40858c9ff5)
in flaky test runner. Error messages a logged as
expected.","sha":"067d949d2c914b87fbbe88f469e005dcf59a0310"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Maxim Palenov <[email protected]>
  • Loading branch information
kibanamachine and maximpn authored Sep 19, 2024
1 parent 21582a7 commit 014add7
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ export async function retryIfDeleteByQueryConflicts(
const operationResult = await operation();

if (!operationResult.failures || operationResult.failures?.length === 0) {
logger.info(`${name} finished successfully`);
return operationResult;
}

const failureCause = operationResult.failures.map((failure) => failure.cause).join(', ');

logger.warning(`Unable to delete by query ${name}. Caused by: "${failureCause}". Retrying ...`);
logger.error(`Unable to delete by query ${name}. Caused by: "${failureCause}". Retrying ...`);

await waitBeforeNextRetry(retryDelay);
}
Expand Down

0 comments on commit 014add7

Please sign in to comment.