From 8b16c7aca4a583504ff1ad29f52c281f8368ee1f Mon Sep 17 00:00:00 2001 From: Pierre Gayvallet Date: Thu, 8 Feb 2024 13:53:29 +0100 Subject: [PATCH] Add `build_flavor` to `/api/status` response (#176477) ## Summary Fix https://github.com/elastic/kibana/issues/176475 Add the `version.build_flavor` field to the response of the status API --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .../src/status/components/version_header.test.tsx | 1 + .../src/status/lib/load_status.test.ts | 1 + packages/core/status/core-status-common-internal/src/status.ts | 2 ++ packages/core/status/core-status-common-internal/tsconfig.json | 3 ++- .../status/core-status-server-internal/src/routes/status.ts | 3 ++- src/core/server/integration_tests/status/routes/status.test.ts | 1 + 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/core/apps/core-apps-browser-internal/src/status/components/version_header.test.tsx b/packages/core/apps/core-apps-browser-internal/src/status/components/version_header.test.tsx index 8172b705a6ffe..e0eaf9b2144fa 100644 --- a/packages/core/apps/core-apps-browser-internal/src/status/components/version_header.test.tsx +++ b/packages/core/apps/core-apps-browser-internal/src/status/components/version_header.test.tsx @@ -17,6 +17,7 @@ const buildServerVersion = (parts: Partial = {}): ServerVersion = build_number: 9000, build_snapshot: false, build_date: '2023-05-15T23:12:09.000Z', + build_flavor: 'traditional', ...parts, }); diff --git a/packages/core/apps/core-apps-browser-internal/src/status/lib/load_status.test.ts b/packages/core/apps/core-apps-browser-internal/src/status/lib/load_status.test.ts index ed6cc186313f3..92aad0f460e70 100644 --- a/packages/core/apps/core-apps-browser-internal/src/status/lib/load_status.test.ts +++ b/packages/core/apps/core-apps-browser-internal/src/status/lib/load_status.test.ts @@ -21,6 +21,7 @@ const mockedResponse: StatusResponse = { build_number: 12, build_snapshot: false, build_date: '2023-05-15T23:12:09.000Z', + build_flavor: 'traditional', }, status: { overall: { diff --git a/packages/core/status/core-status-common-internal/src/status.ts b/packages/core/status/core-status-common-internal/src/status.ts index 806a3ac56b407..0a3f3ad770fe8 100644 --- a/packages/core/status/core-status-common-internal/src/status.ts +++ b/packages/core/status/core-status-common-internal/src/status.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +import type { BuildFlavor } from '@kbn/config'; import type { ServiceStatusLevelId, ServiceStatus, CoreStatus } from '@kbn/core-status-common'; import type { OpsMetrics } from '@kbn/core-metrics-server'; @@ -34,6 +35,7 @@ export interface ServerVersion { build_hash: string; build_number: number; build_snapshot: boolean; + build_flavor: BuildFlavor; build_date: string; } diff --git a/packages/core/status/core-status-common-internal/tsconfig.json b/packages/core/status/core-status-common-internal/tsconfig.json index c746e7133cd2c..7d31fa090eb0f 100644 --- a/packages/core/status/core-status-common-internal/tsconfig.json +++ b/packages/core/status/core-status-common-internal/tsconfig.json @@ -13,7 +13,8 @@ ], "kbn_references": [ "@kbn/core-status-common", - "@kbn/core-metrics-server" + "@kbn/core-metrics-server", + "@kbn/config" ], "exclude": [ "target/**/*", diff --git a/packages/core/status/core-status-server-internal/src/routes/status.ts b/packages/core/status/core-status-server-internal/src/routes/status.ts index 59c7aa23c51d4..1faa623467b58 100644 --- a/packages/core/status/core-status-server-internal/src/routes/status.ts +++ b/packages/core/status/core-status-server-internal/src/routes/status.ts @@ -156,7 +156,7 @@ const getFullStatusResponse = async ({ }; query: { v8format?: boolean; v7format?: boolean }; }): Promise => { - const { version, buildSha, buildNum, buildDate } = config.packageInfo; + const { version, buildSha, buildNum, buildDate, buildFlavor } = config.packageInfo; const versionWithoutSnapshot = version.replace(SNAPSHOT_POSTFIX, ''); let statusInfo: StatusInfo | LegacyStatusInfo; @@ -186,6 +186,7 @@ const getFullStatusResponse = async ({ build_hash: buildSha, build_number: buildNum, build_snapshot: SNAPSHOT_POSTFIX.test(version), + build_flavor: buildFlavor, build_date: buildDate.toISOString(), }, status: statusInfo, diff --git a/src/core/server/integration_tests/status/routes/status.test.ts b/src/core/server/integration_tests/status/routes/status.test.ts index 755b9fc9b46f6..29a55743dd0d5 100644 --- a/src/core/server/integration_tests/status/routes/status.test.ts +++ b/src/core/server/integration_tests/status/routes/status.test.ts @@ -210,6 +210,7 @@ describe('GET /api/status', () => { build_number: 1234, build_snapshot: true, build_date: new Date('2023-05-15T23:12:09.000Z').toISOString(), + build_flavor: 'traditional', }); const metricsMockValue = await firstValueFrom(metrics.getOpsMetrics$()); expect(result.body.metrics).toEqual({