Skip to content

Commit

Permalink
[8.x] [kbn-test] extract ES logs only for svl (#202927) (#204750)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[kbn-test] extract ES logs only for svl
(#202927)](#202927)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Dzmitry
Lemechko","email":"dzmitry.lemechko@elastic.co"},"sourceCommit":{"committedDate":"2024-12-04T23:19:41Z","message":"[kbn-test]
extract ES logs only for svl (#202927)\n\n## Summary\r\n\r\nPR fixes the
issue reported by @dolaru when running stateful FTR\r\nenvironment
without docker setup locally:\r\n\r\n```\r\n info [es] killing node\r\n
info [es] stopping node scout\r\n info [es] no debug files found,
assuming es did not write any\r\n info [es] cleanup complete\r\nERROR
UNHANDLED ERROR\r\nERROR Error: Command failed with exit code 1: docker
ps -a --format {{.Names}}\r\n error during connect: Get
\"http://docker.example.com/v1.47/containers/json?all=1\": command [ssh
-o ConnectTimeout=30 -T -l dolaru -- debian-12-vm docker system
dial-stdio] has exited with exit status 255, make sure the URL is valid,
and Docker 18.09 or later is installed on the remote host: stderr=ssh:
Could not resolve hostname dolaru-m2-mbp-debian.local: nodename nor
servname provided, or not known\r\n at makeError
(/Users/dolaru/workspace/kibana/node_modules/execa/lib/error.js:60:11)\r\n
at handlePromise
(/Users/dolaru/workspace/kibana/node_modules/execa/index.js:118:26)\r\n
at processTicksAndRejections
(node:internal/process/task_queues:95:5)\r\n at extractAndArchiveLogs
(extract_and_archive_logs.ts:34:41)\r\n at
run_elasticsearch.ts:86:5\r\n```\r\n\r\nSince we don't need it for
stateful ES instance, I added condition.\r\nkbn-scout had the same
issue, so I exported `cleanupElasticsearch` from\r\n`kbn-test` to avoid
code
duplication","sha":"cdb5a2dca2f42edbe2be47c970423d7dbd1ce99e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport
missing","v9.0.0","backport:version","v8.18.0"],"number":202927,"url":"https://github.com/elastic/kibana/pull/202927","mergeCommit":{"message":"[kbn-test]
extract ES logs only for svl (#202927)\n\n## Summary\r\n\r\nPR fixes the
issue reported by @dolaru when running stateful FTR\r\nenvironment
without docker setup locally:\r\n\r\n```\r\n info [es] killing node\r\n
info [es] stopping node scout\r\n info [es] no debug files found,
assuming es did not write any\r\n info [es] cleanup complete\r\nERROR
UNHANDLED ERROR\r\nERROR Error: Command failed with exit code 1: docker
ps -a --format {{.Names}}\r\n error during connect: Get
\"http://docker.example.com/v1.47/containers/json?all=1\": command [ssh
-o ConnectTimeout=30 -T -l dolaru -- debian-12-vm docker system
dial-stdio] has exited with exit status 255, make sure the URL is valid,
and Docker 18.09 or later is installed on the remote host: stderr=ssh:
Could not resolve hostname dolaru-m2-mbp-debian.local: nodename nor
servname provided, or not known\r\n at makeError
(/Users/dolaru/workspace/kibana/node_modules/execa/lib/error.js:60:11)\r\n
at handlePromise
(/Users/dolaru/workspace/kibana/node_modules/execa/index.js:118:26)\r\n
at processTicksAndRejections
(node:internal/process/task_queues:95:5)\r\n at extractAndArchiveLogs
(extract_and_archive_logs.ts:34:41)\r\n at
run_elasticsearch.ts:86:5\r\n```\r\n\r\nSince we don't need it for
stateful ES instance, I added condition.\r\nkbn-scout had the same
issue, so I exported `cleanupElasticsearch` from\r\n`kbn-test` to avoid
code
duplication","sha":"cdb5a2dca2f42edbe2be47c970423d7dbd1ce99e"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202927","number":202927,"mergeCommit":{"message":"[kbn-test]
extract ES logs only for svl (#202927)\n\n## Summary\r\n\r\nPR fixes the
issue reported by @dolaru when running stateful FTR\r\nenvironment
without docker setup locally:\r\n\r\n```\r\n info [es] killing node\r\n
info [es] stopping node scout\r\n info [es] no debug files found,
assuming es did not write any\r\n info [es] cleanup complete\r\nERROR
UNHANDLED ERROR\r\nERROR Error: Command failed with exit code 1: docker
ps -a --format {{.Names}}\r\n error during connect: Get
\"http://docker.example.com/v1.47/containers/json?all=1\": command [ssh
-o ConnectTimeout=30 -T -l dolaru -- debian-12-vm docker system
dial-stdio] has exited with exit status 255, make sure the URL is valid,
and Docker 18.09 or later is installed on the remote host: stderr=ssh:
Could not resolve hostname dolaru-m2-mbp-debian.local: nodename nor
servname provided, or not known\r\n at makeError
(/Users/dolaru/workspace/kibana/node_modules/execa/lib/error.js:60:11)\r\n
at handlePromise
(/Users/dolaru/workspace/kibana/node_modules/execa/index.js:118:26)\r\n
at processTicksAndRejections
(node:internal/process/task_queues:95:5)\r\n at extractAndArchiveLogs
(extract_and_archive_logs.ts:34:41)\r\n at
run_elasticsearch.ts:86:5\r\n```\r\n\r\nSince we don't need it for
stateful ES instance, I added condition.\r\nkbn-scout had the same
issue, so I exported `cleanupElasticsearch` from\r\n`kbn-test` to avoid
code
duplication","sha":"cdb5a2dca2f42edbe2be47c970423d7dbd1ce99e"}},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
  • Loading branch information
dmlemeshko authored Dec 18, 2024
1 parent afa4fc9 commit 91aa821
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
7 changes: 3 additions & 4 deletions packages/kbn-scout/src/servers/run_elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { resolve } from 'path';
import type { ToolingLog } from '@kbn/tooling-log';
import { REPO_ROOT } from '@kbn/repo-info';
import type { ArtifactLicense, ServerlessProjectType } from '@kbn/es';
import { isServerlessProjectType, extractAndArchiveLogs } from '@kbn/es/src/utils';
import { createTestEsCluster, esTestConfig } from '@kbn/test';
import { isServerlessProjectType } from '@kbn/es/src/utils';
import { createTestEsCluster, esTestConfig, cleanupElasticsearch } from '@kbn/test';
import { Config } from '../config';

interface RunElasticsearchOptions {
Expand Down Expand Up @@ -82,8 +82,7 @@ export async function runElasticsearch(
config,
});
return async () => {
await node.cleanup();
await extractAndArchiveLogs({ outputFolder: logsDir, log });
await cleanupElasticsearch(node, config.serverless, logsDir, log);
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/kbn-test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export {
remapPluginPaths,
getKibanaCliArg,
getKibanaCliLoggers,
cleanupElasticsearch,
} from './src/functional_tests/lib';

export { initLogsDir } from './src/functional_tests/lib';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-test/src/functional_tests/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

export { runKibanaServer } from './run_kibana_server';
export { runElasticsearch } from './run_elasticsearch';
export { runElasticsearch, cleanupElasticsearch } from './run_elasticsearch';
export * from './run_ftr';
export {
parseRawFlags,
Expand Down
18 changes: 15 additions & 3 deletions packages/kbn-test/src/functional_tests/lib/run_elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { REPO_ROOT } from '@kbn/repo-info';
import type { ArtifactLicense, ServerlessProjectType } from '@kbn/es';
import { isServerlessProjectType, extractAndArchiveLogs } from '@kbn/es/src/utils';
import type { Config } from '../../functional_test_runner';
import { createTestEsCluster, esTestConfig } from '../../es';
import { ICluster, createTestEsCluster, esTestConfig } from '../../es';

interface RunElasticsearchOptions {
log: ToolingLog;
Expand Down Expand Up @@ -77,6 +77,19 @@ function getEsConfig({
};
}

export async function cleanupElasticsearch(
node: ICluster,
isServerless: boolean,
logsDir: string | undefined,
log: ToolingLog
): Promise<void> {
await node.cleanup();

if (isServerless) {
await extractAndArchiveLogs({ outputFolder: logsDir, log });
}
}

export async function runElasticsearch(
options: RunElasticsearchOptions
): Promise<() => Promise<void>> {
Expand All @@ -91,8 +104,7 @@ export async function runElasticsearch(
config,
});
return async () => {
await node.cleanup();
await extractAndArchiveLogs({ outputFolder: logsDir, log });
await cleanupElasticsearch(node, config.serverless, logsDir, log);
};
}

Expand Down

0 comments on commit 91aa821

Please sign in to comment.