1010import { dump } from 'js-yaml' ;
1111import type { BuildkiteAgentTargetingRule } from './buildkite' ;
1212import { BuildkiteClient } from './buildkite' ;
13+ import { FIPS_VERSION , prHasFIPSLabel } from './pr_labels' ;
1314
1415const ELASTIC_IMAGES_QA_PROJECT = 'elastic-images-qa' ;
1516const ELASTIC_IMAGES_PROD_PROJECT = 'elastic-images-prod' ;
@@ -19,32 +20,49 @@ const DEFAULT_AGENT_IMAGE_CONFIG: BuildkiteAgentTargetingRule = {
1920 provider : 'gcp' ,
2021 image : 'family/kibana-ubuntu-2404' ,
2122 imageProject : ELASTIC_IMAGES_PROD_PROJECT ,
22- } ;
23-
24- const FIPS_AGENT_IMAGE_CONFIG : BuildkiteAgentTargetingRule = {
25- provider : 'gcp' ,
26- image : 'family/kibana-fips-ubuntu-2404' ,
27- imageProject : ELASTIC_IMAGES_PROD_PROJECT ,
23+ diskSizeGb : 105 ,
2824} ;
2925
3026const GITHUB_PR_LABELS = process . env . GITHUB_PR_LABELS ?? '' ;
31- 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+ ) ;
3230const USE_QA_IMAGE_FOR_PR = process . env . USE_QA_IMAGE_FOR_PR ?. match ( / ( 1 | t r u e ) / i) ;
3331
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+
3452// Narrow the return type with overloads
3553function getAgentImageConfig ( ) : BuildkiteAgentTargetingRule ;
3654function getAgentImageConfig ( options : { returnYaml : true } ) : string ;
3755function getAgentImageConfig ( { returnYaml = false } = { } ) : string | BuildkiteAgentTargetingRule {
3856 const bk = new BuildkiteClient ( ) ;
3957 let config : BuildkiteAgentTargetingRule ;
4058
41- if ( FTR_ENABLE_FIPS_AGENT || GITHUB_PR_LABELS . includes ( 'ci:enable-fips-agent' ) ) {
42- config = FIPS_AGENT_IMAGE_CONFIG ;
59+ if ( USE_FIPS_IMAGE_FOR_PR || prHasFIPSLabel ( ) ) {
60+ config = getFIPSImage ( ) ;
4361
4462 bk . setAnnotation (
4563 'agent image config' ,
4664 'info' ,
47- '#### 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.'
4866 ) ;
4967 } else {
5068 config = DEFAULT_AGENT_IMAGE_CONFIG ;
@@ -61,7 +79,7 @@ function getAgentImageConfig({ returnYaml = false } = {}): string | BuildkiteAge
6179 return config ;
6280}
6381
64- const expandAgentQueue = ( queueName : string = 'n2-4-spot' ) => {
82+ const expandAgentQueue = ( queueName : string = 'n2-4-spot' , diskSizeGb ?: number ) => {
6583 const [ kind , cores , addition ] = queueName . split ( '-' ) ;
6684 const additionalProps =
6785 {
@@ -72,6 +90,7 @@ const expandAgentQueue = (queueName: string = 'n2-4-spot') => {
7290 return {
7391 ...getAgentImageConfig ( ) ,
7492 machineType : `${ kind } -standard-${ cores } ` ,
93+ ...( diskSizeGb ? { diskSizeGb } : { } ) ,
7594 ...additionalProps ,
7695 } ;
7796} ;
0 commit comments