blob: 545aa4cf75323b3ca56429cd5b2046195d09ae70 [file] [log] [blame]
vnaumov33747e12020-05-04 17:35:20 +02001package com.mirantis.mk
vnaumov33747e12020-05-04 17:35:20 +02002
azvyagintsevc17d14b2022-06-06 19:06:33 +03003import static groovy.json.JsonOutput.toJson
Sergey Lalov78659102024-02-15 16:57:21 +04004import java.util.regex.Pattern
azvyagintsevc17d14b2022-06-06 19:06:33 +03005
vnaumov33747e12020-05-04 17:35:20 +02006/**
7 *
8 * KaaS Component Testing Utilities
9 *
10 */
11
Владислав Наумовe5345812020-08-12 16:30:20 +020012/**
13 * Check KaaS Core CICD feature flags
14 * such triggers can be used in case of switching between pipelines,
15 * conditions inside pipelines to reduce dependency on jenkins job builder and jenkins job templates itself
16 *
17 * @return (map)[
18 * ffNameEnabled: (bool) True/False
19 * ]
20 */
21def checkCoreCIFeatureFlags() {
22 def common = new com.mirantis.mk.Common()
23 def ff = [
24 build_artifacts_upgrade: false,
25 ]
26
27 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
28 if (commitMsg ==~ /(?s).*\[ci-build-artifacts-upgrade\].*/) {
29 ff['build_artifacts_upgrade'] = true
30 }
31
32 common.infoMsg("Core ci feature flags status: ${ff}")
33 return ff
34}
vnaumov33747e12020-05-04 17:35:20 +020035
36/**
azvyagintseva12230a2020-06-05 13:24:06 +030037 * Determine scope of test suite against per-commit KaaS deployment based on keywords
Владислав Наумов81777472021-03-09 15:14:27 +040038 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
azvyagintseva12230a2020-06-05 13:24:06 +030039 *
40 * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs
41 * Example scheme:
Владислав Наумовe5345812020-08-12 16:30:20 +020042 * New CR pushed in kubernetes/lcm-ansible -> parsing it'cs commit body and combine test-suite -> trigger deployment jobs from kaas/core
azvyagintseva12230a2020-06-05 13:24:06 +030043 * manage test-suite through Jenkins Job Parameters
44 *
Владислав Наумов6c2afff2020-06-05 12:54:53 +020045 * @return (map)[
46 * deployChildEnabled: (bool) True if need to deploy child cluster during demo-run
47 * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run
azvyagintseva12230a2020-06-05 13:24:06 +030048 * ]
49 */
vnaumov33747e12020-05-04 17:35:20 +020050def checkDeploymentTestSuite() {
vnaumovbdb90222020-05-04 18:25:50 +020051 def common = new com.mirantis.mk.Common()
52
vnaumov33747e12020-05-04 17:35:20 +020053 // Available triggers and its sane defaults
Владислав Наумов44c64b72020-12-04 20:22:53 +010054 def seedMacOs = env.SEED_MACOS ? env.SEED_MACOS.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020055 def deployChild = env.DEPLOY_CHILD_CLUSTER ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false
56 def upgradeChild = env.UPGRADE_CHILD_CLUSTER ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false
Sergey Lalovc1cb49f2022-09-27 01:16:25 +040057 def fullUpgradeChild = env.FULL_UPGRADE_CHILD_CLUSTER ? env.FULL_UPGRADE_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov38ee4382022-01-27 16:21:51 +040058 def mosDeployChild = env.DEPLOY_MOS_CHILD_CLUSTER ? env.DEPLOY_MOS_CHILD_CLUSTER.toBoolean() : false
59 def mosUpgradeChild = env.UPGRADE_MOS_CHILD_CLUSTER ? env.UPGRADE_MOS_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov74504372021-05-21 17:01:06 +040060 def customChildRelease = env.KAAS_CHILD_CLUSTER_RELEASE_NAME ? env.KAAS_CHILD_CLUSTER_RELEASE_NAME : ''
slalov021171f2022-03-04 14:48:38 +040061 def mosTfDeploy = env.MOS_TF_DEPLOY ? env.MOS_TF_DEPLOY.toBoolean() : false
Владислав Наумов0dc99252020-11-13 13:30:48 +010062 def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false
Владислав Наумовcdbd84e2020-12-01 16:51:09 +010063 def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false
Vladislav Naumov7930ab22021-11-22 18:24:24 +010064 def runBYOMatrix = env.RUN_BYO_MATRIX ? env.RUN_BYO_MATRIX.toBoolean() : false
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +040065 def defaultBYOOs = env.DEFAULT_BYO_OS ? env.DEFAULT_BYO_OS.toString() : 'ubuntu'
Владислав Наумов6c2afff2020-06-05 12:54:53 +020066 def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
slalov1202bba2022-04-20 22:31:07 +040067 def autoUpgradeMgmt = env.AUTO_UPGRADE_MCC ? env.AUTO_UPGRADE_MCC.toBoolean() : false
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +040068 def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false
Sergey Lalovb2f60372022-09-20 23:58:47 +040069 def deployOsOnMos = env.DEPLOY_OS_ON_MOS? env.DEPLOY_OS_ON_MOS.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020070 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +040071 def runUie2eNew = env.RUN_UI_E2E_NEW ? env.RUN_UI_E2E_NEW.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020072 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
Sergey Lalovafcc0432023-04-13 14:59:06 +040073 def runMgmtConformanceNetworkPolicy = env.RUN_MGMT_CFM_NETWORK_POLICY ? env.RUN_MGMT_CFM_NETWORK_POLICY.toBoolean() : false
Владислав Наумов9cec55d2021-08-03 15:00:59 +020074 def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +020075 def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false
Mikhail Ivanov2907e4d2022-04-25 16:41:21 +040076 def runProxyChildTest = env.RUN_PROXY_CHILD_TEST ? env.RUN_PROXY_CHILD_TEST.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020077 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
Sergey Lalov012496a2023-11-27 15:57:52 +040078 def runChildStacklightHa = env.RUN_STACKLIGHT_CHILD_HA ? env.RUN_STACKLIGHT_CHILD_HA.toBoolean() : false
Sergey Lalovafcc0432023-04-13 14:59:06 +040079 def runChildConformanceNetworkPolicy = env.RUN_CHILD_CFM_NETWORK_POLICY ? env.RUN_CHILD_CFM_NETWORK_POLICY.toBoolean() : false
vryzhenkinb286bd82023-04-04 07:17:52 +040080 def runChildHPA = env.RUN_CHILD_HPA ? env.RUN_CHILD_HPA.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020081 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Vladislav Naumov42b71dc2021-11-22 13:09:42 +010082 def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
slalov13e579c2022-01-31 21:37:02 +040083 def runMaintenanceTest = env.RUN_MAINTENANCE_TEST ? env.RUN_MAINTENANCE_TEST.toBoolean() : false
slalov0a4947a2022-06-09 15:44:35 +040084 def runContainerregistryTest = env.RUN_CONTAINER_REGISTRY_TEST ? env.RUN_CONTAINER_REGISTRY_TEST.toBoolean() : false
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +030085 def runMgmtDeleteMasterTest = env.RUN_MGMT_DELETE_MASTER_TEST ? env.RUN_MGMT_DELETE_MASTER_TEST.toBoolean() : false
86 def runRgnlDeleteMasterTest = env.RUN_RGNL_DELETE_MASTER_TEST ? env.RUN_RGNL_DELETE_MASTER_TEST.toBoolean() : false
87 def runChildDeleteMasterTest = env.RUN_CHILD_DELETE_MASTER_TEST ? env.RUN_CHILD_DELETE_MASTER_TEST.toBoolean() : false
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +030088 def runGracefulRebootTest = env.RUN_GRACEFUL_REBOOT_TEST ? env.RUN_GRACEFUL_REBOOT_TEST.toBoolean() : false
Sergey Lalovbc68d752022-11-08 13:40:53 +040089 def pauseForDebug = env.PAUSE_FOR_DEBUG ? env.PAUSE_FOR_DEBUG.toBoolean() : false
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +030090 def runChildMachineDeletionPolicyTest = env.RUN_CHILD_MACHINE_DELETION_POLICY_TEST ? env.RUN_CHILD_MACHINE_DELETION_POLICY_TEST.toBoolean() : false
Sergey Lalovd3e030e2023-03-16 14:32:47 +040091 def runChildCustomCertTest = env.RUN_CHILD_CUSTOM_CERT_TEST ? env.RUN_CHILD_CUSTOM_CERT_TEST.toBoolean() : false
Sergey Lalov430fcd72023-03-20 17:19:44 +040092 def runByoChildCustomCertTest = env.RUN_BYO_CHILD_CUSTOM_CERT_TEST ? env.RUN_BYO_CHILD_CUSTOM_CERT_TEST.toBoolean() : false
Sergey Lalovf6fbfea2023-04-06 17:05:40 +040093 def runMgmtCustomCacheCertTest = env.RUN_MGMT_CUSTOM_CACHE_CERT_TEST ? env.RUN_MGMT_CUSTOM_CACHE_CERT_TEST.toBoolean() : false
Sergey Lalov48e69022023-07-25 16:08:00 +040094 def runMkeCustomCertTest = env.RUN_MKE_CUSTOM_CERT_TEST ? env.RUN_MKE_CUSTOM_CERT_TEST.toBoolean() : false
Sergey Lalov62c28312023-10-18 19:23:59 +040095 def runCustomHostnames = env.RUN_CUSTOM_HOSTNAMES ? env.RUN_CUSTOM_HOSTNAMES.toBoolean() : false
vryzhenkin504dfc92023-11-01 15:49:47 +040096 def slLatest = env.SL_LATEST ? env.SL_LATEST.toBoolean() : false
vryzhenkina8d74e72024-02-26 14:59:37 +040097 def coreKeycloakLdap = env.CORE_KEYCLOAK_LDAP_ENABLED ? env.CORE_KEYCLOAK_LDAP_ENABLED.toBoolean() : false
Sergey Lalovd7593ab2024-01-11 13:40:13 +040098 def disableKubeApiAudit = env.DISABLE_KUBE_API_AUDIT ? env.DISABLE_KUBE_API_AUDIT.toBoolean() : false
Sergey Lalov7c2377e2023-12-15 23:14:45 +040099 def customSlackChannel = env.SLACK_CHANNEL_NOTIFY ? env.SLACK_CHANNEL_NOTIFY : ''
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000100 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
101 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
102 enabled: false,
103 managementLocation: '',
104 regionLocation: '',
105 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200106
Владислав Наумовb8305e22021-02-10 17:23:12 +0100107 // proxy customization
108 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200109 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
110 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +0200111 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +0100112 ]
113
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200114 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +0200115 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000116 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +0200117 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000118 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
119 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
120 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400121 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200122 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +0300123 def enableBMDemo = true
Sergey Lalovc62e9382024-01-29 15:19:15 +0400124 def enablebmCoreDemo = env.ALLOW_BM_CORE_ON_DEMAND ? env.ALLOW_BM_CORE_ON_DEMAND.toBoolean() : false
Sergey Lalovd0e20852023-08-17 19:11:19 +0400125 def bmCoreCleanup = env.BM_CORE_CLEANUP ? env.BM_CORE_CLEANUP : true
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400126 def enableArtifactsBuild = true
Sergey Lalovd0e20852023-08-17 19:11:19 +0400127 def bmDeployType = 'virtual'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400128 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300129 def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500130 def enableVsphereRHEL = env.VSPHERE_DEPLOY_RHEL ? env.VSPHERE_DEPLOY_RHEL.toBoolean() : false
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300131 def childOsBootFromVolume = env.OPENSTACK_BOOT_FROM_VOLUME ? env.OPENSTACK_BOOT_FROM_VOLUME.toBoolean() : false
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400132 def bootstrapV2Scenario = env.BOOTSTRAP_V2_ENABLED ? env.BOOTSTRAP_V2_ENABLED.toBoolean() : false
Sergey Lalovacec3c12022-07-20 16:00:14 +0400133 def equinixMetalV2Metro = env.EQUINIX_MGMT_METRO ? env.EQUINIX_MGMT_METRO : ''
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400134 def enableFips = env.ENABLE_FIPS ? env.ENABLE_FIPS.toBoolean() : false
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400135 def enableMkeDebug = env.ENABLE_MKE_DEBUG ? env.ENABLE_MKE_DEBUG.toBoolean() : false
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300136 def aioCluster = env.AIO_CLUSTER ? env.AIO_CLUSTER.toBoolean() : false
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100137 def useVsphereVvmtObjects = env.VSPHERE_USE_VVMT_OBJECTS ? env.VSPHERE_USE_VVMT_OBJECTS.toBoolean() : false
vryzhenkin4fd3f242023-03-29 15:13:46 +0400138 def enableBv2Smoke = true
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400139 def runCacheWarmup = env.CACHE_WARMUP_ENABLED ? env.CACHE_WARMUP_ENABLED.toBoolean() : false
vryzhenkin211a4e82023-11-23 12:48:27 +0400140 def cveScan = false
vnaumov33747e12020-05-04 17:35:20 +0200141
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200142 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +0100143 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
144 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200145 common.warningMsg('Forced running offline mgmt deployment, some provider CDN regions for mgmt deployment may be set to *public-ci* to verify proxy configuration')
Владислав Наумовb8305e22021-02-10 17:23:12 +0100146 }
Sergey Kolekonov5995dfd2023-07-06 16:09:43 +0600147 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
148 upgradeMgmt = true
149 }
150 if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) {
151 autoUpgradeMgmt = true
152 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100153 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
154 seedMacOs = true
155 }
Sergey Lalovafcc0432023-04-13 14:59:06 +0400156 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ ||
157 upgradeChild || runChildConformance || runProxyChildTest || runChildHPA || runChildConformanceNetworkPolicy) {
vnaumov33747e12020-05-04 17:35:20 +0200158 deployChild = true
159 }
160 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
161 deployChild = true
162 upgradeChild = true
163 }
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400164 if (commitMsg ==~ /(?s).*\[child-upgrade-full\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade-full.*/) {
165 deployChild = true
166 upgradeChild = true
Sergey Lalova048df92023-06-19 19:36:41 +0400167 common.warningMsg("2-step child updates are not testing (PRODX-33510)")
168 //TODO: revert after start testing the two-step upgrade again (PRODX-33510)
169 //fullUpgradeChild = true
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400170 }
Sergey Kolekonov5995dfd2023-07-06 16:09:43 +0600171 if ((upgradeMgmt || autoUpgradeMgmt) && deployChild) {
172 upgradeChild = true
173 common.warningMsg('child upgrade is automatically enabled as mgmt upgrade and child deploy are enabled')
174 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400175 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
176 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400177 // override child version when it set explicitly
178 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400179 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400180 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
181 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400182 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
183 mosDeployChild = true
184 }
185 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
186 mosDeployChild = true
187 mosUpgradeChild = true
188 }
Sergey Kolekonov5995dfd2023-07-06 16:09:43 +0600189 if ((upgradeMgmt || autoUpgradeMgmt) && mosDeployChild) {
190 mosUpgradeChild = true
191 common.warningMsg('MOSK child upgrade is automatically enabled as mgmt upgrade and MOSK child deploy are enabled')
192 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100193 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
194 attachBYO = true
195 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100196 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
197 attachBYO = true
198 upgradeBYO = true
199 }
Sergey Lalovacec3c12022-07-20 16:00:14 +0400200 if (commitMsg ==~ /(?s).*\[ui-test-on-all-providers\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-test-on-all-providers.*/) {
201 enableVsphereDemo = true
202 enableOSDemo = true
203 awsOnDemandDemo = true
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000204 azureOnDemandDemo = true
205 equinixOnDemandDemo = true
Sergey Lalovacec3c12022-07-20 16:00:14 +0400206 equinixMetalV2OnDemandDemo = true
207 runUie2e = true
Sergey Lalovacec3c12022-07-20 16:00:14 +0400208 // Edit after fix PRODX-3961
209 enableBMDemo = false
210 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400211 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
212 if (commitMsg ==~ /(?s).*\[run-byo-matrix\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*run-byo-matrix\.*/ || byoDeployMatches.size() > 0) {
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100213 runBYOMatrix = true
214
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400215 if (byoDeployMatches.size() > 0) {
216 defaultBYOOs = byoDeployMatches[0][2]
217 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
218 }
219
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100220 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
221 attachBYO = false
222 upgradeBYO = false
223 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400224 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
225 enableLMALogging = true
226 }
Sergey Lalovb2f60372022-09-20 23:58:47 +0400227 if (commitMsg ==~ /(?s).*\[deploy-os-on-mos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*deploy-os-on-mos.*/) {
228 deployOsOnMos = true
229 mosDeployChild = true
Sergey Lalovb2f60372022-09-20 23:58:47 +0400230 }
Sergey Lalovd0e20852023-08-17 19:11:19 +0400231
232 if (commitMsg ==~ /(?s).*\[half-virtual\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*half-virtual.*/ || upgradeMgmt) {
233 bmDeployType = 'half-virtual'
234 common.infoMsg('Half-virtual will be deployed by default on upgrade case')
235 }
236
Sergey Lalov95040602023-03-07 16:42:16 +0400237 if (commitMsg ==~ /(?s).*\[ui-e2e-nw\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-nw.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200238 runUie2e = true
239 }
Sergey Lalov95040602023-03-07 16:42:16 +0400240 if (commitMsg ==~ /(?s).*\[ui-e2e-pw\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-pw.*/) {
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400241 runUie2eNew = true
242 }
vnaumov33747e12020-05-04 17:35:20 +0200243 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
244 runMgmtConformance = true
245 }
Sergey Lalovafcc0432023-04-13 14:59:06 +0400246 if (commitMsg ==~ /(?s).*\[mgmt-cfm-netpolicy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm-netpolicy.*/) {
247 runMgmtConformanceNetworkPolicy = true
248 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200249 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
250 runMgmtUserControllerTest = true
251 }
slalov574123e2022-04-06 17:24:19 +0400252 if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) {
253 runProxyChildTest = true
254 deployChild = true
255 common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed')
256 }
vnaumov33747e12020-05-04 17:35:20 +0200257 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
258 runChildConformance = true
259 deployChild = true
260 }
Sergey Lalovafcc0432023-04-13 14:59:06 +0400261 if (commitMsg ==~ /(?s).*\[child-cfm-netpolicy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm-netpolicy.*/) {
262 runChildConformanceNetworkPolicy = true
263 deployChild = true
264 }
vryzhenkinb286bd82023-04-04 07:17:52 +0400265 if (commitMsg ==~ /(?s).*\[child-hpa\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-hpa.*/) {
266 runChildHPA = true
267 deployChild = true
268 }
Sergey Lalov012496a2023-11-27 15:57:52 +0400269 if (commitMsg ==~ /(?s).*\[child-sl-ha\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-sl-ha.*/) {
270 runChildStacklightHa = true
271 deployChild = true
272 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200273 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
274 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400275 enableLMALogging = true
276 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400277 }
slalov13e579c2022-01-31 21:37:02 +0400278 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
279 runMaintenanceTest = true
280 }
slalov0a4947a2022-06-09 15:44:35 +0400281 if (commitMsg ==~ /(?s).*\[container-registry-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*container-registry-test.*/) {
282 runContainerregistryTest = true
283 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300284 if (commitMsg ==~ /(?s).*\[mgmt-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-delete-master-test.*/) {
285 runMgmtDeleteMasterTest = true
286 }
287 if (commitMsg ==~ /(?s).*\[rgnl-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*rgnl-delete-master-test.*/) {
288 runRgnlDeleteMasterTest = true
289 }
290 if (commitMsg ==~ /(?s).*\[child-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-delete-master-test.*/) {
Sergey Lalov47e21592023-07-18 23:36:32 +0400291 if (!mosDeployChild) {
292 deployChild = true
293 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300294 runChildDeleteMasterTest = true
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300295 common.infoMsg('Child cluster deployment will be enabled since delete child master node test suite will be executed')
296 }
297 if (commitMsg ==~ /(?s).*\[child-machine-deletion-policy-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-machine-deletion-policy-test.*/) {
298 runChildMachineDeletionPolicyTest = true
299 deployChild = true
300 common.infoMsg('Child cluster deployment will be enabled since machine deletion child policy test suite will be executed')
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300301 }
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300302 if (commitMsg ==~ /(?s).*\[graceful-reboot-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*graceful-reboot-test.*/) {
303 runGracefulRebootTest = true
304 }
Sergey Lalovbc68d752022-11-08 13:40:53 +0400305 if (commitMsg ==~ /(?s).*\[pause-for-debug\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*pause-for-debug.*/) {
306 pauseForDebug = true
307 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200308 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
309 proxyConfig['childOffline'] = true
310 deployChild = true
311 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200312 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
313 proxyConfig['childOffline'] = true
314 proxyConfig['childProxy'] = true
315 deployChild = true
316 }
vnaumov33747e12020-05-04 17:35:20 +0200317 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
318 fetchServiceBinaries = true
319 }
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000320 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
321 equinixOnAwsDemo = true
322 common.warningMsg('Forced running child cluster deployment on EQUINIX METAL provider based on AWS management cluster, triggered on patchset using custom keyword: \'[equinix-on-aws]\' ')
323 }
324 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
325 azureOnAwsDemo = true
326 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
327 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200328 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
329 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
330 attachBYO ||
331 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100332 runBYOMatrix ||
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000333 seedMacOs ||
334 equinixOnAwsDemo ||
335 azureOnAwsDemo) {
Владислав Наумов2d3db332021-06-15 15:19:19 +0200336
vnaumov33747e12020-05-04 17:35:20 +0200337 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200338 common.warningMsg('Running additional kaas deployment with AWS provider, may be forced due applied trigger cross dependencies, follow docs to clarify info')
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200339 }
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000340 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
341 equinixOnDemandDemo = true
342 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200343 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200344 equinixMetalV2OnDemandDemo = true
345 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100346 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
347 equinixMetalV2OnDemandDemo = true
348 equinixMetalV2ChildDiffMetro = true
349 }
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000350 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
351 azureOnDemandDemo = true
352 }
Sergey Lalov10cb3502023-03-27 22:13:49 +0400353 if (commitMsg ==~ /(?s).*\[disable-all-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-all-demo\.*/) {
354 enableVsphereDemo = false
355 enableOSDemo = false
356 enableBMDemo = false
Sergey Lalov781fccc2023-10-12 21:55:17 +0400357 enableBv2Smoke = false
358 common.errorMsg('vSphere, BM, Openstack, demo deployments and Bootstrap v2 smoke checks will be aborted, VF -1 will be set')
Sergey Lalov10cb3502023-03-27 22:13:49 +0400359 }
360
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200361 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
362 enableOSDemo = false
363 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200364 }
365
azvyagintsev1761bdc2020-09-04 17:24:12 +0300366 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
367 enableBMDemo = false
368 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
369 }
370
Sergey Lalovd0e20852023-08-17 19:11:19 +0400371 if (commitMsg ==~ /(?s).*\[bm-core-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bm-core-demo\\.*/) {
372 enablebmCoreDemo = true
373 enableBMDemo = false
374 }
375
Sergey Kolekonov2204f3a2024-03-08 20:03:00 +0500376 // Projects may or may not have BM Core demo enabled by default
377 if (commitMsg ==~ /(?s).*\[disable-bm-core-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-core-demo\.*/) {
378 enablebmCoreDemo = false
379 common.errorMsg('BM Core demo deployment will be aborted, VF -1 will be set')
380 }
381
Sergey Lalovd0e20852023-08-17 19:11:19 +0400382 if (commitMsg ==~ /(?s).*\[disable-bm-core-cleanup\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-core-cleanup\\.*/) {
383 bmCoreCleanup = false
384 }
385
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400386 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
387 enableVsphereDemo = false
388 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
389 }
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300390 if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) {
391 enableVsphereUbuntu = true
392 common.warningMsg('Ubuntu will be used to deploy vsphere machines')
393 }
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500394 if (commitMsg ==~ /(?s).*\[vsphere-rhel\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-rhel\.*/) {
395 enableVsphereRHEL = true
396 common.warningMsg('RHEL will be used to deploy vsphere machines')
397 }
vryzhenkin4fd3f242023-03-29 15:13:46 +0400398 if (commitMsg ==~ /(?s).*\[disable-bv2-smoke\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bv2-smoke\.*/) {
399 enableBv2Smoke = false
400 common.errorMsg('Bootstrap v2 smoke checks will be aborted, WF -1 will be set')
401 }
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400402
vryzhenkin211a4e82023-11-23 12:48:27 +0400403 if (commitMsg ==~ /(?s).*\[cve-scan\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*cve-scan\.*/) {
404 cveScan = true
405 common.errorMsg('CVE Scan job enabled')
406 }
407
Sergey Lalov7c2377e2023-12-15 23:14:45 +0400408 def slackChannelMatches = (commitMsg =~ /(\[slack-channel\s*[#@](\S+)])/)
409 if (slackChannelMatches.size() > 0) {
410 // override chanenel notify when it set explicitly
411 customSlackChannel = slackChannelMatches[0][0].split("slack-channel")[1].replaceAll('[\\[\\]]', '').trim()
412 common.warningMsg("Forced send notify to ${customSlackChannel} channel")
413 }
414
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400415 if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
416 enableArtifactsBuild = false
417 common.errorMsg('artifacts build will be aborted, VF -1 will be set')
418 }
419
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300420 if (commitMsg ==~ /(?s).*\[child-os-boot-from-volume\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-os-boot-from-volume\.*/) {
421 childOsBootFromVolume = true
422 common.warningMsg('OS will be booted from Ceph volumes')
423 }
424
Sergey Lalovd5efcd52023-03-01 22:42:17 +0400425 if (commitMsg ==~ /(?s).*\[child-custom-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-custom-cert-test\.*/) {
426 runChildCustomCertTest = true
427 deployChild = true
428 common.warningMsg('Child cluster deployment will be enabled since custom cert child test suite will be executed')
429 }
430
Sergey Lalovf6fbfea2023-04-06 17:05:40 +0400431 if (commitMsg ==~ /(?s).*\[mgmt-custom-cache-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-custom-cache-cert-test\.*/) {
432 runMgmtCustomCacheCertTest = true
433 deployChild = true
434 common.warningMsg('Child cluster deployment will be enabled as the test replaces the mgmt and cluster childcertificates')
435 }
436
Sergey Lalov48e69022023-07-25 16:08:00 +0400437 if (commitMsg ==~ /(?s).*\[mke-custom-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mke-custom-cert-test\.*/) {
438 runMkeCustomCertTest = true
439 }
440
Sergey Lalov62c28312023-10-18 19:23:59 +0400441 if (commitMsg ==~ /(?s).*\[custom-hostnames\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*custom-hostnames\.*/) {
442 runCustomHostnames = true
443 common.warningMsg('All clusters will be deployed with Custom Hostnames')
444 }
445
vryzhenkin504dfc92023-11-01 15:49:47 +0400446 if (commitMsg ==~ /(?s).*\[sl-latest\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*sl-latest\.*/) {
447 slLatest = true
448 common.warningMsg('All clusters will be deployed with Stacklight version from artifact-metadata')
449 }
450
vryzhenkina8d74e72024-02-26 14:59:37 +0400451 if (commitMsg ==~ /(?s).*\[keycloak-ldap\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*keycloak-ldap\.*/) {
452 coreKeycloakLdap = true
453 common.warningMsg('Management cluster will be deployed with LDAP integration enabled and after-deployment checks will be executed')
454 }
455
Sergey Lalovd7593ab2024-01-11 13:40:13 +0400456 if (commitMsg ==~ /(?s).*\[disable-kube-api-audit\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-kube-api-audit\.*/) {
457 disableKubeApiAudit = true
458 common.warningMsg('Disable KUBE API audit for mgmt cluster')
459 }
460
Sergey Lalov430fcd72023-03-20 17:19:44 +0400461 if (commitMsg ==~ /(?s).*\[byo-child-custom-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-child-custom-cert-test\.*/) {
462 runByoChildCustomCertTest = true
463 attachBYO = true
464 common.warningMsg('Byo child cluster deployment will be enabled since custom cert child test suite will be executed')
465 }
466
vnaumov33747e12020-05-04 17:35:20 +0200467 // TODO (vnaumov) remove below condition after moving all releases to UCP
468 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
469 if (ucpChildMatches.size() > 0) {
470 deployChild = true
471 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
472
473 // TODO(vnaumov) delete after ucp upgrades support
474 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
475 upgradeChild = false
476 }
477
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300478 if (commitMsg ==~ /(?s).*\[aio-cluster\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aio-cluster.*/) {
479 aioCluster = true
480 }
481
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400482 if (commitMsg ==~ /(?s).*\[cache-warmup\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*cache-warmup.*/) {
483 runCacheWarmup = true
484 }
485
486 if (runCacheWarmup && (!deployChild && !mosDeployChild)) {
487 runCacheWarmup = false
488 common.errorMsg('Child cluster deployment is not enabled, skipping Cache Warmup')
489 }
490
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000491 // multiregional tests
492 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
493 if (multiRegionalMatches.size() > 0) {
494 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
495 }
496 switch (multiregionalMappings['managementLocation']) {
497 case 'aws':
498 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
499 awsOnDemandDemo = true
500
501 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
502 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
503 }
504 break
505 case 'os':
506 if (enableOSDemo == false) {
507 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
508 }
509 break
510 case 'vsphere':
511 if (enableVsphereDemo == false) {
512 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
513 }
514 break
515 case 'equinix':
516 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
517 equinixOnDemandDemo = true
518 break
519 case 'equinixmetalv2':
520 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
521 equinixMetalV2OnDemandDemo = true
522 break
523 case 'azure':
524 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
525 azureOnDemandDemo = true
526 break
527 }
528
Владислав Наумовb8305e22021-02-10 17:23:12 +0100529 // CDN configuration
530 def cdnConfig = [
531 mgmt: [
Sergey Lalovde909ea2023-05-31 20:21:02 +0400532 openstack: 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200533 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100534 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200535 equinix: 'public-ci',
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000536 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200537 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100538 ]
539
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400540 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
541 openstackIMC = 'eu'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400542 }
Sergey Lalovac6a8e72023-12-19 01:28:41 +0400543
544 if (openstackIMC == 'eu') {
slalov021171f2022-03-04 14:48:38 +0400545 // use internal-eu because on internal-ci with eu cloud image pull takes much time
Sergey Lalovde909ea2023-05-31 20:21:02 +0400546 def cdnRegion = 'internal-eu'
slalov021171f2022-03-04 14:48:38 +0400547 cdnConfig['mgmt']['openstack'] = cdnRegion
548 }
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400549
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100550 // calculate weight of current demo run to manage lockable resources
Sergey Lalov46deb442022-08-18 12:11:03 +0400551 def demoWeight = deployChild ? 2 : 1 // management = 1, child += 1
Sergey Lalov95040602023-03-07 16:42:16 +0400552 if (runUie2e || runUie2eNew) {
Sergey Lalov46deb442022-08-18 12:11:03 +0400553 demoWeight += 1
554 }
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100555
Sergey Laloveb611b22023-09-22 16:59:09 +0400556 if (commitMsg ==~ /(?s).*\[bootstrapv1-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv1-scenario\.*/) {
557 bootstrapV2Scenario = false
558 }
559
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400560 if (commitMsg ==~ /(?s).*\[bootstrapv2-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv2-scenario\.*/) {
561 bootstrapV2Scenario = true
562 }
563
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400564 if (commitMsg ==~ /(?s).*\[enable-fips\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*enable-fips\.*/) {
565 enableFips = true
566 }
567
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400568 if (commitMsg ==~ /(?s).*\[enable-mke-debug\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*enable-mke-debug\.*/) {
569 enableMkeDebug = true
570 }
571
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100572 if (commitMsg ==~ /(?s).*\[vsphere-vvmt-obj\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-vvmt-obj\.*/) {
573 useVsphereVvmtObjects = true
574 }
575
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300576 // parse equinixmetalv2-metro trigger
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300577 def equinixMetalV2MetroMatcher = (commitMsg =~ /\[equinixmetalv2-metro(\s+.*)?\]/)
578 if (equinixMetalV2OnDemandDemo && equinixMetalV2MetroMatcher.size() > 0) {
Sergey Zhemerdeevcc785e42022-07-22 17:15:47 +0300579 equinixMetalV2Metro = equinixMetalV2MetroMatcher[0][1].trim().toLowerCase()
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300580 common.infoMsg("Forced Equnix mgmt deployment using custom metro ${equinixMetalV2Metro}")
581 }
582
vnaumov33747e12020-05-04 17:35:20 +0200583 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400584 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100585 CDN deployment configuration: ${cdnConfig}
586 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100587 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200588 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400589 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200590 Child cluster release upgrade scheduled: ${upgradeChild}
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400591 Full Child cluster release upgrade scheduled: ${fullUpgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400592 MOS child deploy scheduled: ${mosDeployChild}
593 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200594 Child conformance testing scheduled: ${runChildConformance}
Sergey Lalovafcc0432023-04-13 14:59:06 +0400595 Child conformance network policy testing scheduled: ${runChildConformanceNetworkPolicy}
vryzhenkinb286bd82023-04-04 07:17:52 +0400596 Child HPA testing scheduled: ${runChildHPA}
Sergey Lalov012496a2023-11-27 15:57:52 +0400597 Child Stacklight HA: ${runChildStacklightHa}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100598 Single BYO cluster attachment scheduled: ${attachBYO}
599 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
600 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400601 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200602 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
slalov1202bba2022-04-20 22:31:07 +0400603 Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400604 Mgmt LMA logging enabled: ${enableLMALogging}
Sergey Lalovb2f60372022-09-20 23:58:47 +0400605 Deploy Os on child with mos release ${deployOsOnMos}
vnaumov33747e12020-05-04 17:35:20 +0200606 Mgmt conformance testing scheduled: ${runMgmtConformance}
Sergey Lalovafcc0432023-04-13 14:59:06 +0400607 Mgmt conformance network policy testing scheduled: ${runMgmtConformanceNetworkPolicy}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200608 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200609 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200610 Mgmt UI e2e testing scheduled: ${runUie2e}
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400611 Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
slalov13e579c2022-01-31 21:37:02 +0400612 Maintenance test: ${runMaintenanceTest}
slalov0a4947a2022-06-09 15:44:35 +0400613 Container Registry test: ${runContainerregistryTest}
slalov574123e2022-04-06 17:24:19 +0400614 Child proxy test: ${runProxyChildTest}
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300615 Graceful reboot test: ${runGracefulRebootTest}
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300616 Delete mgmt master node test: ${runMgmtDeleteMasterTest}
617 Delete rgnl master node test: ${runRgnlDeleteMasterTest}
618 Delete child master node test: ${runChildDeleteMasterTest}
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300619 Child machine deletion policy test: ${runChildMachineDeletionPolicyTest}
Sergey Lalovd5efcd52023-03-01 22:42:17 +0400620 Custom cert test for child clusters: ${runChildCustomCertTest}
Sergey Lalov430fcd72023-03-20 17:19:44 +0400621 Custom cert test for Byo child clusters: ${runByoChildCustomCertTest}
Sergey Lalovf6fbfea2023-04-06 17:05:40 +0400622 Custom cache cert test for mgmt and child clusters: ${runMgmtCustomCacheCertTest}
Sergey Lalov48e69022023-07-25 16:08:00 +0400623 MKE custom cert test for mgmt/region: ${runMkeCustomCertTest}
Sergey Lalov62c28312023-10-18 19:23:59 +0400624 Custom hostnames for all clisuers: ${runCustomHostnames}
vryzhenkin504dfc92023-11-01 15:49:47 +0400625 Stacklight templates enchanced with latest version from artifact-metadata: ${slLatest}
Sergey Lalovd7593ab2024-01-11 13:40:13 +0400626 Disable Kubernetes API audit: ${disableKubeApiAudit}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200627 AWS provider deployment scheduled: ${awsOnDemandDemo}
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000628 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200629 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100630 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Sergey Zhemerdeev019c45a2022-08-13 00:09:07 +0300631 EquinixmetalV2 mgmt will be deployed on the metro: ${equinixMetalV2Metro?:'auto'}
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000632 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
633 Azure provider deployment scheduled: ${azureOnDemandDemo}
634 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400635 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200636 OS provider deployment scheduled: ${enableOSDemo}
Sergey Lalovd0e20852023-08-17 19:11:19 +0400637 BM Core provider deployment scheduled: ${enablebmCoreDemo}
638 BM Core type deplyment: ${bmDeployType}
639 BM Core cleanup: ${bmCoreCleanup}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300640 BM provider deployment scheduled: ${enableBMDemo}
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300641 Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500642 RHEL on vSphere scheduled: ${enableVsphereRHEL}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400643 Artifacts build scheduled: ${enableArtifactsBuild}
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300644 Boot OS child from Ceph volumes: ${childOsBootFromVolume}
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000645 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200646 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100647 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400648 Bootstrap v2 scenario enabled: ${bootstrapV2Scenario}
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400649 FIPS enabled: ${enableFips}
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400650 MKE DEBUG enabled: ${enableMkeDebug}
Sergey Lalovbc68d752022-11-08 13:40:53 +0400651 Pause for debug enabled: ${pauseForDebug}
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300652 AIO cluster: ${aioCluster}
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100653 Use Vsphere VVMT Objects: ${useVsphereVvmtObjects}
vryzhenkin4fd3f242023-03-29 15:13:46 +0400654 Bootsrap v2 smoke checks enabled: ${enableBv2Smoke}
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400655 Run Cache warmup for child clusters: ${runCacheWarmup}
vryzhenkin211a4e82023-11-23 12:48:27 +0400656 CVE Scan enabled: ${cveScan}
vryzhenkina8d74e72024-02-26 14:59:37 +0400657 Keycloak+LDAP integration enabled: ${coreKeycloakLdap}
Владислав Наумов81777472021-03-09 15:14:27 +0400658 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200659 return [
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300660 osCloudLocation : openstackIMC,
661 cdnConfig : cdnConfig,
662 proxyConfig : proxyConfig,
663 useMacOsSeedNode : seedMacOs,
664 deployChildEnabled : deployChild,
665 childDeployCustomRelease : customChildRelease,
666 upgradeChildEnabled : upgradeChild,
667 fullUpgradeChildEnabled : fullUpgradeChild,
668 mosDeployChildEnabled : mosDeployChild,
669 mosUpgradeChildEnabled : mosUpgradeChild,
670 runChildConformanceEnabled : runChildConformance,
Sergey Lalovafcc0432023-04-13 14:59:06 +0400671 runChildConformanceNetworkPolicyEnabled : runChildConformanceNetworkPolicy,
vryzhenkinb286bd82023-04-04 07:17:52 +0400672 runChildHPAEnabled : runChildHPA,
Sergey Lalov012496a2023-11-27 15:57:52 +0400673 runChildStacklightHaEnabled : runChildStacklightHa,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300674 attachBYOEnabled : attachBYO,
675 upgradeBYOEnabled : upgradeBYO,
676 runBYOMatrixEnabled : runBYOMatrix,
677 defaultBYOOs : defaultBYOOs,
678 upgradeMgmtEnabled : upgradeMgmt,
679 autoUpgradeMgmtEnabled : autoUpgradeMgmt,
680 enableLMALoggingEnabled : enableLMALogging,
681 deployOsOnMosEnabled : deployOsOnMos,
682 runUie2eEnabled : runUie2e,
683 runUie2eNewEnabled : runUie2eNew,
684 runMgmtConformanceEnabled : runMgmtConformance,
Sergey Lalovafcc0432023-04-13 14:59:06 +0400685 runMgmtConformanceNetworkPolicyEnabled : runMgmtConformanceNetworkPolicy,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300686 runMaintenanceTestEnabled : runMaintenanceTest,
687 runContainerregistryTestEnabled : runContainerregistryTest,
688 runGracefulRebootTestEnabled : runGracefulRebootTest,
689 pauseForDebugEnabled : pauseForDebug,
690 runMgmtDeleteMasterTestEnabled : runMgmtDeleteMasterTest,
691 runRgnlDeleteMasterTestEnabled : runRgnlDeleteMasterTest,
692 runChildDeleteMasterTestEnabled : runChildDeleteMasterTest,
Sergey Lalovd5efcd52023-03-01 22:42:17 +0400693 runChildCustomCertTestEnabled : runChildCustomCertTest,
Sergey Lalov7c2377e2023-12-15 23:14:45 +0400694 customSlackChannelEnabled : customSlackChannel,
Sergey Lalovf6fbfea2023-04-06 17:05:40 +0400695 runMgmtCustomCacheCertTestEnabled : runMgmtCustomCacheCertTest,
Sergey Lalov48e69022023-07-25 16:08:00 +0400696 runMkeCustomCertTestEnabled : runMkeCustomCertTest,
Sergey Lalov62c28312023-10-18 19:23:59 +0400697 runCustomHostnamesEnabled : runCustomHostnames,
vryzhenkin504dfc92023-11-01 15:49:47 +0400698 slLatestEnabled : slLatest,
Sergey Lalov430fcd72023-03-20 17:19:44 +0400699 runByoChildCustomCertTestEnabled : runByoChildCustomCertTest,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300700 runChildMachineDeletionPolicyTestEnabled : runChildMachineDeletionPolicyTest,
701 runLMATestEnabled : runLMATest,
702 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
703 runProxyChildTestEnabled : runProxyChildTest,
704 fetchServiceBinariesEnabled : fetchServiceBinaries,
705 awsOnDemandDemoEnabled : awsOnDemandDemo,
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000706 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300707 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
708 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000709 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
710 azureOnDemandDemoEnabled : azureOnDemandDemo,
711 azureOnAwsDemoEnabled : azureOnAwsDemo,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300712 vsphereDemoEnabled : enableVsphereDemo,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300713 bmDemoEnabled : enableBMDemo,
Sergey Lalovd0e20852023-08-17 19:11:19 +0400714 bmCoreDemoEnabled : enablebmCoreDemo,
715 bmCoreCleanup : bmCoreCleanup,
716 bmDeployTypeEnabled : bmDeployType,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300717 osDemoEnabled : enableOSDemo,
718 vsphereUbuntuEnabled : enableVsphereUbuntu,
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500719 vsphereRHELEnabled : enableVsphereRHEL,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300720 artifactsBuildEnabled : enableArtifactsBuild,
721 childOsBootFromVolume : childOsBootFromVolume,
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000722 multiregionalConfiguration : multiregionalMappings,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300723 demoWeight : demoWeight,
724 bootstrapV2Scenario : bootstrapV2Scenario,
725 equinixMetalV2Metro : equinixMetalV2Metro,
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300726 enableFips : enableFips,
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400727 enableMkeDebugEnabled : enableMkeDebug,
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100728 aioCluster : aioCluster,
vryzhenkin4fd3f242023-03-29 15:13:46 +0400729 useVsphereVvmtObjects : useVsphereVvmtObjects,
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400730 bv2SmokeEnabled : enableBv2Smoke,
731 runCacheWarmup : runCacheWarmup,
vryzhenkin211a4e82023-11-23 12:48:27 +0400732 cveScanEnabled : cveScan,
Sergey Lalovd7593ab2024-01-11 13:40:13 +0400733 disableKubeApiAudit : disableKubeApiAudit,
vryzhenkina8d74e72024-02-26 14:59:37 +0400734 coreKeycloakLdapEnabled : coreKeycloakLdap,
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400735 ]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200736}
737
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000738/**
739 * Determine management and regional setup for demo workflow scenario
740 *
741 *
742 * @param: keyword (string) string , represents keyword trigger, specified in gerrit commit body, like `[multiregion aws,os]`
743 or Jenkins environment string variable in form like 'aws,os'
744 * @return (map)[
745 enabled: (bool),
746 * managementLocation: (string), //aws,os
747 * regionLocation: (string), //aws,os
748 * ]
749 */
750def multiregionWorkflowParser(keyword) {
751 def common = new com.mirantis.mk.Common()
752 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
753 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
754
755 def clusterTypes = ''
756 if (keyword.toString().contains('multiregion')) {
757 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
758 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
759 } else {
760 common.infoMsg('Multiregion definition configured via environment variable')
761 clusterTypes = keyword.trim().split(',')
762 }
763
764 if (clusterTypes.size() != 2) {
765 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
766 }
767
768 def desiredManagementProvider = clusterTypes[0].trim()
769 def desiredRegionalProvider = clusterTypes[1].trim()
770 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
771 error("""unsupported management <-> regional bundle, available options:
772 management providers list - ${supportedManagementProviders}
773 regional providers list - ${supportedRegionalProviders}""")
774 }
775
776 return [
777 enabled: true,
778 managementLocation: desiredManagementProvider,
779 regionLocation: desiredRegionalProvider,
780 ]
781}
vnaumov33747e12020-05-04 17:35:20 +0200782
783/**
784 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
785
Владислав Наумов81777472021-03-09 15:14:27 +0400786 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
vnaumov33747e12020-05-04 17:35:20 +0200787 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
788 * Example scheme:
789 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
790 * manage refspecs through Jenkins Job Parameters
791 *
azvyagintseva12230a2020-06-05 13:24:06 +0300792 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200793 * siPipelines: (string) final refspec for si-pipelines
794 * ]
795 */
796def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200797 def common = new com.mirantis.mk.Common()
798
vnaumov33747e12020-05-04 17:35:20 +0200799 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200800 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
801 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200802 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
803 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200804 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200805
806 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
807 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
808
809 if (siTestMatches.size() > 0) {
810 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400811 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200812 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200813 }
814 if (siPipelinesMatches.size() > 0) {
815 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
816 }
817
818 common.infoMsg("""
819 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
820 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200821 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400822 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200823 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200824}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200825
Владислав Наумов9080f372020-06-08 13:57:16 +0200826/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200827 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200828 * @param configurationFile (str) path to configuration file in yaml format
829 *
830 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300831 * siTestsFeatureFlagsStable (string) dedicated feature flags that will be used in SI tests for deploying stable release
Владислав Наумов30a516c2020-07-09 13:15:41 +0200832 * ]
833 */
834def parseKaaSComponentCIParameters(configurationFile){
835 def common = new com.mirantis.mk.Common()
836 def ciConfig = readYaml file: configurationFile
837 def ciSpec = [
838 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300839 siTestsFeatureFlagsStable: env.SI_TESTS_FEATURE_FLAGS_STABLE ?: '',
Владислав Наумов30a516c2020-07-09 13:15:41 +0200840 ]
841
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300842 // If exists and not empty
843 if (ciConfig.getOrDefault('si-tests-feature-flags', [])) {
Владислав Наумов30a516c2020-07-09 13:15:41 +0200844 common.infoMsg("""SI tests feature flags customization detected,
845 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
846
847 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
848 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200849
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200850 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200851 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
852 }
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300853 if (ciConfig.getOrDefault('si-tests-feature-flags-stable', [])) {
854 common.infoMsg("""SI tests feature flags for stable release customization detected,
855 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlagsStable']}] identification...""")
856
857 def ffMeta = ciSpec['siTestsFeatureFlagsStable'].tokenize(',').collect { it.trim() }
858 ffMeta.addAll(ciConfig['si-tests-feature-flags-stable'])
859
860 ciSpec['siTestsFeatureFlagsStable'] = ffMeta.unique().join(',')
861 common.infoMsg("SI tests custom feature flags for stable release: ${ciSpec['siTestsFeatureFlagsStable']}")
862 }
Владислав Наумов30a516c2020-07-09 13:15:41 +0200863
864 common.infoMsg("""Additional ci configuration parsed successfully:
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300865 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}
866 siTestsFeatureFlagsStable: ${ciSpec['siTestsFeatureFlagsStable']}""")
Владислав Наумов30a516c2020-07-09 13:15:41 +0200867 return ciSpec
868}
869
870/**
871 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200872
Владислав Наумов81777472021-03-09 15:14:27 +0400873 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
Владислав Наумов9080f372020-06-08 13:57:16 +0200874 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
875 * Example scheme:
876 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
877 * manage refspecs through Jenkins Job Parameters
878 *
879 * @return (map)[ core: (string) final refspec for kaas/core
880 * corePipelines: (string) final refspec for pipelines in kaas/core
881 * ]
882 */
883def checkCustomCoreRefspec() {
884 def common = new com.mirantis.mk.Common()
885
886 // Available triggers and its sane defaults
887 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
888 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
889 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
890 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
891
892 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
893 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
894
895 if (coreMatches.size() > 0) {
896 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
897 }
898 if (corePipelinesMatches.size() > 0) {
899 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
900 }
901
902 common.infoMsg("""
903 kaas/core will be fetched from: ${coreRefspec}
904 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400905 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200906 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
907}
908
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200909
910/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200911 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
912 * needed to forward inside kaas core set of jobs
913 *
914 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
915 * @return (list)[ string(name: '', value: ''),
916 * ]
917 */
918def generateKaaSVarsFromContext(context) {
919 def common = new com.mirantis.mk.Common()
920 def parameters = []
921 def config = readYaml text: context
922
923 config.each { k,v ->
924 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
925 parameters.add(string(name: k, value: v))
926 }
927
928 return parameters
929}
930
931/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200932 * Trigger KaaS demo jobs based on AWS/OS providers with customized test suite, parsed from external sources (gerrit commit/jj vars)
Владислав Наумов81777472021-03-09 15:14:27 +0400933 * Keyword list: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200934 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
935 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200936 * @param: component (string) component name [iam, lcm, stacklight]
937 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
938 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200939 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200940def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200941 def common = new com.mirantis.mk.Common()
942 // Determine if custom trigger keywords forwarded from gerrit
943 def triggers = checkDeploymentTestSuite()
944 // Determine SI refspecs
945 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200946 // Determine Core refspecs
947 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200948
Владислав Наумов418042b2020-07-09 18:31:10 +0200949 // Determine component repo ci configuration
950 def ciSpec = [:]
951 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
952 if (fileExists(configurationFile)) {
953 common.infoMsg('Component CI configuration file detected, parsing...')
954 ciSpec = parseKaaSComponentCIParameters(configurationFile)
955 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
956 } else {
957 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200958 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200959 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
960 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200961 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400962
963 def platforms = []
964 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
965 // Currently only vsphere demo is required for IPAM component
966 platforms.add('vsphere')
967 } else {
968 if (triggers.osDemoEnabled) {
969 platforms.add('openstack')
970 }
971 if (triggers.awsOnDemandDemoEnabled) {
972 platforms.add('aws')
973 }
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000974 if (triggers.equinixOnDemandDemoEnabled) {
975 platforms.add('equinix')
976 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200977 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
978 platforms.add('equinixmetalv2')
979 }
Sergey Kolekonovd6a17392024-02-06 15:57:53 +0000980 if (triggers.azureOnDemandDemoEnabled) {
981 platforms.add('azure')
982 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400983 if (triggers.vsphereDemoEnabled) {
984 platforms.add('vsphere')
985 }
Sergey Kolekonov8e4de182024-03-05 15:07:07 +0500986 if (triggers.bmCoreDemoEnabled) {
987 platforms.add('bm')
988 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400989 }
990
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200991 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200992 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200993 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
994 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200995 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200996 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200997 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
998 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200999 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001000 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +04001001 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +04001002 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Sergey Lalov7c2377e2023-12-15 23:14:45 +04001003 string(name: 'SLACK_CHANNEL_NOTIFY', value: triggers.customSlackChannelEnabled),
Владислав Наумовb8305e22021-02-10 17:23:12 +01001004 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +02001005 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +02001006 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +01001007 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +02001008 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
slalov1202bba2022-04-20 22:31:07 +04001009 booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +04001010 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Sergey Lalovb2f60372022-09-20 23:58:47 +04001011 booleanParam(name: 'DEPLOY_OS_ON_MOS', value: triggers.deployOsOnMosEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001012 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +02001013 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
Sergey Lalovafcc0432023-04-13 14:59:06 +04001014 booleanParam(name: 'RUN_MGMT_CFM_NETWORK_POLICY', value: triggers.runMgmtConformanceNetworkPolicyEnabled),
slalov0a4947a2022-06-09 15:44:35 +04001015 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnabled),
1016 booleanParam(name: 'RUN_CONTAINER_REGISTRY_TEST', value: triggers.runContainerregistryTestEnabled),
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +03001017 booleanParam(name: 'RUN_GRACEFUL_REBOOT_TEST', value: triggers.runGracefulRebootTestEnabled),
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +03001018 booleanParam(name: 'RUN_MGMT_DELETE_MASTER_TEST', value: triggers.runMgmtDeleteMasterTestEnabled),
1019 booleanParam(name: 'RUN_RGNL_DELETE_MASTER_TEST', value: triggers.runRgnlDeleteMasterTestEnabled),
1020 booleanParam(name: 'RUN_CHILD_DELETE_MASTER_TEST', value: triggers.runChildDeleteMasterTestEnabled),
Sergey Lalovd5efcd52023-03-01 22:42:17 +04001021 booleanParam(name: 'RUN_CHILD_CUSTOM_CERT_TEST', value: triggers.runChildCustomCertTestEnabled),
Sergey Lalovf6fbfea2023-04-06 17:05:40 +04001022 booleanParam(name: 'RUN_MGMT_CUSTOM_CACHE_CERT_TEST', value: triggers.runMgmtCustomCacheCertTestEnabled),
Sergey Lalov48e69022023-07-25 16:08:00 +04001023 booleanParam(name: 'RUN_MKE_CUSTOM_CERT_TEST', value: triggers.runMkeCustomCertTestEnabled),
Sergey Lalov62c28312023-10-18 19:23:59 +04001024 booleanParam(name: 'RUN_CUSTOM_HOSTNAMES', value: triggers.runCustomHostnamesEnabled),
vryzhenkin504dfc92023-11-01 15:49:47 +04001025 booleanParam(name: 'SL_LATEST', value: triggers.slLatestEnabled),
Sergey Lalov430fcd72023-03-20 17:19:44 +04001026 booleanParam(name: 'RUN_BYO_CHILD_CUSTOM_CERT_TEST', value: triggers.runByoChildCustomCertTestEnabled),
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +03001027 booleanParam(name: 'RUN_CHILD_MACHINE_DELETION_POLICY_TEST', value: triggers.runChildMachineDeletionPolicyTestEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +02001028 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +02001029 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +02001030 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
1031 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Sergey Lalovc1cb49f2022-09-27 01:16:25 +04001032 booleanParam(name: 'FULL_UPGRADE_CHILD_CLUSTER', value: triggers.fullUpgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +04001033 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +01001034 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +01001035 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +01001036 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +02001037 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Sergey Lalovafcc0432023-04-13 14:59:06 +04001038 booleanParam(name: 'RUN_CHILD_CFM_NETPOLICY', value: triggers.runChildConformanceNetworkPolicyEnabled),
vryzhenkinb286bd82023-04-04 07:17:52 +04001039 booleanParam(name: 'RUN_CHILD_HPA', value: triggers.runChildHPAEnabled),
Sergey Lalov012496a2023-11-27 15:57:52 +04001040 booleanParam(name: 'RUN_STACKLIGHT_CHILD_HA', value: triggers.runChildStacklightHaEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +04001041 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Sergey Kolekonovd6a17392024-02-06 15:57:53 +00001042 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +02001043 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +01001044 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
Sergey Kolekonovd6a17392024-02-06 15:57:53 +00001045 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
1046 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
1047 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Sergey Lalovc63259f2024-01-28 16:52:30 +04001048 booleanParam(name: 'ALLOW_BM_CORE_ON_DEMAND', value: triggers.bmCoreDemoEnabled),
Sergey Zhemerdeev9074f6e2022-06-07 12:03:16 +03001049 booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled),
Sergey Lalovbc68d752022-11-08 13:40:53 +04001050 booleanParam(name: 'PAUSE_FOR_DEBUG', value: triggers.pauseForDebugEnabled),
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +03001051 booleanParam(name: 'ENABLE_FIPS', value: triggers.enableFips),
Sergey Lalov00bea0f2023-08-14 16:46:33 +04001052 booleanParam(name: 'ENABLE_MKE_DUBUG', value: triggers.enableMkeDebugEnabled),
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +03001053 booleanParam(name: 'AIO_CLUSTER', value: triggers.aioCluster),
Sergey Lalovd0e20852023-08-17 19:11:19 +04001054 booleanParam(name: 'BM_CORE_CLEANUP', value: triggers.bmCoreCleanup),
Sergey Lalovd7593ab2024-01-11 13:40:13 +04001055 booleanParam(name: 'DISABLE_KUBE_API_AUDIT', value: triggers.disableKubeApiAudit),
vryzhenkina8d74e72024-02-26 14:59:37 +04001056 booleanParam(name: 'CORE_KEYCLOAK_LDAP_ENABLED', value: triggers.coreKeycloakLdapEnabled)
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001057 ]
Владислав Наумов92288d92020-07-13 18:36:21 +02001058
Sergey Kolekonovd6a17392024-02-06 15:57:53 +00001059 // customize multiregional demo
1060 if (triggers.multiregionalConfiguration.enabled) {
1061 parameters.add(string(name: 'MULTIREGION_SETUP',
1062 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
1063 ))
1064 }
1065
Владислав Наумов92288d92020-07-13 18:36:21 +02001066 // Determine component team custom context
1067 if (coreContext != '') {
1068 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
1069 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +02001070 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +02001071 }
1072
Владислав Наумовaa430612020-06-08 17:18:31 +02001073 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +04001074
1075 platforms.each { platform ->
1076 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +00001077 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +04001078 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
1079 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
1080 def build_description = job_info.getDescription()
1081 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +00001082 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +02001083
Vladislav Naumov5313a202021-04-07 17:13:39 +00001084 if (build_description) {
1085 currentBuild.description += build_description
1086 }
1087 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +04001088 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +00001089 }
1090 }
1091 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001092
1093 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +04001094 if (jobs.size() == 0) {
1095 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
1096 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001097 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
1098 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +02001099
1100 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +02001101 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +02001102 currentBuild.result = 'FAILURE'
1103 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001104}
Владислав Наумов30a516c2020-07-09 13:15:41 +02001105
1106
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001107/**
1108 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +02001109 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001110 *
1111 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
1112 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
Sergey Kolekonovd6a17392024-02-06 15:57:53 +00001113 * @param: multiregionalConfiguration (map) Multiregional configuration
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001114 * @return (map) Return aggregated map with lockResources and netMap
1115 */
1116
1117
1118def generateLockResources(callBackDemo, triggers) {
1119 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +02001120 def netMap = [
1121 vsphere: [:],
1122 equinix: [:],
1123 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001124 // Define vsphere locklabels with initial quantity
1125 def lockLabels = [
1126 vsphere_networking_core_ci: 0,
1127 vsphere_offline_networking_core_ci: 0,
1128 ]
1129 def deployChild = triggers.deployChildEnabled
Sergey Lalov13eea422023-08-21 23:10:17 +04001130 def testUiVsphere = triggers.runUie2eEnabled || triggers.runUie2eNewEnabled
Sergey Kolekonovd6a17392024-02-06 15:57:53 +00001131 def multiregionConfig = triggers.multiregionalConfiguration
1132 def runMultiregion = multiregionConfig.enabled
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001133
1134 // Generate vsphere netMap and lockLabels based on demo context
1135 switch (callBackDemo) {
1136 case 'aws':
1137 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
1138 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +04001139 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Sergey Kolekonovd6a17392024-02-06 15:57:53 +00001140
1141 // Define netMap for Vsphere region
1142 if (runMultiregion && multiregionConfig.managementLocation == 'aws') {
1143 if (multiregionConfig.regionLocation == 'vsphere') {
1144 if (deployChild) {
1145 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
1146 }
1147 addToProviderNetMap(netMap, 'vsphere', 'region')
1148 }
1149
1150 if (multiregionConfig.regionLocation == 'azure') {
1151 lockLabels['azure_core_ci_queue'] = 1
1152 if (deployChild) {
1153 lockLabels['azure_core_ci_queue'] += 1
1154 }
1155 }
1156 }
1157 if (triggers.azureOnAwsDemoEnabled) {
1158 lockLabels['azure_core_ci_queue'] = 1
1159 }
1160
1161 if (triggers.equinixOnAwsDemoEnabled) {
1162 lockLabels['equinix_core_ci_queue'] = 1
1163 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001164 break
1165 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +02001166 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
slalov27833272022-06-30 02:13:50 +04001167 if (deployChild || testUiVsphere) {
Владислав Наумов33e1e812021-08-17 17:09:25 +02001168 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001169 }
Sergey Kolekonovd6a17392024-02-06 15:57:53 +00001170 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
1171 multiregionConfig.regionLocation == 'vsphere') {
1172 if (deployChild) {
1173 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
1174 }
1175 addToProviderNetMap(netMap, 'vsphere', 'region')
1176 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001177 break
Sergey Kolekonovd6a17392024-02-06 15:57:53 +00001178 case 'azure':
1179 lockLabels['azure_core_ci_queue'] = triggers.demoWeight
1180 if (runMultiregion && multiregionConfig.managementLocation == 'azure') {
1181 if (multiregionConfig.regionLocation == 'aws') {
1182 lockLabels['aws_core_ci_queue'] = 1
1183 if (deployChild) {
1184 lockLabels['aws_core_ci_queue'] += 1
1185 }
1186 }
1187
1188 if (multiregionConfig.regionLocation == 'equinix') {
1189 lockLabels['equinix_core_ci_queue'] = 1
1190 if (deployChild) {
1191 lockLabels['equinix_core_ci_queue'] +=1
1192 }
1193 }
1194 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001195 default:
Sergey Kolekonovd6a17392024-02-06 15:57:53 +00001196 error('Supposed to be called from aws, azure or vsphere demos only')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001197 }
1198
1199 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
1200 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +02001201 netMap['vsphere'].each { clusterType, netConfig ->
1202 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
1203 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
1204 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
1205
1206 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001207 lockLabels['vsphere_offline_networking_core_ci']++
1208 } else {
1209 lockLabels['vsphere_networking_core_ci']++
1210 }
1211 }
1212
1213 // generate lock metadata
1214 def lockResources = []
1215 lockLabels.each { label, quantity ->
1216 if (quantity > 0) {
1217 def res = [
1218 label: label,
1219 quantity: quantity,
1220 ]
1221 lockResources.add(res)
1222 }
1223 }
1224
1225 common.infoMsg("""Generated vsphere netMap: ${netMap}
1226 Generated lockResources: ${lockResources}""")
1227
1228 return [
1229 netMap: netMap,
1230 lockResources: lockResources,
1231 ]
1232}
1233
1234/**
1235 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
1236 * and empty rangeConfig to the this map.
1237 *
Владислав Наумов33e1e812021-08-17 17:09:25 +02001238 * @param: netMap (string) vsphere, equinix netMap or empty map
1239 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001240 * @param: clusterType (string) Vsphere cluster type
1241 */
1242
Владислав Наумов33e1e812021-08-17 17:09:25 +02001243def addToProviderNetMap (netMap, provider, clusterType) {
1244 switch (provider) {
1245 case 'equinix':
1246 netMap[provider][clusterType] = [
1247 vlanConfig: '',
1248 ]
1249 break
1250 case 'vsphere':
1251 netMap[provider][clusterType] = [
1252 netName: 'default',
1253 rangeConfig: '',
1254 ]
1255 break
1256 default:
1257 error('Net map locks supported for Equinix/Vsphere providers only')
1258 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001259}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +03001260
1261/**
1262* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
1263* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
1264* If keyword contains only 'key' part then 'value' is boolean True.
1265* This function does not perform keywords validation.
1266* First line of a commit message is ignored.
1267* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
1268* TODO: Remove backslash chars from values if they prepend '[' or ']'.
1269**/
1270
1271List getCIKeywordsFromCommitMsg() {
1272 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
1273 List commitMsgLines = commitMsg.split('\n')
1274 List keywords = []
1275 if (commitMsgLines.size() < 2) {
1276 return keywords
1277 }
1278
1279 String commitMsgBody = commitMsgLines[1..-1].join('\n')
1280
1281 // Split commit message body to chunks using '[' or ']' as delimiter,
1282 // ignoring them if prepended by backslash (regex negative lookbehind).
1283 // Resulting list will have chunks between '[' and ']' at odd indexes.
1284 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
1285
1286 // Iterate chunks by odd indexes only, trim values and split to
1287 // <key> / <value> pair where <key> is the part of a sting before the first
1288 // whitespace delimiter, and <value> is the rest (may include whitespaces).
1289 // If there is no whitespace in the string then this is a 'switch'
1290 // and <value> will be boolean True.
1291 for (i = 1; i < parts.size(); i += 2) {
1292 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
1293 keywords.add(['key': key, 'value': value])
1294 }
1295
1296 return keywords
1297}
1298
1299/**
1300* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
1301* that were specified for given job name. `job-params` keyword has the following structure
1302*
1303* [job-params <job name> <parameter name> <parameter value>]
1304*
1305* Return value is a Map that contains those parameters using the following structure:
1306*
1307* <job name>:
1308* <parameter name>: <parameter value>
1309*
1310**/
1311Map getJobsParamsFromCommitMsg() {
1312 List keywords = getCIKeywordsFromCommitMsg()
1313
1314 List jobsParamsList = []
1315 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
1316 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
1317 def (key, value) = params.split(/\s+/, 2)
1318 ['name': name, 'key': key, 'value': value]
1319 }
1320
1321 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
1322 if (!result.containsKey(it.name)) {
1323 result[it.name] = [:]
1324 }
1325 result[it.name][it.key] = it.value
1326 result
1327 }
1328
1329 return jobsParams
1330}
1331
1332
1333/**
1334* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
1335* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
1336* uses only those parametes that were set to all jobs (with <job name> == '*') or to
1337* a particular job. Parameters set to a particular job have higher precedence.
1338*
1339* Return value is a Map that contains those parameters:
1340*
1341* <parameter name>: <parameter value>
1342*
1343**/
1344Map getJobParamsFromCommitMsg(String jobName) {
1345 jobsParams = getJobsParamsFromCommitMsg()
1346 jobParams = jobsParams.getOrDefault('*', [:])
1347 if (jobName) {
1348 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
1349 }
1350 return jobParams
1351}
azvyagintsevc17d14b2022-06-06 19:06:33 +03001352
1353/** Getting test scheme from text, which should be
1354Imput example:
1355text="""
1356 DATA
1357
1358 kaas_bm_test_schemas:
1359 KAAS_RELEASES_REFSPEC: ''
1360 KEY: VAL
1361
1362 DATA
1363 """
1364
1365 Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas'])
1366
1367 Return:
1368 ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL']
1369 **/
1370def parseTextForTestSchemas(Map opts) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001371 String text = opts.getOrDefault('text', '')
azvyagintsevc17d14b2022-06-06 19:06:33 +03001372 String keyLine = opts.getOrDefault('keyLine', '')
1373 Map testScheme = [:]
1374 if (!text || !keyLine) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001375 return testScheme
azvyagintsevc17d14b2022-06-06 19:06:33 +03001376 }
1377 if (text =~ /\n$keyLine\n.*/) {
1378 def common = new com.mirantis.mk.Common()
1379 try {
1380 String regExp = '\\n' + keyLine + '\\n'
1381 // regexep block must be followed by empty line
1382 testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}"
1383 common.infoMsg("parseTextForTestSchemas result:\n" + testScheme)
1384 common.mergeEnv(env, toJson(testScheme))
1385 }
1386 catch (Exception e) {
1387 common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}")
1388 throw e
1389 }
1390 }
azvyagintsevd96aac22022-06-10 14:23:26 +03001391 return testScheme
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +03001392}
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001393
1394
1395/**
eromanovab24cb232023-11-17 12:17:06 +04001396* getEquinixMetroWithCapacity returns list of Equinix metros using specified
1397* instance type (nodeType), desired count of metros (metroCount) and
1398* instances (nodeCount) in a metro using specified matal version.
1399* Function downloads metal CLI from the
1400* https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux
1401* Empty list is returned in case of no metros with specified capacity was found or any other errors.
1402* Non-empty list is shuffled.
1403*
1404* @param: metroCount (int) Desired count of metros
1405* @param: nodeCount (int) Desired count of instances
1406* @param: nodeType (string) Instance type
1407* @param: version (string) Metal version to use
1408* @return ([]string) List of selected metros
1409*
1410**/
1411def getEquinixMetroWithCapacity(metroCount = 1, nodeCount = 50, nodeType = 'c3.small.x86', version = '0.9.0') {
1412 def common = new com.mirantis.mk.Common()
1413 def metalUrl = "https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux"
1414 def metal = './metal --config metal.yaml'
1415 def metro = []
1416 def out = ''
1417 def retries = 3 // number of retries
1418 def i = 0
1419 def delay = 60 // 1 minute sleep
1420 def excludeMetro = [] // list of metros to exclude from selection
1421 try {
1422 if (excludeMetro.size() > 0) {
1423 common.infoMsg("Excluded metros: ${excludeMetros}")
1424 }
1425 sh "curl -o metal -# ${metalUrl} && chmod +x metal"
1426 withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) {
1427 sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml'
1428 }
1429 while (metro.size() < metroCount && i < retries) {
1430 common.infoMsg("Selecting ${metroCount} available Equinix metros with free ${nodeCount} ${nodeType} hosts, try ${i+1}/${retries} ...")
1431 if (i > 0) { // skip sleep on first step
1432 sleep(delay)
1433 }
1434 out = sh(script: "${metal} capacity get -m -P ${nodeType}|awk '/${nodeType}/ {print \$2}'|paste -s -d,|xargs ${metal} capacity check -P ${nodeType} -q ${nodeCount} -m|grep true|awk '{print \$2}'|paste -s -d,", returnStdout: true).trim()
1435 metro = out.tokenize(',')
1436 metro -= excludeMetro
1437 if (metro.size() < metroCount) {
1438 nodeCount -= 10
1439 // We need different metros for the [equinixmetalv2-child-diff-metro] case
1440 } else if (metro.size() == 2 && metro[0][0, 1] == metro[1][0, 1]) {
1441 nodeCount -= 10
1442 }
1443 i++
1444 }
1445 if (metro.size() > 0) {
eromanovaefbbb422023-11-24 13:54:35 +04001446 m = metro.size() > 1 ? "${metro[0]},${metro[1]}" : "${metro[0]}"
1447 sh "${metal} capacity check -P ${nodeType} -m ${m} -q ${nodeCount}"
eromanovab24cb232023-11-17 12:17:06 +04001448 }
1449 } catch (Exception e) {
1450 common.errorMsg "Exception: '${e}'"
1451 return []
1452 } finally {
1453 sh 'rm metal.yaml'
1454 }
1455 if (metro.size() > 0) {
1456 Collections.shuffle(metro)
1457 common.infoMsg("Selected metros: ${metro}")
1458 } else {
1459 common.warningMsg('No any metros have been selected !!! :(')
1460 }
1461 return metro
1462}
1463
1464
1465/**
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001466* getEquinixFacilityWithCapacity returns list of Equinix facilities using specified
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001467* instance type (nodeType), desired count of facilities (facilityCount) and
1468* instances (nodeCount) in a facility using specified matal version.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001469* Function downloads metal CLI from the
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001470* https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux
1471* Empty list is returned in case of no facilities with specified capacity was found or any other errors.
Sergey Zhemerdeev15aa8602022-10-13 11:10:02 +03001472* Non-empty list is shuffled.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001473*
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001474* @param: facilityCount (int) Desired count of facilities
1475* @param: nodeCount (int) Desired count of instances
1476* @param: nodeType (string) Instance type
1477* @param: version (string) Metal version to use
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001478* @return ([]string) List of selected facilities
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001479*
1480**/
eromanovab24cb232023-11-17 12:17:06 +04001481@Deprecated
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001482def getEquinixFacilityWithCapacity(facilityCount = 1, nodeCount = 50, nodeType = 'c3.small.x86', version = '0.9.0') {
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001483 def common = new com.mirantis.mk.Common()
Sergey Lalov314daae2023-11-27 12:21:20 +04001484 common.warningMsg('You are using deprecated method getEquinixFacilityWithCapacity. Use getEquinixMetroWithCapacity instead')
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001485 def metalUrl = "https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux"
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001486 def metal = './metal --config metal.yaml'
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001487 def facility = []
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001488 def out = ''
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001489 def retries = 3 // number of retries
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001490 def i = 0
1491 def delay = 60 // 1 minute sleep
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001492 def excludeFacility = [] // list of facilities to exclude from selection
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001493 try {
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001494 if (excludeFacility.size() > 0) {
1495 common.infoMsg("Excluded facilities: ${excludeFacility}")
1496 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001497 sh "curl -o metal -# ${metalUrl} && chmod +x metal"
1498 withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) {
1499 sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml'
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001500 }
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001501 while (facility.size() < facilityCount && i < retries) {
1502 common.infoMsg("Selecting ${facilityCount} available Equinix facilities with free ${nodeCount} ${nodeType} hosts, try ${i+1}/${retries} ...")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001503 if (i > 0 ) { // skip sleep on first step
1504 sleep(delay)
1505 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001506 out = sh(script: "${metal} capacity get -f -P ${nodeType}|awk '/${nodeType}/ {print \$2}'|paste -s -d,|xargs ${metal} capacity check -P ${nodeType} -q ${nodeCount} -f|grep true|awk '{print \$2}'|paste -s -d,", returnStdout: true).trim()
1507 facility = out.tokenize(',')
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001508 facility -= excludeFacility
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001509 if (facility.size() < facilityCount) {
1510 nodeCount -= 10
1511 // We need different metros for the [equinixmetalv2-child-diff-metro] case, facility[][0, 1] contains a metro name
1512 } else if (facility.size() == 2 && facility[0][0, 1] == facility[1][0, 1]) {
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001513 nodeCount -= 10
1514 }
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001515 i++
1516 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001517 if (facility.size() > 0) {
1518 f = facility.size() > 1 ? "${facility[0]},${facility[1]}" : "${facility[0]}"
1519 sh "${metal} capacity check -P ${nodeType} -f ${f} -q ${nodeCount}"
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001520 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001521 } catch (Exception e) {
1522 common.errorMsg "Exception: '${e}'"
1523 return []
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001524 } finally {
1525 sh 'rm metal.yaml'
1526 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001527 if (facility.size() > 0) {
Sergey Zhemerdeev15aa8602022-10-13 11:10:02 +03001528 Collections.shuffle(facility)
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001529 common.infoMsg("Selected facilities: ${facility}")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001530 } else {
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001531 common.warningMsg('No any facilities have been selected !!! :(')
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001532 }
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001533 return facility
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001534}
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001535
1536
1537/**
1538 * genCommandLine prepares command line for artifactory-replication
1539 * command using legacy environment variables
1540 *
1541 * @return: (string) Prepared command line
1542 */
1543def genCommandLine() {
1544 def envToParam = [
1545 'DESTINATION_USER': '-dst-user',
1546 'ARTIFACT_FILTER': '-artifact-filter',
1547 'ARTIFACT_FILTER_PROD': '-artifact-filter-prod',
1548 'ARTIFACT_TYPE': '-artifact-type',
1549 'BINARY_CLEAN': '-bin-cleanup',
1550 'BINARY_CLEAN_KEEP_DAYS': '-bin-clean-keep-days',
1551 'BINARY_CLEAN_PREFIX': '-bin-clean-prefix',
1552 'BUILD_URL': '-slack-build-url',
1553 'CHECK_REPOS': '-check-repos',
1554 'DESTINATION_REGISTRY': '-dst-repo',
1555 'DESTINATION_REGISTRY_TYPE': '-dst-repo-type',
Ihor Hryshchenko4f703862023-12-07 14:45:50 +02001556 'SIGNED_IMAGES_PATH': '-signed-images-path',
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001557 'DOCKER_CLEAN': '-cleanup',
Ihor Hryshchenkoaa501002024-03-11 16:39:56 +02001558 'DOCKER_OLDER_THAN_DAYS': '-older-than-days',
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001559 'DOCKER_REPO_PREFIX': '-docker-repo-prefix',
1560 'DOCKER_TAG': '-docker-tag',
1561 'FORCE': '-force',
1562 'HELM_CDN_DOMAIN': '-helm-cdn-domain',
1563 'SLACK_CHANNEL': '-slack-channel',
Ihor Hryshchenko742c9012024-01-19 16:47:22 +02001564 'SLACK_CHANNELS': '-slack-channels',
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001565 'SLACK_USER': '-slack-user',
1566 'SOURCE_REGISTRY': '-src-repo',
1567 'SOURCE_REGISTRY_TYPE': '-src-repo-type',
1568 'SYNC_PATTERN': '-sync-pattern'
1569 ]
1570 def cmdParams = ''
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001571 def isCheckClean = false
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001572 for (e in envToParam) {
1573 if (env[e.key] == null) {
1574 continue
1575 }
1576 if (e.key == 'CHECK_REPOS' || e.key == 'DOCKER_CLEAN') {
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001577 // Avoid CHECK_REPOS=true and DOCKER_CLEAN=true
1578 if (env[e.key].toBoolean() && !isCheckClean) {
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001579 cmdParams += e.value + ' '
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001580 isCheckClean = true
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001581 }
1582 } else if (e.key == 'FORCE') {
1583 if (env[e.key].toBoolean()) {
1584 cmdParams += e.value + ' '
1585 }
1586 } else {
Sergey Zhemerdeeve2926cd2022-08-29 15:28:47 +03001587 cmdParams += "${e.value} '${env[e.key]}' "
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001588 }
1589 }
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001590 // No any check or clean was specified - take a default action
1591 if (!isCheckClean) {
1592 cmdParams += '-replicate'
1593 }
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001594 return cmdParams
1595}
Sergey Kolekonov0e60a942022-09-05 13:02:22 +04001596
1597/**
1598 * custom scheduling algorithm
1599 * it ensures that builds of the same job are distributed as much as possible between different nodes
1600 * @param label (string) desired node label
1601 * @return: (string) node name
1602 */
1603def schedule (label='docker') {
1604 def common = new com.mirantis.mk.Common()
1605 def freeNodes = []
1606 def nodesMap = [:]
1607
1608 // filter nodes with the specified label and at least one free executor
1609 timeout(time: 30, unit: 'MINUTES') {
1610 while (!freeNodes) {
1611 freeNodes = jenkins.model.Jenkins.instance.computers.findAll { node ->
1612 label in node.getAssignedLabels().collect { it.name } &&
Sergey Kolekonovd5887172022-11-10 12:13:22 +06001613 node.isPartiallyIdle() &&
1614 node.isOnline()
Sergey Kolekonov0e60a942022-09-05 13:02:22 +04001615 }
1616 if (!freeNodes) {
1617 echo 'No nodes available for scheduling, retrying...'
1618 sleep 30
1619 }
1620 }
1621 }
1622
1623 // generate a map of nodes matching other criteria
1624 for (node in freeNodes) {
1625 // sameJobExecutors is the number of executors running the same job as the calling one
1626 sameJobExecutors = node.getExecutors() // get all executors
1627 .collect { executor -> executor.getCurrentExecutable() } // get running "threads"
1628 .collect { thread -> thread?.displayName } // filter job names from threads
1629 .minus(null) // null = empty executors, remove them from the list
1630 .findAll { it.contains(env.JOB_NAME) } // filter the same jobs as the calling one
1631 .size()
1632
1633 // calculate busy executors, we don't want to count "sameJobExecutors" twice
1634 totalBusyExecutors = node.countBusy() - sameJobExecutors
1635 // generate the final map which contains nodes matching criteria with their load score
1636 // builds of the same jobs have x10 score, all others x1
1637 nodesMap += ["${node.getName()}" : sameJobExecutors * 10 + totalBusyExecutors]
1638 }
1639
1640 // return the least loaded node
1641 return common.SortMapByValueAsc(nodesMap).collect { it.key }[0]
1642}
Sergey Zhemerdeev78a65272023-03-23 18:05:22 +02001643
1644
1645/**
1646 * Get latest tag for test/frontend & equinix-private-infra images
1647 * @param version (str) default tag value from main workflow
1648 * @param isChanged (bool) is dependent directory files were changed
1649 * @param imageName (string) image name for information message
1650 * @return: (string) tag name
1651 */
1652def getImageTag(version, isChanged, imageName) {
1653 def common = new com.mirantis.mk.Common()
Sergey Zhemerdeev5fbf2022023-04-28 14:51:36 +03001654 def latestTag = ''
1655 if (env.GERRIT_EVENT_TYPE && !(env.GERRIT_EVENT_TYPE in ['change-merged', 'ref-updated']) && isChanged) {
Sergey Zhemerdeev78a65272023-03-23 18:05:22 +02001656 latestTag = version
Sergey Zhemerdeevebdcad22023-04-25 16:58:28 +03001657 } else {
1658 if (env.GERRIT_EVENT_TYPE == 'ref-updated') {
1659 latestTag = env.GERRIT_REFNAME.replace('refs/tags/v', '').trim()
1660 } else {
1661 latestTag = env.GERRIT_BRANCH ? env.GERRIT_BRANCH : env.GERRIT_REFSPEC ? env.GERRIT_REFSPEC : 'master'
1662 if (latestTag != 'master') {
1663 latestTag = latestTag.replaceAll('/', '_')
1664 }
1665 }
Sergey Zhemerdeev78a65272023-03-23 18:05:22 +02001666 }
1667 common.infoMsg("${imageName} image will use tag '${latestTag}'")
1668 return latestTag
1669}
Sergey Zhemerdeev1d2c03e2023-04-28 11:07:24 +03001670
Sergey Lalov78659102024-02-15 16:57:21 +04001671/**
1672 * Get actual branch version for os deployment job
1673 * @param mosChildPreviouseComplexRelease (string) kaas_previous_complex_mosk_cluster_release_version.txt
1674 * @param mosChildLatestComplexRelease (string) kaas_latest_complex_mosk_cluster_release_version.txt
1675 * @param upgradeFlag (boolean)
1676 * all parametrs get from si-test-release-sanity-check-prepare-configuration job
1677 * @return: (string) branch verison
1678 */
1679def getOpenstackbranchVersion(mosChildPreviouseComplexRelease, mosChildLatestComplexRelease, upgradeFlag) {
1680 def common = new com.mirantis.mk.Common()
1681 def regex = Pattern.compile('([a-z]+)-([0-9]+-[0-9]+-[0-9]+)-([a-z]*)-?([0-9]+-[0-9]+-?[0-9]*)')
1682
1683 def mosVersionBranch = upgradeFlag ? mosChildPreviouseComplexRelease : mosChildLatestComplexRelease
1684 def matcherComplexVersion = regex.matcher((mosVersionBranch).toString())
1685 def releaseOpenstackK8sBranch = 'master'
1686
1687 if (matcherComplexVersion.find()) {
1688 def matcherComplexVersionParts = matcherComplexVersion.group(2).split('-')
1689 releaseOpenstackK8sBranch = String.format('%s.%s.%s', matcherComplexVersionParts[0], matcherComplexVersionParts[1], '0')
1690 }
1691 common.infoMsg("Use: OPENSTACK_DEPLOY_RELEASE_DIR ${releaseOpenstackK8sBranch}")
1692 return releaseOpenstackK8sBranch
1693}
1694
1695
Sergey Zhemerdeev1d2c03e2023-04-28 11:07:24 +03001696
1697/**
1698 * Translates set of environment vars into actual replicator command line
1699 * @return: (string cmdParams, string jobDescription)
1700 * cmdParams - generated command line
1701 * jobDescription - job description
1702 */
1703def genReplicatorCommandLine() {
1704 def mainModes = ['REPLICATE', 'CLEANUP', 'CHECK_REPOS', 'BIN_CLEANUP']
Sergey Zhemerdeev9919b1b2023-04-28 17:24:21 +03001705 def parameterWithoutArgument = mainModes
Sergey Zhemerdeev1d2c03e2023-04-28 11:07:24 +03001706 def parametersList = parameterWithoutArgument + [
1707 'ARTIFACT_FILTER',
1708 'ARTIFACT_TYPE',
1709 'BIN_CLEAN_KEEP_DAYS',
1710 'BIN_CLEAN_PREFIX',
1711 'DOCKER_TAG',
1712 // DST_ will be changed to TARGET_
1713 'DST_REPO',
1714 'DST_REPO_TYPE',
1715 'DST_USER',
1716 'OLDER_THAN_DAYS',
1717 'SLACK_BUILD_URL',
1718 'SLACK_CHANNEL',
1719 'SLACK_USER',
1720 'SRC_REPO',
1721 'SRC_REPO_TYPE',
1722 'SRC_USER',
1723 'SYNC_PATTERN',
1724 'THREAD_COUNT'
1725 ]
1726 def mainModesDescriptions = [
1727 'REPLICATE': 'Replicating binaries/Docker images',
1728 'CLEANUP': 'Cleaning Docker images',
1729 'BIN_CLEANUP': 'Cleaning binaries',
1730 'CHECK_REPOS': 'Checking binaries'
1731 ]
1732
1733 def cmdParams = ''
1734 def jobDescription = ''
1735 for (e in parametersList) {
1736 if (env[e] == null || env[e] == '') {
1737 continue
1738 }
1739 if (e in mainModes) {
1740 jobDescription = mainModesDescriptions[e]
1741 }
1742 cmdParams += "-${e.replaceAll('_', '-').toLowerCase()} "
1743 if (!(e in parameterWithoutArgument)) {
1744 cmdParams += "'${env[e]}' "
1745 }
1746 }
1747 return [cmdParams, jobDescription]
1748}