blob: 43fd71e11b5eea4490a0a1de0aa6aa37225f4ab4 [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
4
vnaumov33747e12020-05-04 17:35:20 +02005/**
6 *
7 * KaaS Component Testing Utilities
8 *
9 */
10
Владислав Наумовe5345812020-08-12 16:30:20 +020011/**
12 * Check KaaS Core CICD feature flags
13 * such triggers can be used in case of switching between pipelines,
14 * conditions inside pipelines to reduce dependency on jenkins job builder and jenkins job templates itself
15 *
16 * @return (map)[
17 * ffNameEnabled: (bool) True/False
18 * ]
19 */
20def checkCoreCIFeatureFlags() {
21 def common = new com.mirantis.mk.Common()
22 def ff = [
23 build_artifacts_upgrade: false,
24 ]
25
26 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
27 if (commitMsg ==~ /(?s).*\[ci-build-artifacts-upgrade\].*/) {
28 ff['build_artifacts_upgrade'] = true
29 }
30
31 common.infoMsg("Core ci feature flags status: ${ff}")
32 return ff
33}
vnaumov33747e12020-05-04 17:35:20 +020034
35/**
azvyagintseva12230a2020-06-05 13:24:06 +030036 * Determine scope of test suite against per-commit KaaS deployment based on keywords
Владислав Наумов81777472021-03-09 15:14:27 +040037 * 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 +030038 *
39 * Used for components team to combine test-suites and forward desired parameters to kaas/core deployment jobs
40 * Example scheme:
Владислав Наумовe5345812020-08-12 16:30:20 +020041 * 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 +030042 * manage test-suite through Jenkins Job Parameters
43 *
Владислав Наумов6c2afff2020-06-05 12:54:53 +020044 * @return (map)[
45 * deployChildEnabled: (bool) True if need to deploy child cluster during demo-run
46 * runUie2eEnabled: (bool) True if need to run ui-e2e cluster during demo-run
azvyagintseva12230a2020-06-05 13:24:06 +030047 * ]
48 */
vnaumov33747e12020-05-04 17:35:20 +020049def checkDeploymentTestSuite() {
vnaumovbdb90222020-05-04 18:25:50 +020050 def common = new com.mirantis.mk.Common()
51
vnaumov33747e12020-05-04 17:35:20 +020052 // Available triggers and its sane defaults
Владислав Наумов44c64b72020-12-04 20:22:53 +010053 def seedMacOs = env.SEED_MACOS ? env.SEED_MACOS.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020054 def deployChild = env.DEPLOY_CHILD_CLUSTER ? env.DEPLOY_CHILD_CLUSTER.toBoolean() : false
55 def upgradeChild = env.UPGRADE_CHILD_CLUSTER ? env.UPGRADE_CHILD_CLUSTER.toBoolean() : false
Sergey Lalovc1cb49f2022-09-27 01:16:25 +040056 def fullUpgradeChild = env.FULL_UPGRADE_CHILD_CLUSTER ? env.FULL_UPGRADE_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov38ee4382022-01-27 16:21:51 +040057 def mosDeployChild = env.DEPLOY_MOS_CHILD_CLUSTER ? env.DEPLOY_MOS_CHILD_CLUSTER.toBoolean() : false
58 def mosUpgradeChild = env.UPGRADE_MOS_CHILD_CLUSTER ? env.UPGRADE_MOS_CHILD_CLUSTER.toBoolean() : false
Mikhail Ivanov74504372021-05-21 17:01:06 +040059 def customChildRelease = env.KAAS_CHILD_CLUSTER_RELEASE_NAME ? env.KAAS_CHILD_CLUSTER_RELEASE_NAME : ''
slalov021171f2022-03-04 14:48:38 +040060 def mosTfDeploy = env.MOS_TF_DEPLOY ? env.MOS_TF_DEPLOY.toBoolean() : false
Владислав Наумов0dc99252020-11-13 13:30:48 +010061 def attachBYO = env.ATTACH_BYO ? env.ATTACH_BYO.toBoolean() : false
Владислав Наумовcdbd84e2020-12-01 16:51:09 +010062 def upgradeBYO = env.UPGRADE_BYO ? env.UPGRADE_BYO.toBoolean() : false
Vladislav Naumov7930ab22021-11-22 18:24:24 +010063 def runBYOMatrix = env.RUN_BYO_MATRIX ? env.RUN_BYO_MATRIX.toBoolean() : false
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +040064 def defaultBYOOs = env.DEFAULT_BYO_OS ? env.DEFAULT_BYO_OS.toString() : 'ubuntu'
Владислав Наумов6c2afff2020-06-05 12:54:53 +020065 def upgradeMgmt = env.UPGRADE_MGMT_CLUSTER ? env.UPGRADE_MGMT_CLUSTER.toBoolean() : false
slalov1202bba2022-04-20 22:31:07 +040066 def autoUpgradeMgmt = env.AUTO_UPGRADE_MCC ? env.AUTO_UPGRADE_MCC.toBoolean() : false
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +040067 def enableLMALogging = env.ENABLE_LMA_LOGGING ? env.ENABLE_LMA_LOGGING.toBoolean(): false
Sergey Lalovb2f60372022-09-20 23:58:47 +040068 def deployOsOnMos = env.DEPLOY_OS_ON_MOS? env.DEPLOY_OS_ON_MOS.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020069 def runUie2e = env.RUN_UI_E2E ? env.RUN_UI_E2E.toBoolean() : false
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +040070 def runUie2eNew = env.RUN_UI_E2E_NEW ? env.RUN_UI_E2E_NEW.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020071 def runMgmtConformance = env.RUN_MGMT_CFM ? env.RUN_MGMT_CFM.toBoolean() : false
Sergey Lalovafcc0432023-04-13 14:59:06 +040072 def runMgmtConformanceNetworkPolicy = env.RUN_MGMT_CFM_NETWORK_POLICY ? env.RUN_MGMT_CFM_NETWORK_POLICY.toBoolean() : false
Владислав Наумов9cec55d2021-08-03 15:00:59 +020073 def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +020074 def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false
Mikhail Ivanov2907e4d2022-04-25 16:41:21 +040075 def runProxyChildTest = env.RUN_PROXY_CHILD_TEST ? env.RUN_PROXY_CHILD_TEST.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020076 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
Sergey Lalov012496a2023-11-27 15:57:52 +040077 def runChildStacklightHa = env.RUN_STACKLIGHT_CHILD_HA ? env.RUN_STACKLIGHT_CHILD_HA.toBoolean() : false
Sergey Lalovafcc0432023-04-13 14:59:06 +040078 def runChildConformanceNetworkPolicy = env.RUN_CHILD_CFM_NETWORK_POLICY ? env.RUN_CHILD_CFM_NETWORK_POLICY.toBoolean() : false
vryzhenkinb286bd82023-04-04 07:17:52 +040079 def runChildHPA = env.RUN_CHILD_HPA ? env.RUN_CHILD_HPA.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020080 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Vladislav Naumov42b71dc2021-11-22 13:09:42 +010081 def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
slalov13e579c2022-01-31 21:37:02 +040082 def runMaintenanceTest = env.RUN_MAINTENANCE_TEST ? env.RUN_MAINTENANCE_TEST.toBoolean() : false
slalov0a4947a2022-06-09 15:44:35 +040083 def runContainerregistryTest = env.RUN_CONTAINER_REGISTRY_TEST ? env.RUN_CONTAINER_REGISTRY_TEST.toBoolean() : false
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +030084 def runMgmtDeleteMasterTest = env.RUN_MGMT_DELETE_MASTER_TEST ? env.RUN_MGMT_DELETE_MASTER_TEST.toBoolean() : false
85 def runRgnlDeleteMasterTest = env.RUN_RGNL_DELETE_MASTER_TEST ? env.RUN_RGNL_DELETE_MASTER_TEST.toBoolean() : false
86 def runChildDeleteMasterTest = env.RUN_CHILD_DELETE_MASTER_TEST ? env.RUN_CHILD_DELETE_MASTER_TEST.toBoolean() : false
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +030087 def runGracefulRebootTest = env.RUN_GRACEFUL_REBOOT_TEST ? env.RUN_GRACEFUL_REBOOT_TEST.toBoolean() : false
Sergey Lalovbc68d752022-11-08 13:40:53 +040088 def pauseForDebug = env.PAUSE_FOR_DEBUG ? env.PAUSE_FOR_DEBUG.toBoolean() : false
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +030089 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 +040090 def runChildCustomCertTest = env.RUN_CHILD_CUSTOM_CERT_TEST ? env.RUN_CHILD_CUSTOM_CERT_TEST.toBoolean() : false
Sergey Lalov430fcd72023-03-20 17:19:44 +040091 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 +040092 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 +040093 def runMkeCustomCertTest = env.RUN_MKE_CUSTOM_CERT_TEST ? env.RUN_MKE_CUSTOM_CERT_TEST.toBoolean() : false
Sergey Lalov62c28312023-10-18 19:23:59 +040094 def runCustomHostnames = env.RUN_CUSTOM_HOSTNAMES ? env.RUN_CUSTOM_HOSTNAMES.toBoolean() : false
vryzhenkin504dfc92023-11-01 15:49:47 +040095 def slLatest = env.SL_LATEST ? env.SL_LATEST.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020096 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
97 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
98 enabled: false,
99 managementLocation: '',
100 regionLocation: '',
101 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200102
Владислав Наумовb8305e22021-02-10 17:23:12 +0100103 // proxy customization
104 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200105 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
106 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +0200107 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +0100108 ]
109
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200110 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +0200111 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +0200112 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +0200113 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +0200114 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +0200115 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200116 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400117 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200118 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +0300119 def enableBMDemo = true
Sergey Lalovd0e20852023-08-17 19:11:19 +0400120 def enablebmCoreDemo = false
121 def bmCoreCleanup = env.BM_CORE_CLEANUP ? env.BM_CORE_CLEANUP : true
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400122 def enableArtifactsBuild = true
Sergey Lalovd0e20852023-08-17 19:11:19 +0400123 def bmDeployType = 'virtual'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400124 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300125 def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500126 def enableVsphereRHEL = env.VSPHERE_DEPLOY_RHEL ? env.VSPHERE_DEPLOY_RHEL.toBoolean() : false
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300127 def childOsBootFromVolume = env.OPENSTACK_BOOT_FROM_VOLUME ? env.OPENSTACK_BOOT_FROM_VOLUME.toBoolean() : false
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400128 def bootstrapV2Scenario = env.BOOTSTRAP_V2_ENABLED ? env.BOOTSTRAP_V2_ENABLED.toBoolean() : false
Sergey Lalovacec3c12022-07-20 16:00:14 +0400129 def equinixMetalV2Metro = env.EQUINIX_MGMT_METRO ? env.EQUINIX_MGMT_METRO : ''
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400130 def enableFips = env.ENABLE_FIPS ? env.ENABLE_FIPS.toBoolean() : false
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400131 def enableMkeDebug = env.ENABLE_MKE_DEBUG ? env.ENABLE_MKE_DEBUG.toBoolean() : false
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300132 def aioCluster = env.AIO_CLUSTER ? env.AIO_CLUSTER.toBoolean() : false
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100133 def useVsphereVvmtObjects = env.VSPHERE_USE_VVMT_OBJECTS ? env.VSPHERE_USE_VVMT_OBJECTS.toBoolean() : false
vryzhenkin4fd3f242023-03-29 15:13:46 +0400134 def enableBv2Smoke = true
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400135 def runCacheWarmup = env.CACHE_WARMUP_ENABLED ? env.CACHE_WARMUP_ENABLED.toBoolean() : false
vryzhenkin211a4e82023-11-23 12:48:27 +0400136 def cveScan = false
vnaumov33747e12020-05-04 17:35:20 +0200137
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200138 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +0100139 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
140 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200141 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 +0100142 }
Sergey Kolekonov5995dfd2023-07-06 16:09:43 +0600143 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
144 upgradeMgmt = true
145 }
146 if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) {
147 autoUpgradeMgmt = true
148 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100149 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
150 seedMacOs = true
151 }
Sergey Lalovafcc0432023-04-13 14:59:06 +0400152 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ ||
153 upgradeChild || runChildConformance || runProxyChildTest || runChildHPA || runChildConformanceNetworkPolicy) {
vnaumov33747e12020-05-04 17:35:20 +0200154 deployChild = true
155 }
156 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
157 deployChild = true
158 upgradeChild = true
159 }
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400160 if (commitMsg ==~ /(?s).*\[child-upgrade-full\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade-full.*/) {
161 deployChild = true
162 upgradeChild = true
Sergey Lalova048df92023-06-19 19:36:41 +0400163 common.warningMsg("2-step child updates are not testing (PRODX-33510)")
164 //TODO: revert after start testing the two-step upgrade again (PRODX-33510)
165 //fullUpgradeChild = true
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400166 }
Sergey Kolekonov5995dfd2023-07-06 16:09:43 +0600167 if ((upgradeMgmt || autoUpgradeMgmt) && deployChild) {
168 upgradeChild = true
169 common.warningMsg('child upgrade is automatically enabled as mgmt upgrade and child deploy are enabled')
170 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400171 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
172 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400173 // override child version when it set explicitly
174 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400175 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400176 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
177 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400178 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
179 mosDeployChild = true
180 }
181 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
182 mosDeployChild = true
183 mosUpgradeChild = true
184 }
Sergey Kolekonov5995dfd2023-07-06 16:09:43 +0600185 if ((upgradeMgmt || autoUpgradeMgmt) && mosDeployChild) {
186 mosUpgradeChild = true
187 common.warningMsg('MOSK child upgrade is automatically enabled as mgmt upgrade and MOSK child deploy are enabled')
188 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100189 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
190 attachBYO = true
191 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100192 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
193 attachBYO = true
194 upgradeBYO = true
195 }
Sergey Lalovacec3c12022-07-20 16:00:14 +0400196 if (commitMsg ==~ /(?s).*\[ui-test-on-all-providers\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-test-on-all-providers.*/) {
197 enableVsphereDemo = true
198 enableOSDemo = true
199 awsOnDemandDemo = true
200 azureOnDemandDemo = true
201 equinixOnDemandDemo = true
202 equinixMetalV2OnDemandDemo = true
203 runUie2e = true
Sergey Lalovacec3c12022-07-20 16:00:14 +0400204 // Edit after fix PRODX-3961
205 enableBMDemo = false
206 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400207 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
208 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 +0100209 runBYOMatrix = true
210
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400211 if (byoDeployMatches.size() > 0) {
212 defaultBYOOs = byoDeployMatches[0][2]
213 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
214 }
215
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100216 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
217 attachBYO = false
218 upgradeBYO = false
219 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400220 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
221 enableLMALogging = true
222 }
Sergey Lalovb2f60372022-09-20 23:58:47 +0400223 if (commitMsg ==~ /(?s).*\[deploy-os-on-mos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*deploy-os-on-mos.*/) {
224 deployOsOnMos = true
225 mosDeployChild = true
226 openstackIMC = 'eu2'
227 }
Sergey Lalovd0e20852023-08-17 19:11:19 +0400228
229 if (commitMsg ==~ /(?s).*\[half-virtual\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*half-virtual.*/ || upgradeMgmt) {
230 bmDeployType = 'half-virtual'
231 common.infoMsg('Half-virtual will be deployed by default on upgrade case')
232 }
233
Sergey Lalov95040602023-03-07 16:42:16 +0400234 if (commitMsg ==~ /(?s).*\[ui-e2e-nw\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-nw.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200235 runUie2e = true
236 }
Sergey Lalov95040602023-03-07 16:42:16 +0400237 if (commitMsg ==~ /(?s).*\[ui-e2e-pw\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-pw.*/) {
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400238 runUie2eNew = true
239 }
vnaumov33747e12020-05-04 17:35:20 +0200240 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
241 runMgmtConformance = true
242 }
Sergey Lalovafcc0432023-04-13 14:59:06 +0400243 if (commitMsg ==~ /(?s).*\[mgmt-cfm-netpolicy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm-netpolicy.*/) {
244 runMgmtConformanceNetworkPolicy = true
245 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200246 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
247 runMgmtUserControllerTest = true
248 }
slalov574123e2022-04-06 17:24:19 +0400249 if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) {
250 runProxyChildTest = true
251 deployChild = true
252 common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed')
253 }
vnaumov33747e12020-05-04 17:35:20 +0200254 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
255 runChildConformance = true
256 deployChild = true
257 }
Sergey Lalovafcc0432023-04-13 14:59:06 +0400258 if (commitMsg ==~ /(?s).*\[child-cfm-netpolicy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm-netpolicy.*/) {
259 runChildConformanceNetworkPolicy = true
260 deployChild = true
261 }
vryzhenkinb286bd82023-04-04 07:17:52 +0400262 if (commitMsg ==~ /(?s).*\[child-hpa\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-hpa.*/) {
263 runChildHPA = true
264 deployChild = true
265 }
Sergey Lalov012496a2023-11-27 15:57:52 +0400266 if (commitMsg ==~ /(?s).*\[child-sl-ha\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-sl-ha.*/) {
267 runChildStacklightHa = true
268 deployChild = true
269 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200270 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
271 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400272 enableLMALogging = true
273 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400274 }
slalov13e579c2022-01-31 21:37:02 +0400275 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
276 runMaintenanceTest = true
277 }
slalov0a4947a2022-06-09 15:44:35 +0400278 if (commitMsg ==~ /(?s).*\[container-registry-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*container-registry-test.*/) {
279 runContainerregistryTest = true
280 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300281 if (commitMsg ==~ /(?s).*\[mgmt-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-delete-master-test.*/) {
282 runMgmtDeleteMasterTest = true
283 }
284 if (commitMsg ==~ /(?s).*\[rgnl-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*rgnl-delete-master-test.*/) {
285 runRgnlDeleteMasterTest = true
286 }
287 if (commitMsg ==~ /(?s).*\[child-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-delete-master-test.*/) {
Sergey Lalov47e21592023-07-18 23:36:32 +0400288 if (!mosDeployChild) {
289 deployChild = true
290 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300291 runChildDeleteMasterTest = true
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300292 common.infoMsg('Child cluster deployment will be enabled since delete child master node test suite will be executed')
293 }
294 if (commitMsg ==~ /(?s).*\[child-machine-deletion-policy-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-machine-deletion-policy-test.*/) {
295 runChildMachineDeletionPolicyTest = true
296 deployChild = true
297 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 +0300298 }
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300299 if (commitMsg ==~ /(?s).*\[graceful-reboot-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*graceful-reboot-test.*/) {
300 runGracefulRebootTest = true
301 }
Sergey Lalovbc68d752022-11-08 13:40:53 +0400302 if (commitMsg ==~ /(?s).*\[pause-for-debug\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*pause-for-debug.*/) {
303 pauseForDebug = true
304 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200305 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
306 proxyConfig['childOffline'] = true
307 deployChild = true
308 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200309 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
310 proxyConfig['childOffline'] = true
311 proxyConfig['childProxy'] = true
312 deployChild = true
313 }
vnaumov33747e12020-05-04 17:35:20 +0200314 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
315 fetchServiceBinaries = true
316 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200317 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400318 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200319 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]\' ')
eromanovadf247c32020-12-25 15:44:13 +0400320 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200321 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
322 azureOnAwsDemo = true
323 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
324 }
325 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
326 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
327 attachBYO ||
328 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100329 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200330 seedMacOs ||
331 equinixOnAwsDemo ||
332 azureOnAwsDemo) {
333
vnaumov33747e12020-05-04 17:35:20 +0200334 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200335 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 +0200336 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200337 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200338 equinixOnDemandDemo = true
339 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200340 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200341 equinixMetalV2OnDemandDemo = true
342 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100343 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
344 equinixMetalV2OnDemandDemo = true
345 equinixMetalV2ChildDiffMetro = true
346 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200347 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
348 azureOnDemandDemo = true
349 }
Sergey Lalov10cb3502023-03-27 22:13:49 +0400350 if (commitMsg ==~ /(?s).*\[disable-all-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-all-demo\.*/) {
351 enableVsphereDemo = false
352 enableOSDemo = false
353 enableBMDemo = false
Sergey Lalov781fccc2023-10-12 21:55:17 +0400354 enableBv2Smoke = false
355 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 +0400356 }
357
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200358 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
359 enableOSDemo = false
360 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200361 }
362
azvyagintsev1761bdc2020-09-04 17:24:12 +0300363 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
364 enableBMDemo = false
365 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
366 }
367
Sergey Lalovd0e20852023-08-17 19:11:19 +0400368 if (commitMsg ==~ /(?s).*\[bm-core-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bm-core-demo\\.*/) {
369 enablebmCoreDemo = true
370 enableBMDemo = false
371 }
372
373 if (commitMsg ==~ /(?s).*\[disable-bm-core-cleanup\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-core-cleanup\\.*/) {
374 bmCoreCleanup = false
375 }
376
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400377 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
378 enableVsphereDemo = false
379 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
380 }
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300381 if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) {
382 enableVsphereUbuntu = true
383 common.warningMsg('Ubuntu will be used to deploy vsphere machines')
384 }
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500385 if (commitMsg ==~ /(?s).*\[vsphere-rhel\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-rhel\.*/) {
386 enableVsphereRHEL = true
387 common.warningMsg('RHEL will be used to deploy vsphere machines')
388 }
vryzhenkin4fd3f242023-03-29 15:13:46 +0400389 if (commitMsg ==~ /(?s).*\[disable-bv2-smoke\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bv2-smoke\.*/) {
390 enableBv2Smoke = false
391 common.errorMsg('Bootstrap v2 smoke checks will be aborted, WF -1 will be set')
392 }
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400393
vryzhenkin211a4e82023-11-23 12:48:27 +0400394 if (commitMsg ==~ /(?s).*\[cve-scan\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*cve-scan\.*/) {
395 cveScan = true
396 common.errorMsg('CVE Scan job enabled')
397 }
398
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400399 if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
400 enableArtifactsBuild = false
401 common.errorMsg('artifacts build will be aborted, VF -1 will be set')
402 }
403
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300404 if (commitMsg ==~ /(?s).*\[child-os-boot-from-volume\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-os-boot-from-volume\.*/) {
405 childOsBootFromVolume = true
406 common.warningMsg('OS will be booted from Ceph volumes')
407 }
408
Sergey Lalovd5efcd52023-03-01 22:42:17 +0400409 if (commitMsg ==~ /(?s).*\[child-custom-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-custom-cert-test\.*/) {
410 runChildCustomCertTest = true
411 deployChild = true
412 common.warningMsg('Child cluster deployment will be enabled since custom cert child test suite will be executed')
413 }
414
Sergey Lalovf6fbfea2023-04-06 17:05:40 +0400415 if (commitMsg ==~ /(?s).*\[mgmt-custom-cache-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-custom-cache-cert-test\.*/) {
416 runMgmtCustomCacheCertTest = true
417 deployChild = true
418 common.warningMsg('Child cluster deployment will be enabled as the test replaces the mgmt and cluster childcertificates')
419 }
420
Sergey Lalov48e69022023-07-25 16:08:00 +0400421 if (commitMsg ==~ /(?s).*\[mke-custom-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mke-custom-cert-test\.*/) {
422 runMkeCustomCertTest = true
423 }
424
Sergey Lalov62c28312023-10-18 19:23:59 +0400425 if (commitMsg ==~ /(?s).*\[custom-hostnames\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*custom-hostnames\.*/) {
426 runCustomHostnames = true
427 common.warningMsg('All clusters will be deployed with Custom Hostnames')
428 }
429
vryzhenkin504dfc92023-11-01 15:49:47 +0400430 if (commitMsg ==~ /(?s).*\[sl-latest\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*sl-latest\.*/) {
431 slLatest = true
432 common.warningMsg('All clusters will be deployed with Stacklight version from artifact-metadata')
433 }
434
Sergey Lalov430fcd72023-03-20 17:19:44 +0400435 if (commitMsg ==~ /(?s).*\[byo-child-custom-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-child-custom-cert-test\.*/) {
436 runByoChildCustomCertTest = true
437 attachBYO = true
438 common.warningMsg('Byo child cluster deployment will be enabled since custom cert child test suite will be executed')
439 }
440
vnaumov33747e12020-05-04 17:35:20 +0200441 // TODO (vnaumov) remove below condition after moving all releases to UCP
442 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
443 if (ucpChildMatches.size() > 0) {
444 deployChild = true
445 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
446
447 // TODO(vnaumov) delete after ucp upgrades support
448 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
449 upgradeChild = false
450 }
451
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300452 if (commitMsg ==~ /(?s).*\[aio-cluster\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aio-cluster.*/) {
453 aioCluster = true
454 }
455
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400456 if (commitMsg ==~ /(?s).*\[cache-warmup\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*cache-warmup.*/) {
457 runCacheWarmup = true
458 }
459
460 if (runCacheWarmup && (!deployChild && !mosDeployChild)) {
461 runCacheWarmup = false
462 common.errorMsg('Child cluster deployment is not enabled, skipping Cache Warmup')
463 }
464
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200465 // multiregional tests
466 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
467 if (multiRegionalMatches.size() > 0) {
468 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
469 }
470 switch (multiregionalMappings['managementLocation']) {
471 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100472 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200473 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100474
475 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
476 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
477 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200478 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200479 case 'os':
480 if (enableOSDemo == false) {
481 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
482 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200483 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200484 case 'vsphere':
485 if (enableVsphereDemo == false) {
486 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
487 }
488 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200489 case 'equinix':
490 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
491 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400492 break
eromanova8c702ae2021-12-24 17:43:12 +0400493 case 'equinixmetalv2':
494 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
495 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400496 break
slalovfd0b7e62021-07-28 18:05:16 +0400497 case 'azure':
498 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
499 azureOnDemandDemo = true
500 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200501 }
502
Владислав Наумовb8305e22021-02-10 17:23:12 +0100503 // CDN configuration
504 def cdnConfig = [
505 mgmt: [
Sergey Lalovde909ea2023-05-31 20:21:02 +0400506 openstack: 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200507 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100508 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200509 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200510 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200511 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100512 ]
513
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400514 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
515 openstackIMC = 'eu'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400516 }
slalov021171f2022-03-04 14:48:38 +0400517 if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) {
518 openstackIMC = 'eu2'
Mikhail Ivanovf05b8252022-04-27 18:14:03 +0400519 }
520 if (openstackIMC == 'eu' || openstackIMC == 'eu2') {
slalov021171f2022-03-04 14:48:38 +0400521 // use internal-eu because on internal-ci with eu cloud image pull takes much time
Sergey Lalovde909ea2023-05-31 20:21:02 +0400522 def cdnRegion = 'internal-eu'
slalov021171f2022-03-04 14:48:38 +0400523 common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}")
524 cdnConfig['mgmt']['openstack'] = cdnRegion
525 }
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400526
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100527 // calculate weight of current demo run to manage lockable resources
Sergey Lalov46deb442022-08-18 12:11:03 +0400528 def demoWeight = deployChild ? 2 : 1 // management = 1, child += 1
Sergey Lalov95040602023-03-07 16:42:16 +0400529 if (runUie2e || runUie2eNew) {
Sergey Lalov46deb442022-08-18 12:11:03 +0400530 demoWeight += 1
531 }
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100532
Sergey Laloveb611b22023-09-22 16:59:09 +0400533 if (commitMsg ==~ /(?s).*\[bootstrapv1-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv1-scenario\.*/) {
534 bootstrapV2Scenario = false
535 }
536
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400537 if (commitMsg ==~ /(?s).*\[bootstrapv2-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv2-scenario\.*/) {
538 bootstrapV2Scenario = true
539 }
540
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400541 if (commitMsg ==~ /(?s).*\[enable-fips\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*enable-fips\.*/) {
542 enableFips = true
543 }
544
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400545 if (commitMsg ==~ /(?s).*\[enable-mke-debug\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*enable-mke-debug\.*/) {
546 enableMkeDebug = true
547 }
548
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100549 if (commitMsg ==~ /(?s).*\[vsphere-vvmt-obj\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-vvmt-obj\.*/) {
550 useVsphereVvmtObjects = true
551 }
552
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300553 // parse equinixmetalv2-metro trigger
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300554 def equinixMetalV2MetroMatcher = (commitMsg =~ /\[equinixmetalv2-metro(\s+.*)?\]/)
555 if (equinixMetalV2OnDemandDemo && equinixMetalV2MetroMatcher.size() > 0) {
Sergey Zhemerdeevcc785e42022-07-22 17:15:47 +0300556 equinixMetalV2Metro = equinixMetalV2MetroMatcher[0][1].trim().toLowerCase()
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300557 common.infoMsg("Forced Equnix mgmt deployment using custom metro ${equinixMetalV2Metro}")
558 }
559
vnaumov33747e12020-05-04 17:35:20 +0200560 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400561 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100562 CDN deployment configuration: ${cdnConfig}
563 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100564 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200565 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400566 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200567 Child cluster release upgrade scheduled: ${upgradeChild}
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400568 Full Child cluster release upgrade scheduled: ${fullUpgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400569 MOS child deploy scheduled: ${mosDeployChild}
570 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200571 Child conformance testing scheduled: ${runChildConformance}
Sergey Lalovafcc0432023-04-13 14:59:06 +0400572 Child conformance network policy testing scheduled: ${runChildConformanceNetworkPolicy}
vryzhenkinb286bd82023-04-04 07:17:52 +0400573 Child HPA testing scheduled: ${runChildHPA}
Sergey Lalov012496a2023-11-27 15:57:52 +0400574 Child Stacklight HA: ${runChildStacklightHa}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100575 Single BYO cluster attachment scheduled: ${attachBYO}
576 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
577 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400578 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200579 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
slalov1202bba2022-04-20 22:31:07 +0400580 Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400581 Mgmt LMA logging enabled: ${enableLMALogging}
Sergey Lalovb2f60372022-09-20 23:58:47 +0400582 Deploy Os on child with mos release ${deployOsOnMos}
vnaumov33747e12020-05-04 17:35:20 +0200583 Mgmt conformance testing scheduled: ${runMgmtConformance}
Sergey Lalovafcc0432023-04-13 14:59:06 +0400584 Mgmt conformance network policy testing scheduled: ${runMgmtConformanceNetworkPolicy}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200585 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200586 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200587 Mgmt UI e2e testing scheduled: ${runUie2e}
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400588 Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
slalov13e579c2022-01-31 21:37:02 +0400589 Maintenance test: ${runMaintenanceTest}
slalov0a4947a2022-06-09 15:44:35 +0400590 Container Registry test: ${runContainerregistryTest}
slalov574123e2022-04-06 17:24:19 +0400591 Child proxy test: ${runProxyChildTest}
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300592 Graceful reboot test: ${runGracefulRebootTest}
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300593 Delete mgmt master node test: ${runMgmtDeleteMasterTest}
594 Delete rgnl master node test: ${runRgnlDeleteMasterTest}
595 Delete child master node test: ${runChildDeleteMasterTest}
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300596 Child machine deletion policy test: ${runChildMachineDeletionPolicyTest}
Sergey Lalovd5efcd52023-03-01 22:42:17 +0400597 Custom cert test for child clusters: ${runChildCustomCertTest}
Sergey Lalov430fcd72023-03-20 17:19:44 +0400598 Custom cert test for Byo child clusters: ${runByoChildCustomCertTest}
Sergey Lalovf6fbfea2023-04-06 17:05:40 +0400599 Custom cache cert test for mgmt and child clusters: ${runMgmtCustomCacheCertTest}
Sergey Lalov48e69022023-07-25 16:08:00 +0400600 MKE custom cert test for mgmt/region: ${runMkeCustomCertTest}
Sergey Lalov62c28312023-10-18 19:23:59 +0400601 Custom hostnames for all clisuers: ${runCustomHostnames}
vryzhenkin504dfc92023-11-01 15:49:47 +0400602 Stacklight templates enchanced with latest version from artifact-metadata: ${slLatest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200603 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200604 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200605 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100606 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Sergey Zhemerdeev019c45a2022-08-13 00:09:07 +0300607 EquinixmetalV2 mgmt will be deployed on the metro: ${equinixMetalV2Metro?:'auto'}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200608 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200609 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200610 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400611 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200612 OS provider deployment scheduled: ${enableOSDemo}
Sergey Lalovd0e20852023-08-17 19:11:19 +0400613 BM Core provider deployment scheduled: ${enablebmCoreDemo}
614 BM Core type deplyment: ${bmDeployType}
615 BM Core cleanup: ${bmCoreCleanup}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300616 BM provider deployment scheduled: ${enableBMDemo}
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300617 Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500618 RHEL on vSphere scheduled: ${enableVsphereRHEL}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400619 Artifacts build scheduled: ${enableArtifactsBuild}
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300620 Boot OS child from Ceph volumes: ${childOsBootFromVolume}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200621 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200622 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100623 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400624 Bootstrap v2 scenario enabled: ${bootstrapV2Scenario}
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400625 FIPS enabled: ${enableFips}
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400626 MKE DEBUG enabled: ${enableMkeDebug}
Sergey Lalovbc68d752022-11-08 13:40:53 +0400627 Pause for debug enabled: ${pauseForDebug}
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300628 AIO cluster: ${aioCluster}
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100629 Use Vsphere VVMT Objects: ${useVsphereVvmtObjects}
vryzhenkin4fd3f242023-03-29 15:13:46 +0400630 Bootsrap v2 smoke checks enabled: ${enableBv2Smoke}
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400631 Run Cache warmup for child clusters: ${runCacheWarmup}
vryzhenkin211a4e82023-11-23 12:48:27 +0400632 CVE Scan enabled: ${cveScan}
Владислав Наумов81777472021-03-09 15:14:27 +0400633 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200634 return [
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300635 osCloudLocation : openstackIMC,
636 cdnConfig : cdnConfig,
637 proxyConfig : proxyConfig,
638 useMacOsSeedNode : seedMacOs,
639 deployChildEnabled : deployChild,
640 childDeployCustomRelease : customChildRelease,
641 upgradeChildEnabled : upgradeChild,
642 fullUpgradeChildEnabled : fullUpgradeChild,
643 mosDeployChildEnabled : mosDeployChild,
644 mosUpgradeChildEnabled : mosUpgradeChild,
645 runChildConformanceEnabled : runChildConformance,
Sergey Lalovafcc0432023-04-13 14:59:06 +0400646 runChildConformanceNetworkPolicyEnabled : runChildConformanceNetworkPolicy,
vryzhenkinb286bd82023-04-04 07:17:52 +0400647 runChildHPAEnabled : runChildHPA,
Sergey Lalov012496a2023-11-27 15:57:52 +0400648 runChildStacklightHaEnabled : runChildStacklightHa,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300649 attachBYOEnabled : attachBYO,
650 upgradeBYOEnabled : upgradeBYO,
651 runBYOMatrixEnabled : runBYOMatrix,
652 defaultBYOOs : defaultBYOOs,
653 upgradeMgmtEnabled : upgradeMgmt,
654 autoUpgradeMgmtEnabled : autoUpgradeMgmt,
655 enableLMALoggingEnabled : enableLMALogging,
656 deployOsOnMosEnabled : deployOsOnMos,
657 runUie2eEnabled : runUie2e,
658 runUie2eNewEnabled : runUie2eNew,
659 runMgmtConformanceEnabled : runMgmtConformance,
Sergey Lalovafcc0432023-04-13 14:59:06 +0400660 runMgmtConformanceNetworkPolicyEnabled : runMgmtConformanceNetworkPolicy,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300661 runMaintenanceTestEnabled : runMaintenanceTest,
662 runContainerregistryTestEnabled : runContainerregistryTest,
663 runGracefulRebootTestEnabled : runGracefulRebootTest,
664 pauseForDebugEnabled : pauseForDebug,
665 runMgmtDeleteMasterTestEnabled : runMgmtDeleteMasterTest,
666 runRgnlDeleteMasterTestEnabled : runRgnlDeleteMasterTest,
667 runChildDeleteMasterTestEnabled : runChildDeleteMasterTest,
Sergey Lalovd5efcd52023-03-01 22:42:17 +0400668 runChildCustomCertTestEnabled : runChildCustomCertTest,
Sergey Lalovf6fbfea2023-04-06 17:05:40 +0400669 runMgmtCustomCacheCertTestEnabled : runMgmtCustomCacheCertTest,
Sergey Lalov48e69022023-07-25 16:08:00 +0400670 runMkeCustomCertTestEnabled : runMkeCustomCertTest,
Sergey Lalov62c28312023-10-18 19:23:59 +0400671 runCustomHostnamesEnabled : runCustomHostnames,
vryzhenkin504dfc92023-11-01 15:49:47 +0400672 slLatestEnabled : slLatest,
Sergey Lalov430fcd72023-03-20 17:19:44 +0400673 runByoChildCustomCertTestEnabled : runByoChildCustomCertTest,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300674 runChildMachineDeletionPolicyTestEnabled : runChildMachineDeletionPolicyTest,
675 runLMATestEnabled : runLMATest,
676 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
677 runProxyChildTestEnabled : runProxyChildTest,
678 fetchServiceBinariesEnabled : fetchServiceBinaries,
679 awsOnDemandDemoEnabled : awsOnDemandDemo,
680 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
681 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
682 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
683 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
684 azureOnDemandDemoEnabled : azureOnDemandDemo,
685 azureOnAwsDemoEnabled : azureOnAwsDemo,
686 vsphereDemoEnabled : enableVsphereDemo,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300687 bmDemoEnabled : enableBMDemo,
Sergey Lalovd0e20852023-08-17 19:11:19 +0400688 bmCoreDemoEnabled : enablebmCoreDemo,
689 bmCoreCleanup : bmCoreCleanup,
690 bmDeployTypeEnabled : bmDeployType,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300691 osDemoEnabled : enableOSDemo,
692 vsphereUbuntuEnabled : enableVsphereUbuntu,
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500693 vsphereRHELEnabled : enableVsphereRHEL,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300694 artifactsBuildEnabled : enableArtifactsBuild,
695 childOsBootFromVolume : childOsBootFromVolume,
696 multiregionalConfiguration : multiregionalMappings,
697 demoWeight : demoWeight,
698 bootstrapV2Scenario : bootstrapV2Scenario,
699 equinixMetalV2Metro : equinixMetalV2Metro,
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300700 enableFips : enableFips,
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400701 enableMkeDebugEnabled : enableMkeDebug,
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100702 aioCluster : aioCluster,
vryzhenkin4fd3f242023-03-29 15:13:46 +0400703 useVsphereVvmtObjects : useVsphereVvmtObjects,
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400704 bv2SmokeEnabled : enableBv2Smoke,
705 runCacheWarmup : runCacheWarmup,
vryzhenkin211a4e82023-11-23 12:48:27 +0400706 cveScanEnabled : cveScan,
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400707 ]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200708}
709
710/**
711 * Determine management and regional setup for demo workflow scenario
712 *
713 *
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300714 * @param: keyword (string) string , represents keyword trigger, specified in gerrit commit body, like `[multiregion aws,os]`
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200715 or Jenkins environment string variable in form like 'aws,os'
716 * @return (map)[
717 enabled: (bool),
718 * managementLocation: (string), //aws,os
719 * regionLocation: (string), //aws,os
720 * ]
721 */
722def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200723 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400724 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
725 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200726
727 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200728 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200729 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
730 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
731 } else {
732 common.infoMsg('Multiregion definition configured via environment variable')
733 clusterTypes = keyword.trim().split(',')
734 }
735
736 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100737 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200738 }
739
Владислав Наумовf793fe32020-09-11 15:19:19 +0200740 def desiredManagementProvider = clusterTypes[0].trim()
741 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200742 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
743 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200744 management providers list - ${supportedManagementProviders}
745 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200746 }
747
748 return [
749 enabled: true,
750 managementLocation: desiredManagementProvider,
751 regionLocation: desiredRegionalProvider,
752 ]
vnaumov33747e12020-05-04 17:35:20 +0200753}
754
755/**
756 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
757
Владислав Наумов81777472021-03-09 15:14:27 +0400758 * 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 +0200759 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
760 * Example scheme:
761 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
762 * manage refspecs through Jenkins Job Parameters
763 *
azvyagintseva12230a2020-06-05 13:24:06 +0300764 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200765 * siPipelines: (string) final refspec for si-pipelines
766 * ]
767 */
768def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200769 def common = new com.mirantis.mk.Common()
770
vnaumov33747e12020-05-04 17:35:20 +0200771 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200772 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
773 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200774 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
775 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200776 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200777
778 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
779 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
780
781 if (siTestMatches.size() > 0) {
782 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400783 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200784 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200785 }
786 if (siPipelinesMatches.size() > 0) {
787 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
788 }
789
790 common.infoMsg("""
791 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
792 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200793 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400794 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200795 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200796}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200797
Владислав Наумов9080f372020-06-08 13:57:16 +0200798/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200799 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200800 * @param configurationFile (str) path to configuration file in yaml format
801 *
802 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300803 * siTestsFeatureFlagsStable (string) dedicated feature flags that will be used in SI tests for deploying stable release
Владислав Наумов30a516c2020-07-09 13:15:41 +0200804 * ]
805 */
806def parseKaaSComponentCIParameters(configurationFile){
807 def common = new com.mirantis.mk.Common()
808 def ciConfig = readYaml file: configurationFile
809 def ciSpec = [
810 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300811 siTestsFeatureFlagsStable: env.SI_TESTS_FEATURE_FLAGS_STABLE ?: '',
Владислав Наумов30a516c2020-07-09 13:15:41 +0200812 ]
813
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300814 // If exists and not empty
815 if (ciConfig.getOrDefault('si-tests-feature-flags', [])) {
Владислав Наумов30a516c2020-07-09 13:15:41 +0200816 common.infoMsg("""SI tests feature flags customization detected,
817 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
818
819 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
820 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200821
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200822 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200823 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
824 }
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300825 if (ciConfig.getOrDefault('si-tests-feature-flags-stable', [])) {
826 common.infoMsg("""SI tests feature flags for stable release customization detected,
827 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlagsStable']}] identification...""")
828
829 def ffMeta = ciSpec['siTestsFeatureFlagsStable'].tokenize(',').collect { it.trim() }
830 ffMeta.addAll(ciConfig['si-tests-feature-flags-stable'])
831
832 ciSpec['siTestsFeatureFlagsStable'] = ffMeta.unique().join(',')
833 common.infoMsg("SI tests custom feature flags for stable release: ${ciSpec['siTestsFeatureFlagsStable']}")
834 }
Владислав Наумов30a516c2020-07-09 13:15:41 +0200835
836 common.infoMsg("""Additional ci configuration parsed successfully:
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300837 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}
838 siTestsFeatureFlagsStable: ${ciSpec['siTestsFeatureFlagsStable']}""")
Владислав Наумов30a516c2020-07-09 13:15:41 +0200839 return ciSpec
840}
841
842/**
843 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200844
Владислав Наумов81777472021-03-09 15:14:27 +0400845 * 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 +0200846 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
847 * Example scheme:
848 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
849 * manage refspecs through Jenkins Job Parameters
850 *
851 * @return (map)[ core: (string) final refspec for kaas/core
852 * corePipelines: (string) final refspec for pipelines in kaas/core
853 * ]
854 */
855def checkCustomCoreRefspec() {
856 def common = new com.mirantis.mk.Common()
857
858 // Available triggers and its sane defaults
859 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
860 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
861 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
862 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
863
864 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
865 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
866
867 if (coreMatches.size() > 0) {
868 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
869 }
870 if (corePipelinesMatches.size() > 0) {
871 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
872 }
873
874 common.infoMsg("""
875 kaas/core will be fetched from: ${coreRefspec}
876 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400877 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200878 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
879}
880
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200881
882/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200883 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
884 * needed to forward inside kaas core set of jobs
885 *
886 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
887 * @return (list)[ string(name: '', value: ''),
888 * ]
889 */
890def generateKaaSVarsFromContext(context) {
891 def common = new com.mirantis.mk.Common()
892 def parameters = []
893 def config = readYaml text: context
894
895 config.each { k,v ->
896 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
897 parameters.add(string(name: k, value: v))
898 }
899
900 return parameters
901}
902
903/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200904 * 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 +0400905 * 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 +0200906 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
907 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200908 * @param: component (string) component name [iam, lcm, stacklight]
909 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
910 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200911 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200912def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200913 def common = new com.mirantis.mk.Common()
914 // Determine if custom trigger keywords forwarded from gerrit
915 def triggers = checkDeploymentTestSuite()
916 // Determine SI refspecs
917 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200918 // Determine Core refspecs
919 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200920
Владислав Наумов418042b2020-07-09 18:31:10 +0200921 // Determine component repo ci configuration
922 def ciSpec = [:]
923 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
924 if (fileExists(configurationFile)) {
925 common.infoMsg('Component CI configuration file detected, parsing...')
926 ciSpec = parseKaaSComponentCIParameters(configurationFile)
927 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
928 } else {
929 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200930 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200931 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
932 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200933 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400934
935 def platforms = []
936 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
937 // Currently only vsphere demo is required for IPAM component
938 platforms.add('vsphere')
939 } else {
940 if (triggers.osDemoEnabled) {
941 platforms.add('openstack')
942 }
943 if (triggers.awsOnDemandDemoEnabled) {
944 platforms.add('aws')
945 }
946 if (triggers.equinixOnDemandDemoEnabled) {
947 platforms.add('equinix')
948 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200949 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
950 platforms.add('equinixmetalv2')
951 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200952 if (triggers.azureOnDemandDemoEnabled) {
953 platforms.add('azure')
954 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400955 if (triggers.vsphereDemoEnabled) {
956 platforms.add('vsphere')
957 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400958 }
959
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200960 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200961 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200962 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
963 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200964 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200965 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200966 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
967 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200968 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200969 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400970 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400971 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100972 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200973 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200974 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100975 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200976 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
slalov1202bba2022-04-20 22:31:07 +0400977 booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400978 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Sergey Lalovb2f60372022-09-20 23:58:47 +0400979 booleanParam(name: 'DEPLOY_OS_ON_MOS', value: triggers.deployOsOnMosEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200980 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200981 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
Sergey Lalovafcc0432023-04-13 14:59:06 +0400982 booleanParam(name: 'RUN_MGMT_CFM_NETWORK_POLICY', value: triggers.runMgmtConformanceNetworkPolicyEnabled),
slalov0a4947a2022-06-09 15:44:35 +0400983 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnabled),
984 booleanParam(name: 'RUN_CONTAINER_REGISTRY_TEST', value: triggers.runContainerregistryTestEnabled),
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300985 booleanParam(name: 'RUN_GRACEFUL_REBOOT_TEST', value: triggers.runGracefulRebootTestEnabled),
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300986 booleanParam(name: 'RUN_MGMT_DELETE_MASTER_TEST', value: triggers.runMgmtDeleteMasterTestEnabled),
987 booleanParam(name: 'RUN_RGNL_DELETE_MASTER_TEST', value: triggers.runRgnlDeleteMasterTestEnabled),
988 booleanParam(name: 'RUN_CHILD_DELETE_MASTER_TEST', value: triggers.runChildDeleteMasterTestEnabled),
Sergey Lalovd5efcd52023-03-01 22:42:17 +0400989 booleanParam(name: 'RUN_CHILD_CUSTOM_CERT_TEST', value: triggers.runChildCustomCertTestEnabled),
Sergey Lalovf6fbfea2023-04-06 17:05:40 +0400990 booleanParam(name: 'RUN_MGMT_CUSTOM_CACHE_CERT_TEST', value: triggers.runMgmtCustomCacheCertTestEnabled),
Sergey Lalov48e69022023-07-25 16:08:00 +0400991 booleanParam(name: 'RUN_MKE_CUSTOM_CERT_TEST', value: triggers.runMkeCustomCertTestEnabled),
Sergey Lalov62c28312023-10-18 19:23:59 +0400992 booleanParam(name: 'RUN_CUSTOM_HOSTNAMES', value: triggers.runCustomHostnamesEnabled),
vryzhenkin504dfc92023-11-01 15:49:47 +0400993 booleanParam(name: 'SL_LATEST', value: triggers.slLatestEnabled),
Sergey Lalov430fcd72023-03-20 17:19:44 +0400994 booleanParam(name: 'RUN_BYO_CHILD_CUSTOM_CERT_TEST', value: triggers.runByoChildCustomCertTestEnabled),
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300995 booleanParam(name: 'RUN_CHILD_MACHINE_DELETION_POLICY_TEST', value: triggers.runChildMachineDeletionPolicyTestEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200996 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200997 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200998 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
999 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Sergey Lalovc1cb49f2022-09-27 01:16:25 +04001000 booleanParam(name: 'FULL_UPGRADE_CHILD_CLUSTER', value: triggers.fullUpgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +04001001 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +01001002 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +01001003 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +01001004 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +02001005 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Sergey Lalovafcc0432023-04-13 14:59:06 +04001006 booleanParam(name: 'RUN_CHILD_CFM_NETPOLICY', value: triggers.runChildConformanceNetworkPolicyEnabled),
vryzhenkinb286bd82023-04-04 07:17:52 +04001007 booleanParam(name: 'RUN_CHILD_HPA', value: triggers.runChildHPAEnabled),
Sergey Lalov012496a2023-11-27 15:57:52 +04001008 booleanParam(name: 'RUN_STACKLIGHT_CHILD_HA', value: triggers.runChildStacklightHaEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +04001009 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +02001010 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +02001011 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +01001012 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +04001013 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +02001014 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +02001015 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Sergey Zhemerdeev9074f6e2022-06-07 12:03:16 +03001016 booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled),
Sergey Lalovbc68d752022-11-08 13:40:53 +04001017 booleanParam(name: 'PAUSE_FOR_DEBUG', value: triggers.pauseForDebugEnabled),
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +03001018 booleanParam(name: 'ENABLE_FIPS', value: triggers.enableFips),
Sergey Lalov00bea0f2023-08-14 16:46:33 +04001019 booleanParam(name: 'ENABLE_MKE_DUBUG', value: triggers.enableMkeDebugEnabled),
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +03001020 booleanParam(name: 'AIO_CLUSTER', value: triggers.aioCluster),
Sergey Lalovd0e20852023-08-17 19:11:19 +04001021 booleanParam(name: 'BM_CORE_CLEANUP', value: triggers.bmCoreCleanup),
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001022 ]
Владислав Наумов92288d92020-07-13 18:36:21 +02001023
Владислав Наумов765f3bd2020-09-07 18:09:24 +02001024 // customize multiregional demo
1025 if (triggers.multiregionalConfiguration.enabled) {
1026 parameters.add(string(name: 'MULTIREGION_SETUP',
1027 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
1028 ))
1029 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001030
Владислав Наумов92288d92020-07-13 18:36:21 +02001031 // Determine component team custom context
1032 if (coreContext != '') {
1033 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
1034 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +02001035 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +02001036 }
1037
Владислав Наумовaa430612020-06-08 17:18:31 +02001038 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +04001039
1040 platforms.each { platform ->
1041 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +00001042 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +04001043 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
1044 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
1045 def build_description = job_info.getDescription()
1046 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +00001047 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +02001048
Vladislav Naumov5313a202021-04-07 17:13:39 +00001049 if (build_description) {
1050 currentBuild.description += build_description
1051 }
1052 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +04001053 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +00001054 }
1055 }
1056 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001057
1058 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +04001059 if (jobs.size() == 0) {
1060 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
1061 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001062 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
1063 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +02001064
1065 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +02001066 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +02001067 currentBuild.result = 'FAILURE'
1068 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001069}
Владислав Наумов30a516c2020-07-09 13:15:41 +02001070
1071
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001072/**
1073 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +02001074 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001075 *
1076 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
1077 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
1078 * @param: multiregionalConfiguration (map) Multiregional configuration
1079 * @return (map) Return aggregated map with lockResources and netMap
1080 */
1081
1082
1083def generateLockResources(callBackDemo, triggers) {
1084 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +02001085 def netMap = [
1086 vsphere: [:],
1087 equinix: [:],
1088 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001089 // Define vsphere locklabels with initial quantity
1090 def lockLabels = [
1091 vsphere_networking_core_ci: 0,
1092 vsphere_offline_networking_core_ci: 0,
1093 ]
1094 def deployChild = triggers.deployChildEnabled
Sergey Lalov13eea422023-08-21 23:10:17 +04001095 def testUiVsphere = triggers.runUie2eEnabled || triggers.runUie2eNewEnabled
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001096 def multiregionConfig = triggers.multiregionalConfiguration
1097 def runMultiregion = multiregionConfig.enabled
1098
1099 // Generate vsphere netMap and lockLabels based on demo context
1100 switch (callBackDemo) {
1101 case 'aws':
1102 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
1103 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +04001104 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001105
1106 // Define netMap for Vsphere region
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +04001107 if (runMultiregion && multiregionConfig.managementLocation == 'aws') {
1108 if (multiregionConfig.regionLocation == 'vsphere') {
1109 if (deployChild) {
1110 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
1111 }
1112 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001113 }
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +04001114
1115 if (multiregionConfig.regionLocation == 'azure') {
1116 lockLabels['azure_core_ci_queue'] = 1
1117 if (deployChild) {
1118 lockLabels['azure_core_ci_queue'] += 1
1119 }
1120 }
1121 }
1122 if (triggers.azureOnAwsDemoEnabled) {
1123 lockLabels['azure_core_ci_queue'] = 1
1124 }
1125
1126 if (triggers.equinixOnAwsDemoEnabled) {
1127 lockLabels['equinix_core_ci_queue'] = 1
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001128 }
1129 break
1130 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +02001131 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
slalov27833272022-06-30 02:13:50 +04001132 if (deployChild || testUiVsphere) {
Владислав Наумов33e1e812021-08-17 17:09:25 +02001133 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001134 }
1135 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
1136 multiregionConfig.regionLocation == 'vsphere') {
1137 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +02001138 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001139 }
Владислав Наумов33e1e812021-08-17 17:09:25 +02001140 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001141 }
1142 break
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +04001143 case 'azure':
1144 lockLabels['azure_core_ci_queue'] = triggers.demoWeight
1145 if (runMultiregion && multiregionConfig.managementLocation == 'azure') {
1146 if (multiregionConfig.regionLocation == 'aws') {
1147 lockLabels['aws_core_ci_queue'] = 1
1148 if (deployChild) {
1149 lockLabels['aws_core_ci_queue'] += 1
1150 }
1151 }
1152
1153 if (multiregionConfig.regionLocation == 'equinix') {
1154 lockLabels['equinix_core_ci_queue'] = 1
1155 if (deployChild) {
1156 lockLabels['equinix_core_ci_queue'] +=1
1157 }
1158 }
1159 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001160 default:
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +04001161 error('Supposed to be called from aws, azure or vsphere demos only')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001162 }
1163
1164 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
1165 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +02001166 netMap['vsphere'].each { clusterType, netConfig ->
1167 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
1168 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
1169 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
1170
1171 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001172 lockLabels['vsphere_offline_networking_core_ci']++
1173 } else {
1174 lockLabels['vsphere_networking_core_ci']++
1175 }
1176 }
1177
1178 // generate lock metadata
1179 def lockResources = []
1180 lockLabels.each { label, quantity ->
1181 if (quantity > 0) {
1182 def res = [
1183 label: label,
1184 quantity: quantity,
1185 ]
1186 lockResources.add(res)
1187 }
1188 }
1189
1190 common.infoMsg("""Generated vsphere netMap: ${netMap}
1191 Generated lockResources: ${lockResources}""")
1192
1193 return [
1194 netMap: netMap,
1195 lockResources: lockResources,
1196 ]
1197}
1198
1199/**
1200 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
1201 * and empty rangeConfig to the this map.
1202 *
Владислав Наумов33e1e812021-08-17 17:09:25 +02001203 * @param: netMap (string) vsphere, equinix netMap or empty map
1204 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001205 * @param: clusterType (string) Vsphere cluster type
1206 */
1207
Владислав Наумов33e1e812021-08-17 17:09:25 +02001208def addToProviderNetMap (netMap, provider, clusterType) {
1209 switch (provider) {
1210 case 'equinix':
1211 netMap[provider][clusterType] = [
1212 vlanConfig: '',
1213 ]
1214 break
1215 case 'vsphere':
1216 netMap[provider][clusterType] = [
1217 netName: 'default',
1218 rangeConfig: '',
1219 ]
1220 break
1221 default:
1222 error('Net map locks supported for Equinix/Vsphere providers only')
1223 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001224}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +03001225
1226/**
1227* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
1228* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
1229* If keyword contains only 'key' part then 'value' is boolean True.
1230* This function does not perform keywords validation.
1231* First line of a commit message is ignored.
1232* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
1233* TODO: Remove backslash chars from values if they prepend '[' or ']'.
1234**/
1235
1236List getCIKeywordsFromCommitMsg() {
1237 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
1238 List commitMsgLines = commitMsg.split('\n')
1239 List keywords = []
1240 if (commitMsgLines.size() < 2) {
1241 return keywords
1242 }
1243
1244 String commitMsgBody = commitMsgLines[1..-1].join('\n')
1245
1246 // Split commit message body to chunks using '[' or ']' as delimiter,
1247 // ignoring them if prepended by backslash (regex negative lookbehind).
1248 // Resulting list will have chunks between '[' and ']' at odd indexes.
1249 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
1250
1251 // Iterate chunks by odd indexes only, trim values and split to
1252 // <key> / <value> pair where <key> is the part of a sting before the first
1253 // whitespace delimiter, and <value> is the rest (may include whitespaces).
1254 // If there is no whitespace in the string then this is a 'switch'
1255 // and <value> will be boolean True.
1256 for (i = 1; i < parts.size(); i += 2) {
1257 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
1258 keywords.add(['key': key, 'value': value])
1259 }
1260
1261 return keywords
1262}
1263
1264/**
1265* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
1266* that were specified for given job name. `job-params` keyword has the following structure
1267*
1268* [job-params <job name> <parameter name> <parameter value>]
1269*
1270* Return value is a Map that contains those parameters using the following structure:
1271*
1272* <job name>:
1273* <parameter name>: <parameter value>
1274*
1275**/
1276Map getJobsParamsFromCommitMsg() {
1277 List keywords = getCIKeywordsFromCommitMsg()
1278
1279 List jobsParamsList = []
1280 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
1281 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
1282 def (key, value) = params.split(/\s+/, 2)
1283 ['name': name, 'key': key, 'value': value]
1284 }
1285
1286 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
1287 if (!result.containsKey(it.name)) {
1288 result[it.name] = [:]
1289 }
1290 result[it.name][it.key] = it.value
1291 result
1292 }
1293
1294 return jobsParams
1295}
1296
1297
1298/**
1299* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
1300* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
1301* uses only those parametes that were set to all jobs (with <job name> == '*') or to
1302* a particular job. Parameters set to a particular job have higher precedence.
1303*
1304* Return value is a Map that contains those parameters:
1305*
1306* <parameter name>: <parameter value>
1307*
1308**/
1309Map getJobParamsFromCommitMsg(String jobName) {
1310 jobsParams = getJobsParamsFromCommitMsg()
1311 jobParams = jobsParams.getOrDefault('*', [:])
1312 if (jobName) {
1313 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
1314 }
1315 return jobParams
1316}
azvyagintsevc17d14b2022-06-06 19:06:33 +03001317
1318/** Getting test scheme from text, which should be
1319Imput example:
1320text="""
1321 DATA
1322
1323 kaas_bm_test_schemas:
1324 KAAS_RELEASES_REFSPEC: ''
1325 KEY: VAL
1326
1327 DATA
1328 """
1329
1330 Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas'])
1331
1332 Return:
1333 ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL']
1334 **/
1335def parseTextForTestSchemas(Map opts) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001336 String text = opts.getOrDefault('text', '')
azvyagintsevc17d14b2022-06-06 19:06:33 +03001337 String keyLine = opts.getOrDefault('keyLine', '')
1338 Map testScheme = [:]
1339 if (!text || !keyLine) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001340 return testScheme
azvyagintsevc17d14b2022-06-06 19:06:33 +03001341 }
1342 if (text =~ /\n$keyLine\n.*/) {
1343 def common = new com.mirantis.mk.Common()
1344 try {
1345 String regExp = '\\n' + keyLine + '\\n'
1346 // regexep block must be followed by empty line
1347 testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}"
1348 common.infoMsg("parseTextForTestSchemas result:\n" + testScheme)
1349 common.mergeEnv(env, toJson(testScheme))
1350 }
1351 catch (Exception e) {
1352 common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}")
1353 throw e
1354 }
1355 }
azvyagintsevd96aac22022-06-10 14:23:26 +03001356 return testScheme
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +03001357}
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001358
1359
1360/**
eromanovab24cb232023-11-17 12:17:06 +04001361* getEquinixMetroWithCapacity returns list of Equinix metros using specified
1362* instance type (nodeType), desired count of metros (metroCount) and
1363* instances (nodeCount) in a metro using specified matal version.
1364* Function downloads metal CLI from the
1365* https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux
1366* Empty list is returned in case of no metros with specified capacity was found or any other errors.
1367* Non-empty list is shuffled.
1368*
1369* @param: metroCount (int) Desired count of metros
1370* @param: nodeCount (int) Desired count of instances
1371* @param: nodeType (string) Instance type
1372* @param: version (string) Metal version to use
1373* @return ([]string) List of selected metros
1374*
1375**/
1376def getEquinixMetroWithCapacity(metroCount = 1, nodeCount = 50, nodeType = 'c3.small.x86', version = '0.9.0') {
1377 def common = new com.mirantis.mk.Common()
1378 def metalUrl = "https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux"
1379 def metal = './metal --config metal.yaml'
1380 def metro = []
1381 def out = ''
1382 def retries = 3 // number of retries
1383 def i = 0
1384 def delay = 60 // 1 minute sleep
1385 def excludeMetro = [] // list of metros to exclude from selection
1386 try {
1387 if (excludeMetro.size() > 0) {
1388 common.infoMsg("Excluded metros: ${excludeMetros}")
1389 }
1390 sh "curl -o metal -# ${metalUrl} && chmod +x metal"
1391 withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) {
1392 sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml'
1393 }
1394 while (metro.size() < metroCount && i < retries) {
1395 common.infoMsg("Selecting ${metroCount} available Equinix metros with free ${nodeCount} ${nodeType} hosts, try ${i+1}/${retries} ...")
1396 if (i > 0) { // skip sleep on first step
1397 sleep(delay)
1398 }
1399 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()
1400 metro = out.tokenize(',')
1401 metro -= excludeMetro
1402 if (metro.size() < metroCount) {
1403 nodeCount -= 10
1404 // We need different metros for the [equinixmetalv2-child-diff-metro] case
1405 } else if (metro.size() == 2 && metro[0][0, 1] == metro[1][0, 1]) {
1406 nodeCount -= 10
1407 }
1408 i++
1409 }
1410 if (metro.size() > 0) {
eromanovaefbbb422023-11-24 13:54:35 +04001411 m = metro.size() > 1 ? "${metro[0]},${metro[1]}" : "${metro[0]}"
1412 sh "${metal} capacity check -P ${nodeType} -m ${m} -q ${nodeCount}"
eromanovab24cb232023-11-17 12:17:06 +04001413 }
1414 } catch (Exception e) {
1415 common.errorMsg "Exception: '${e}'"
1416 return []
1417 } finally {
1418 sh 'rm metal.yaml'
1419 }
1420 if (metro.size() > 0) {
1421 Collections.shuffle(metro)
1422 common.infoMsg("Selected metros: ${metro}")
1423 } else {
1424 common.warningMsg('No any metros have been selected !!! :(')
1425 }
1426 return metro
1427}
1428
1429
1430/**
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001431* getEquinixFacilityWithCapacity returns list of Equinix facilities using specified
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001432* instance type (nodeType), desired count of facilities (facilityCount) and
1433* instances (nodeCount) in a facility using specified matal version.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001434* Function downloads metal CLI from the
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001435* https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux
1436* 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 +03001437* Non-empty list is shuffled.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001438*
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001439* @param: facilityCount (int) Desired count of facilities
1440* @param: nodeCount (int) Desired count of instances
1441* @param: nodeType (string) Instance type
1442* @param: version (string) Metal version to use
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001443* @return ([]string) List of selected facilities
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001444*
1445**/
eromanovab24cb232023-11-17 12:17:06 +04001446@Deprecated
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001447def getEquinixFacilityWithCapacity(facilityCount = 1, nodeCount = 50, nodeType = 'c3.small.x86', version = '0.9.0') {
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001448 def common = new com.mirantis.mk.Common()
Sergey Lalov314daae2023-11-27 12:21:20 +04001449 common.warningMsg('You are using deprecated method getEquinixFacilityWithCapacity. Use getEquinixMetroWithCapacity instead')
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001450 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 +03001451 def metal = './metal --config metal.yaml'
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001452 def facility = []
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001453 def out = ''
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001454 def retries = 3 // number of retries
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001455 def i = 0
1456 def delay = 60 // 1 minute sleep
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001457 def excludeFacility = [] // list of facilities to exclude from selection
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001458 try {
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001459 if (excludeFacility.size() > 0) {
1460 common.infoMsg("Excluded facilities: ${excludeFacility}")
1461 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001462 sh "curl -o metal -# ${metalUrl} && chmod +x metal"
1463 withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) {
1464 sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml'
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001465 }
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001466 while (facility.size() < facilityCount && i < retries) {
1467 common.infoMsg("Selecting ${facilityCount} available Equinix facilities with free ${nodeCount} ${nodeType} hosts, try ${i+1}/${retries} ...")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001468 if (i > 0 ) { // skip sleep on first step
1469 sleep(delay)
1470 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001471 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()
1472 facility = out.tokenize(',')
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001473 facility -= excludeFacility
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001474 if (facility.size() < facilityCount) {
1475 nodeCount -= 10
1476 // We need different metros for the [equinixmetalv2-child-diff-metro] case, facility[][0, 1] contains a metro name
1477 } else if (facility.size() == 2 && facility[0][0, 1] == facility[1][0, 1]) {
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001478 nodeCount -= 10
1479 }
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001480 i++
1481 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001482 if (facility.size() > 0) {
1483 f = facility.size() > 1 ? "${facility[0]},${facility[1]}" : "${facility[0]}"
1484 sh "${metal} capacity check -P ${nodeType} -f ${f} -q ${nodeCount}"
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001485 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001486 } catch (Exception e) {
1487 common.errorMsg "Exception: '${e}'"
1488 return []
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001489 } finally {
1490 sh 'rm metal.yaml'
1491 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001492 if (facility.size() > 0) {
Sergey Zhemerdeev15aa8602022-10-13 11:10:02 +03001493 Collections.shuffle(facility)
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001494 common.infoMsg("Selected facilities: ${facility}")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001495 } else {
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001496 common.warningMsg('No any facilities have been selected !!! :(')
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001497 }
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001498 return facility
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001499}
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001500
1501
1502/**
1503 * genCommandLine prepares command line for artifactory-replication
1504 * command using legacy environment variables
1505 *
1506 * @return: (string) Prepared command line
1507 */
1508def genCommandLine() {
1509 def envToParam = [
1510 'DESTINATION_USER': '-dst-user',
1511 'ARTIFACT_FILTER': '-artifact-filter',
1512 'ARTIFACT_FILTER_PROD': '-artifact-filter-prod',
1513 'ARTIFACT_TYPE': '-artifact-type',
1514 'BINARY_CLEAN': '-bin-cleanup',
1515 'BINARY_CLEAN_KEEP_DAYS': '-bin-clean-keep-days',
1516 'BINARY_CLEAN_PREFIX': '-bin-clean-prefix',
1517 'BUILD_URL': '-slack-build-url',
1518 'CHECK_REPOS': '-check-repos',
1519 'DESTINATION_REGISTRY': '-dst-repo',
1520 'DESTINATION_REGISTRY_TYPE': '-dst-repo-type',
1521 'DOCKER_CLEAN': '-cleanup',
1522 'DOCKER_REPO_PREFIX': '-docker-repo-prefix',
1523 'DOCKER_TAG': '-docker-tag',
1524 'FORCE': '-force',
1525 'HELM_CDN_DOMAIN': '-helm-cdn-domain',
1526 'SLACK_CHANNEL': '-slack-channel',
1527 'SLACK_USER': '-slack-user',
1528 'SOURCE_REGISTRY': '-src-repo',
1529 'SOURCE_REGISTRY_TYPE': '-src-repo-type',
1530 'SYNC_PATTERN': '-sync-pattern'
1531 ]
1532 def cmdParams = ''
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001533 def isCheckClean = false
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001534 for (e in envToParam) {
1535 if (env[e.key] == null) {
1536 continue
1537 }
1538 if (e.key == 'CHECK_REPOS' || e.key == 'DOCKER_CLEAN') {
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001539 // Avoid CHECK_REPOS=true and DOCKER_CLEAN=true
1540 if (env[e.key].toBoolean() && !isCheckClean) {
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001541 cmdParams += e.value + ' '
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001542 isCheckClean = true
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001543 }
1544 } else if (e.key == 'FORCE') {
1545 if (env[e.key].toBoolean()) {
1546 cmdParams += e.value + ' '
1547 }
1548 } else {
Sergey Zhemerdeeve2926cd2022-08-29 15:28:47 +03001549 cmdParams += "${e.value} '${env[e.key]}' "
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001550 }
1551 }
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001552 // No any check or clean was specified - take a default action
1553 if (!isCheckClean) {
1554 cmdParams += '-replicate'
1555 }
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001556 return cmdParams
1557}
Sergey Kolekonov0e60a942022-09-05 13:02:22 +04001558
1559/**
1560 * custom scheduling algorithm
1561 * it ensures that builds of the same job are distributed as much as possible between different nodes
1562 * @param label (string) desired node label
1563 * @return: (string) node name
1564 */
1565def schedule (label='docker') {
1566 def common = new com.mirantis.mk.Common()
1567 def freeNodes = []
1568 def nodesMap = [:]
1569
1570 // filter nodes with the specified label and at least one free executor
1571 timeout(time: 30, unit: 'MINUTES') {
1572 while (!freeNodes) {
1573 freeNodes = jenkins.model.Jenkins.instance.computers.findAll { node ->
1574 label in node.getAssignedLabels().collect { it.name } &&
Sergey Kolekonovd5887172022-11-10 12:13:22 +06001575 node.isPartiallyIdle() &&
1576 node.isOnline()
Sergey Kolekonov0e60a942022-09-05 13:02:22 +04001577 }
1578 if (!freeNodes) {
1579 echo 'No nodes available for scheduling, retrying...'
1580 sleep 30
1581 }
1582 }
1583 }
1584
1585 // generate a map of nodes matching other criteria
1586 for (node in freeNodes) {
1587 // sameJobExecutors is the number of executors running the same job as the calling one
1588 sameJobExecutors = node.getExecutors() // get all executors
1589 .collect { executor -> executor.getCurrentExecutable() } // get running "threads"
1590 .collect { thread -> thread?.displayName } // filter job names from threads
1591 .minus(null) // null = empty executors, remove them from the list
1592 .findAll { it.contains(env.JOB_NAME) } // filter the same jobs as the calling one
1593 .size()
1594
1595 // calculate busy executors, we don't want to count "sameJobExecutors" twice
1596 totalBusyExecutors = node.countBusy() - sameJobExecutors
1597 // generate the final map which contains nodes matching criteria with their load score
1598 // builds of the same jobs have x10 score, all others x1
1599 nodesMap += ["${node.getName()}" : sameJobExecutors * 10 + totalBusyExecutors]
1600 }
1601
1602 // return the least loaded node
1603 return common.SortMapByValueAsc(nodesMap).collect { it.key }[0]
1604}
Sergey Zhemerdeev78a65272023-03-23 18:05:22 +02001605
1606
1607/**
1608 * Get latest tag for test/frontend & equinix-private-infra images
1609 * @param version (str) default tag value from main workflow
1610 * @param isChanged (bool) is dependent directory files were changed
1611 * @param imageName (string) image name for information message
1612 * @return: (string) tag name
1613 */
1614def getImageTag(version, isChanged, imageName) {
1615 def common = new com.mirantis.mk.Common()
Sergey Zhemerdeev5fbf2022023-04-28 14:51:36 +03001616 def latestTag = ''
1617 if (env.GERRIT_EVENT_TYPE && !(env.GERRIT_EVENT_TYPE in ['change-merged', 'ref-updated']) && isChanged) {
Sergey Zhemerdeev78a65272023-03-23 18:05:22 +02001618 latestTag = version
Sergey Zhemerdeevebdcad22023-04-25 16:58:28 +03001619 } else {
1620 if (env.GERRIT_EVENT_TYPE == 'ref-updated') {
1621 latestTag = env.GERRIT_REFNAME.replace('refs/tags/v', '').trim()
1622 } else {
1623 latestTag = env.GERRIT_BRANCH ? env.GERRIT_BRANCH : env.GERRIT_REFSPEC ? env.GERRIT_REFSPEC : 'master'
1624 if (latestTag != 'master') {
1625 latestTag = latestTag.replaceAll('/', '_')
1626 }
1627 }
Sergey Zhemerdeev78a65272023-03-23 18:05:22 +02001628 }
1629 common.infoMsg("${imageName} image will use tag '${latestTag}'")
1630 return latestTag
1631}
Sergey Zhemerdeev1d2c03e2023-04-28 11:07:24 +03001632
1633
1634/**
1635 * Translates set of environment vars into actual replicator command line
1636 * @return: (string cmdParams, string jobDescription)
1637 * cmdParams - generated command line
1638 * jobDescription - job description
1639 */
1640def genReplicatorCommandLine() {
1641 def mainModes = ['REPLICATE', 'CLEANUP', 'CHECK_REPOS', 'BIN_CLEANUP']
Sergey Zhemerdeev9919b1b2023-04-28 17:24:21 +03001642 def parameterWithoutArgument = mainModes
Sergey Zhemerdeev1d2c03e2023-04-28 11:07:24 +03001643 def parametersList = parameterWithoutArgument + [
1644 'ARTIFACT_FILTER',
1645 'ARTIFACT_TYPE',
1646 'BIN_CLEAN_KEEP_DAYS',
1647 'BIN_CLEAN_PREFIX',
1648 'DOCKER_TAG',
1649 // DST_ will be changed to TARGET_
1650 'DST_REPO',
1651 'DST_REPO_TYPE',
1652 'DST_USER',
1653 'OLDER_THAN_DAYS',
1654 'SLACK_BUILD_URL',
1655 'SLACK_CHANNEL',
1656 'SLACK_USER',
1657 'SRC_REPO',
1658 'SRC_REPO_TYPE',
1659 'SRC_USER',
1660 'SYNC_PATTERN',
1661 'THREAD_COUNT'
1662 ]
1663 def mainModesDescriptions = [
1664 'REPLICATE': 'Replicating binaries/Docker images',
1665 'CLEANUP': 'Cleaning Docker images',
1666 'BIN_CLEANUP': 'Cleaning binaries',
1667 'CHECK_REPOS': 'Checking binaries'
1668 ]
1669
1670 def cmdParams = ''
1671 def jobDescription = ''
1672 for (e in parametersList) {
1673 if (env[e] == null || env[e] == '') {
1674 continue
1675 }
1676 if (e in mainModes) {
1677 jobDescription = mainModesDescriptions[e]
1678 }
1679 cmdParams += "-${e.replaceAll('_', '-').toLowerCase()} "
1680 if (!(e in parameterWithoutArgument)) {
1681 cmdParams += "'${env[e]}' "
1682 }
1683 }
1684 return [cmdParams, jobDescription]
1685}