Skip to content

Commit 67d2298

Browse files
Ikuni17delanni
andauthored
[8.19] [CI / FIPS] Add support for FIPS 140-3 agents (#243112) (#245757)
# Backport This will backport the following commits from `main` to `8.19`: - [[CI / FIPS] Add support for FIPS 140-3 agents (#243112)](#243112) <!--- Backport version: 10.2.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Brad White","email":"Ikuni17@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-12-10T02:52:04Z","message":"[CI / FIPS] Add support for FIPS 140-3 agents (#243112)\n\n## Summary\nCloses #242952\n\n- Adds support for FIPS 140-3 agents in CI\n- Adds two GH labels for choosing the agent's FIPS version\n`ci:enable-fips-140-2-agent`, `ci:enable-fips-140-3-agent` and removes\nthe old label `ci:enable-fips-agent`\n - Updated existing PRs to new `140-2` label\n- Updates the FIPS pipeline to use the store cache step and missing disk\nsize updates.\n- Removes bootstrapping from `Verify FIPS Enabled` step because it isn't\nneeded.\n- Adds `fipsIsEnabled` to `@kbn/test` to reduce redundant checks in some\ntests\n- Combines the following env vars into one, `TEST_ENABLE_FIPS_VERSION`,\nwhich contains `\"140-2\"` or `\"140-3\"` when FIPS should be enabled for\nCI.\n - `KBN_ENABLE_FIPS`\n- This initially was to enable FIPS in Kibana itself, but is no longer\nnecessary since it is through configuration `yml`.\n - `FTR_ENABLE_FIPS_AGENT`\n- Was used as a boolean, but didn't describe the new usage with version.\n - `KBN_FIPS_VERSION`\n- Original idea from #243434 for usage with `FTR_ENABLE_FIPS_AGENT`, but\nseemed unnecessary to have two vars.\n\n### Testing\n- [Daily 140-3](https://buildkite.com/elastic/kibana-fips/builds/942)\n- [Daily 140-2](https://buildkite.com/elastic/kibana-fips/builds/944)\n- [PR\n140-3](https://buildkite.com/elastic/kibana-pull-request/builds/369297)\n- [PR\n140-2](https://buildkite.com/elastic/kibana-pull-request/builds/369323)\n- Non FIPS in this PR","sha":"0c2707e6c998bafc6f3cb41a3a8c135d1760e503","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","v9.3.0"],"title":"[CI / FIPS] Add support for FIPS 140-3 agents","number":243112,"url":"https://github.com/elastic/kibana/pull/243112","mergeCommit":{"message":"[CI / FIPS] Add support for FIPS 140-3 agents (#243112)\n\n## Summary\nCloses #242952\n\n- Adds support for FIPS 140-3 agents in CI\n- Adds two GH labels for choosing the agent's FIPS version\n`ci:enable-fips-140-2-agent`, `ci:enable-fips-140-3-agent` and removes\nthe old label `ci:enable-fips-agent`\n - Updated existing PRs to new `140-2` label\n- Updates the FIPS pipeline to use the store cache step and missing disk\nsize updates.\n- Removes bootstrapping from `Verify FIPS Enabled` step because it isn't\nneeded.\n- Adds `fipsIsEnabled` to `@kbn/test` to reduce redundant checks in some\ntests\n- Combines the following env vars into one, `TEST_ENABLE_FIPS_VERSION`,\nwhich contains `\"140-2\"` or `\"140-3\"` when FIPS should be enabled for\nCI.\n - `KBN_ENABLE_FIPS`\n- This initially was to enable FIPS in Kibana itself, but is no longer\nnecessary since it is through configuration `yml`.\n - `FTR_ENABLE_FIPS_AGENT`\n- Was used as a boolean, but didn't describe the new usage with version.\n - `KBN_FIPS_VERSION`\n- Original idea from #243434 for usage with `FTR_ENABLE_FIPS_AGENT`, but\nseemed unnecessary to have two vars.\n\n### Testing\n- [Daily 140-3](https://buildkite.com/elastic/kibana-fips/builds/942)\n- [Daily 140-2](https://buildkite.com/elastic/kibana-fips/builds/944)\n- [PR\n140-3](https://buildkite.com/elastic/kibana-pull-request/builds/369297)\n- [PR\n140-2](https://buildkite.com/elastic/kibana-pull-request/builds/369323)\n- Non FIPS in this PR","sha":"0c2707e6c998bafc6f3cb41a3a8c135d1760e503"}},"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/243112","number":243112,"mergeCommit":{"message":"[CI / FIPS] Add support for FIPS 140-3 agents (#243112)\n\n## Summary\nCloses #242952\n\n- Adds support for FIPS 140-3 agents in CI\n- Adds two GH labels for choosing the agent's FIPS version\n`ci:enable-fips-140-2-agent`, `ci:enable-fips-140-3-agent` and removes\nthe old label `ci:enable-fips-agent`\n - Updated existing PRs to new `140-2` label\n- Updates the FIPS pipeline to use the store cache step and missing disk\nsize updates.\n- Removes bootstrapping from `Verify FIPS Enabled` step because it isn't\nneeded.\n- Adds `fipsIsEnabled` to `@kbn/test` to reduce redundant checks in some\ntests\n- Combines the following env vars into one, `TEST_ENABLE_FIPS_VERSION`,\nwhich contains `\"140-2\"` or `\"140-3\"` when FIPS should be enabled for\nCI.\n - `KBN_ENABLE_FIPS`\n- This initially was to enable FIPS in Kibana itself, but is no longer\nnecessary since it is through configuration `yml`.\n - `FTR_ENABLE_FIPS_AGENT`\n- Was used as a boolean, but didn't describe the new usage with version.\n - `KBN_FIPS_VERSION`\n- Original idea from #243434 for usage with `FTR_ENABLE_FIPS_AGENT`, but\nseemed unnecessary to have two vars.\n\n### Testing\n- [Daily 140-3](https://buildkite.com/elastic/kibana-fips/builds/942)\n- [Daily 140-2](https://buildkite.com/elastic/kibana-fips/builds/944)\n- [PR\n140-3](https://buildkite.com/elastic/kibana-pull-request/builds/369297)\n- [PR\n140-2](https://buildkite.com/elastic/kibana-pull-request/builds/369323)\n- Non FIPS in this PR","sha":"0c2707e6c998bafc6f3cb41a3a8c135d1760e503"}}]}] BACKPORT--> --------- Co-authored-by: Alex Szabo <alex.szabo@elastic.co>
1 parent df4721e commit 67d2298

19 files changed

Lines changed: 169 additions & 79 deletions

File tree

.buildkite/pipeline-resource-definitions/kibana-fips-daily.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,37 @@ spec:
3333
branch: main
3434
cronline: 0 5 * * * America/New_York
3535
env:
36-
KBN_FIPS_VERSION: '140-2'
36+
TEST_ENABLE_FIPS_VERSION: '140-2'
3737
'140-2 Daily build (9.1)':
3838
message: 140-2 Daily build
3939
branch: '9.1'
4040
cronline: 0 5 * * * America/New_York
4141
env:
42-
KBN_FIPS_VERSION: '140-2'
42+
TEST_ENABLE_FIPS_VERSION: '140-2'
4343
'140-2 Daily build (8.19)':
4444
message: 140-2 Daily build
4545
branch: '8.19'
4646
cronline: 0 5 * * * America/New_York
4747
env:
48-
KBN_FIPS_VERSION: '140-2'
48+
TEST_ENABLE_FIPS_VERSION: '140-2'
49+
'140-3 Daily build (main)':
50+
message: 140-3 Daily build
51+
branch: main
52+
cronline: 0 5 * * * America/New_York
53+
env:
54+
TEST_ENABLE_FIPS_VERSION: '140-3'
55+
'140-3 Daily build (9.1)':
56+
message: 140-3 Daily build
57+
branch: '9.1'
58+
cronline: 0 5 * * * America/New_York
59+
env:
60+
TEST_ENABLE_FIPS_VERSION: '140-3'
61+
'140-3 Daily build (8.19)':
62+
message: 140-3 Daily build
63+
branch: '8.19'
64+
cronline: 0 5 * * * America/New_York
65+
env:
66+
TEST_ENABLE_FIPS_VERSION: '140-3'
4967
teams:
5068
kibana-operations:
5169
access_level: MANAGE_BUILD_AND_READ

.buildkite/pipeline-utils/agent_images.ts

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
*/
99

1010
import { dump } from 'js-yaml';
11-
import { BuildkiteClient, BuildkiteAgentTargetingRule } from './buildkite';
11+
import type { BuildkiteAgentTargetingRule } from './buildkite';
12+
import { BuildkiteClient } from './buildkite';
13+
import { FIPS_VERSION, prHasFIPSLabel } from './pr_labels';
1214

1315
const ELASTIC_IMAGES_QA_PROJECT = 'elastic-images-qa';
1416
const ELASTIC_IMAGES_PROD_PROJECT = 'elastic-images-prod';
@@ -21,31 +23,46 @@ const DEFAULT_AGENT_IMAGE_CONFIG: BuildkiteAgentTargetingRule = {
2123
diskSizeGb: 105,
2224
};
2325

24-
const FIPS_AGENT_IMAGE_CONFIG: BuildkiteAgentTargetingRule = {
25-
provider: 'gcp',
26-
image: 'family/kibana-fips-ubuntu-2404',
27-
imageProject: ELASTIC_IMAGES_PROD_PROJECT,
28-
diskSizeGb: 105,
29-
};
30-
3126
const GITHUB_PR_LABELS = process.env.GITHUB_PR_LABELS ?? '';
32-
const FTR_ENABLE_FIPS_AGENT = process.env.FTR_ENABLE_FIPS_AGENT?.toLowerCase() === 'true';
27+
const USE_FIPS_IMAGE_FOR_PR = process.env.TEST_ENABLE_FIPS_VERSION?.match(
28+
new RegExp(`^${FIPS_VERSION.TWO}|${FIPS_VERSION.THREE}$`)
29+
);
3330
const USE_QA_IMAGE_FOR_PR = process.env.USE_QA_IMAGE_FOR_PR?.match(/(1|true)/i);
3431

32+
const getFIPSImage = () => {
33+
let image: string;
34+
35+
if (
36+
process.env.TEST_ENABLE_FIPS_VERSION === FIPS_VERSION.THREE ||
37+
prHasFIPSLabel(FIPS_VERSION.THREE)
38+
) {
39+
image = 'family/kibana-fips-140-3-ubuntu-2404';
40+
} else {
41+
image = 'family/kibana-fips-140-2-ubuntu-2404';
42+
}
43+
44+
return {
45+
provider: 'gcp',
46+
image,
47+
imageProject: ELASTIC_IMAGES_PROD_PROJECT,
48+
diskSizeGb: 105,
49+
};
50+
};
51+
3552
// Narrow the return type with overloads
3653
function getAgentImageConfig(): BuildkiteAgentTargetingRule;
3754
function getAgentImageConfig(options: { returnYaml: true }): string;
3855
function getAgentImageConfig({ returnYaml = false } = {}): string | BuildkiteAgentTargetingRule {
3956
const bk = new BuildkiteClient();
4057
let config: BuildkiteAgentTargetingRule;
4158

42-
if (FTR_ENABLE_FIPS_AGENT || GITHUB_PR_LABELS.includes('ci:enable-fips-agent')) {
43-
config = FIPS_AGENT_IMAGE_CONFIG;
59+
if (USE_FIPS_IMAGE_FOR_PR || prHasFIPSLabel()) {
60+
config = getFIPSImage();
4461

4562
bk.setAnnotation(
4663
'agent image config',
4764
'info',
48-
'#### FIPS Agents Enabled<br />\nFIPS mode can produce new test failures. If you did not intend this remove ```KBN_ENABLE_FIPS``` environment variable and/or the ```ci:enable-fips-agent``` Github label.'
65+
'#### FIPS Agents Enabled<br />\nFIPS mode can produce new test failures. If you did not intend this remove ```TEST_ENABLE_FIPS_VERSION``` environment variable and/or the ```ci:enable-fips-<version>-agent``` Github label.'
4966
);
5067
} else {
5168
config = DEFAULT_AGENT_IMAGE_CONFIG;

.buildkite/pipeline-utils/buildkite/emitPipeline.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

.buildkite/pipeline-utils/ci-stats/pick_test_group_run_order.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { CiStatsClient, TestGroupRunOrderResponse } from './client';
1919

2020
import DISABLED_JEST_CONFIGS from '../../disabled_jest_configs.json';
2121
import { serverless, stateful } from '../../ftr_configs_manifests.json';
22-
import { expandAgentQueue } from '#pipeline-utils';
22+
import { collectEnvFromLabels, expandAgentQueue } from '#pipeline-utils';
2323

2424
const ALL_FTR_MANIFEST_REL_PATHS = serverless.concat(stateful);
2525

@@ -208,32 +208,6 @@ function getEnabledFtrConfigs(patterns?: string[], solutions?: string[]) {
208208
}
209209
}
210210

211-
/**
212-
* Collects environment variables from labels on the PR
213-
* TODO: extract this (and other functions from this big file) to a separate module
214-
*/
215-
function collectEnvFromLabels() {
216-
const LABEL_MAPPING: Record<string, Record<string, string>> = {
217-
'ci:use-chrome-beta': {
218-
USE_CHROME_BETA: 'true',
219-
},
220-
};
221-
222-
const envFromlabels: Record<string, string> = {};
223-
if (!process.env.GITHUB_PR_LABELS) {
224-
return envFromlabels;
225-
} else {
226-
const labels = process.env.GITHUB_PR_LABELS.split(',');
227-
labels.forEach((label) => {
228-
const env = LABEL_MAPPING[label];
229-
if (env) {
230-
Object.assign(envFromlabels, env);
231-
}
232-
});
233-
return envFromlabels;
234-
}
235-
}
236-
237211
export async function pickTestGroupRunOrder() {
238212
const bk = new BuildkiteClient();
239213
const ciStats = new CiStatsClient();

.buildkite/pipeline-utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ export * as CiStats from './ci-stats';
1313
export * from './github';
1414
export * as TestFailures from './test-failures';
1515
export * from './utils';
16+
export * from './pr_labels';
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
export enum FIPS_VERSION {
11+
TWO = '140-2',
12+
THREE = '140-3',
13+
}
14+
15+
export const FIPS_GH_LABELS = {
16+
[FIPS_VERSION.TWO]: 'ci:enable-fips-140-2-agent',
17+
[FIPS_VERSION.THREE]: 'ci:enable-fips-140-3-agent',
18+
};
19+
20+
/**
21+
* Checks if the PR has a specific FIPS label or ANY FIPS label when no version is passed.
22+
*/
23+
export function prHasFIPSLabel(version?: FIPS_VERSION): boolean {
24+
const labels = process.env.GITHUB_PR_LABELS ?? '';
25+
26+
if (!labels) {
27+
return false;
28+
}
29+
30+
if (version) {
31+
return labels.includes(FIPS_GH_LABELS[version]);
32+
}
33+
34+
return Object.values(FIPS_GH_LABELS).some((label) => labels.includes(label));
35+
}
36+
37+
/**
38+
* Available auto-mapped label options, respected by 'collectEnvFromLabels' function.
39+
*/
40+
export const LABEL_MAPPING: Record<string, Record<string, string>> = {
41+
'ci:use-chrome-beta': {
42+
USE_CHROME_BETA: 'true', // Use if you want to run tests with Chrome Beta
43+
},
44+
[FIPS_GH_LABELS[FIPS_VERSION.TWO]]: {
45+
TEST_ENABLE_FIPS_VERSION: FIPS_VERSION.TWO,
46+
},
47+
[FIPS_GH_LABELS[FIPS_VERSION.THREE]]: {
48+
TEST_ENABLE_FIPS_VERSION: FIPS_VERSION.THREE,
49+
},
50+
};
51+
52+
/**
53+
* This function reads available GITHUB_LABELS and maps them to environment variables.
54+
*/
55+
export function collectEnvFromLabels(
56+
labels = process.env.GITHUB_PR_LABELS
57+
): Record<string, string> {
58+
const envFromlabels: Record<string, string> = {};
59+
60+
if (labels) {
61+
const labelArray = labels.split(',');
62+
labelArray.forEach((label) => {
63+
const env = LABEL_MAPPING[label];
64+
if (env) {
65+
Object.assign(envFromlabels, env);
66+
}
67+
});
68+
}
69+
70+
return envFromlabels;
71+
}

.buildkite/pipelines/fips.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
env:
22
DISABLE_CI_STATS_SHIPPING: 'true'
3-
KBN_ENABLE_FIPS: 'true'
43
TEST_BROWSER_HEADLESS: 1
54
agents:
65
provider: 'gcp'
@@ -13,14 +12,27 @@ steps:
1312
timeout_in_minutes: 10
1413
agents:
1514
machineType: n2-standard-2
15+
diskSizeGb: 115
1616

1717
- wait
1818

19+
- command: .buildkite/scripts/steps/store_cache.sh
20+
label: Store Cache for build
21+
timeout_in_minutes: 10
22+
id: store_cache
23+
soft_fail: true
24+
depends_on:
25+
- terrazzo-initial-pipeline-upload
26+
agents:
27+
machineType: n2-standard-2
28+
diskSizeGb: 95
29+
1930
- command: .buildkite/scripts/steps/build_kibana.sh
2031
label: Build Kibana Distribution
2132
agents:
2233
machineType: n2-standard-8
2334
preemptible: true
35+
diskSizeGb: 150
2436
key: build
2537
if: "build.env('KIBANA_BUILD_ID') == null || build.env('KIBANA_BUILD_ID') == ''"
2638
depends_on: pre-build
@@ -44,6 +56,9 @@ steps:
4456
label: 'Pick Test Group Run Order'
4557
depends_on: build
4658
timeout_in_minutes: 10
59+
agents:
60+
machineType: n2-standard-2
61+
diskSizeGb: 115
4762
env:
4863
FTR_CONFIGS_SCRIPT: '.buildkite/scripts/steps/test/ftr_configs.sh'
4964
FTR_EXTRA_ARGS: '$FTR_EXTRA_ARGS'

.buildkite/pipelines/fips/fips_pipeline.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import { emitPipeline, getPipeline } from '#pipeline-utils';
10+
import { emitPipeline, getAgentImageConfig, getPipeline } from '#pipeline-utils';
1111

1212
(async () => {
1313
const pipeline: string[] = [];
1414

1515
try {
16+
pipeline.push(getAgentImageConfig({ returnYaml: true }));
1617
pipeline.push(getPipeline('.buildkite/pipelines/fips.yml', false));
1718

1819
emitPipeline(pipeline);

.buildkite/pipelines/fips/verify_fips_enabled.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
set -euo pipefail
44

55
source .buildkite/scripts/common/util.sh
6-
export DISABLE_BOOTSTRAP_VALIDATION=false
7-
.buildkite/scripts/bootstrap.sh
86
.buildkite/scripts/download_build_artifacts.sh
97

108
echo --- Verify FIPS enabled

.buildkite/pipelines/flaky_tests/pipeline.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import { groups } from './groups.json';
1111
import { TestSuiteType } from './constants';
1212
import type { BuildkiteStep } from '#pipeline-utils';
13-
import { expandAgentQueue } from '#pipeline-utils';
13+
import { expandAgentQueue, collectEnvFromLabels } from '#pipeline-utils';
1414

1515
const configJson = process.env.KIBANA_FLAKY_TEST_RUNNER_CONFIG;
1616
if (!configJson) {
@@ -143,9 +143,11 @@ if (totalJobs > MAX_JOBS) {
143143
}
144144

145145
const steps: BuildkiteStep[] = [];
146+
const envFromLabels = collectEnvFromLabels(process.env.GITHUB_PR_LABELS);
146147
const pipeline = {
147148
env: {
148149
IGNORE_SHIP_CI_STATS_ERROR: 'true',
150+
...envFromLabels,
149151
},
150152
steps,
151153
};

0 commit comments

Comments
 (0)