blob: f693c27774fab1268254a1f244ad919016b0b732 [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 Lalovafcc0432023-04-13 14:59:06 +040077 def runChildConformanceNetworkPolicy = env.RUN_CHILD_CFM_NETWORK_POLICY ? env.RUN_CHILD_CFM_NETWORK_POLICY.toBoolean() : false
vryzhenkinb286bd82023-04-04 07:17:52 +040078 def runChildHPA = env.RUN_CHILD_HPA ? env.RUN_CHILD_HPA.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020079 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Vladislav Naumov42b71dc2021-11-22 13:09:42 +010080 def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
slalov13e579c2022-01-31 21:37:02 +040081 def runMaintenanceTest = env.RUN_MAINTENANCE_TEST ? env.RUN_MAINTENANCE_TEST.toBoolean() : false
slalov0a4947a2022-06-09 15:44:35 +040082 def runContainerregistryTest = env.RUN_CONTAINER_REGISTRY_TEST ? env.RUN_CONTAINER_REGISTRY_TEST.toBoolean() : false
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +030083 def runMgmtDeleteMasterTest = env.RUN_MGMT_DELETE_MASTER_TEST ? env.RUN_MGMT_DELETE_MASTER_TEST.toBoolean() : false
84 def runRgnlDeleteMasterTest = env.RUN_RGNL_DELETE_MASTER_TEST ? env.RUN_RGNL_DELETE_MASTER_TEST.toBoolean() : false
85 def runChildDeleteMasterTest = env.RUN_CHILD_DELETE_MASTER_TEST ? env.RUN_CHILD_DELETE_MASTER_TEST.toBoolean() : false
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +030086 def runGracefulRebootTest = env.RUN_GRACEFUL_REBOOT_TEST ? env.RUN_GRACEFUL_REBOOT_TEST.toBoolean() : false
Sergey Lalovbc68d752022-11-08 13:40:53 +040087 def pauseForDebug = env.PAUSE_FOR_DEBUG ? env.PAUSE_FOR_DEBUG.toBoolean() : false
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +030088 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 +040089 def runChildCustomCertTest = env.RUN_CHILD_CUSTOM_CERT_TEST ? env.RUN_CHILD_CUSTOM_CERT_TEST.toBoolean() : false
Sergey Lalov430fcd72023-03-20 17:19:44 +040090 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 +040091 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 +040092 def runMkeCustomCertTest = env.RUN_MKE_CUSTOM_CERT_TEST ? env.RUN_MKE_CUSTOM_CERT_TEST.toBoolean() : false
Sergey Lalov62c28312023-10-18 19:23:59 +040093 def runCustomHostnames = env.RUN_CUSTOM_HOSTNAMES ? env.RUN_CUSTOM_HOSTNAMES.toBoolean() : false
vryzhenkin504dfc92023-11-01 15:49:47 +040094 def slLatest = env.SL_LATEST ? env.SL_LATEST.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020095 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
96 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
97 enabled: false,
98 managementLocation: '',
99 regionLocation: '',
100 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200101
Владислав Наумовb8305e22021-02-10 17:23:12 +0100102 // proxy customization
103 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200104 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
105 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +0200106 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +0100107 ]
108
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200109 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +0200110 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +0200111 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +0200112 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +0200113 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +0200114 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200115 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400116 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200117 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +0300118 def enableBMDemo = true
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400119 def enableArtifactsBuild = true
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400120 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300121 def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500122 def enableVsphereRHEL = env.VSPHERE_DEPLOY_RHEL ? env.VSPHERE_DEPLOY_RHEL.toBoolean() : false
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300123 def childOsBootFromVolume = env.OPENSTACK_BOOT_FROM_VOLUME ? env.OPENSTACK_BOOT_FROM_VOLUME.toBoolean() : false
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400124 def bootstrapV2Scenario = env.BOOTSTRAP_V2_ENABLED ? env.BOOTSTRAP_V2_ENABLED.toBoolean() : false
Sergey Lalovacec3c12022-07-20 16:00:14 +0400125 def equinixMetalV2Metro = env.EQUINIX_MGMT_METRO ? env.EQUINIX_MGMT_METRO : ''
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400126 def enableFips = env.ENABLE_FIPS ? env.ENABLE_FIPS.toBoolean() : false
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400127 def enableMkeDebug = env.ENABLE_MKE_DEBUG ? env.ENABLE_MKE_DEBUG.toBoolean() : false
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300128 def aioCluster = env.AIO_CLUSTER ? env.AIO_CLUSTER.toBoolean() : false
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100129 def useVsphereVvmtObjects = env.VSPHERE_USE_VVMT_OBJECTS ? env.VSPHERE_USE_VVMT_OBJECTS.toBoolean() : false
vryzhenkin4fd3f242023-03-29 15:13:46 +0400130 def enableBv2Smoke = true
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400131 def runCacheWarmup = env.CACHE_WARMUP_ENABLED ? env.CACHE_WARMUP_ENABLED.toBoolean() : false
vnaumov33747e12020-05-04 17:35:20 +0200132
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200133 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +0100134 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
135 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200136 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 +0100137 }
Sergey Kolekonov5995dfd2023-07-06 16:09:43 +0600138 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
139 upgradeMgmt = true
140 }
141 if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) {
142 autoUpgradeMgmt = true
143 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100144 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
145 seedMacOs = true
146 }
Sergey Lalovafcc0432023-04-13 14:59:06 +0400147 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ ||
148 upgradeChild || runChildConformance || runProxyChildTest || runChildHPA || runChildConformanceNetworkPolicy) {
vnaumov33747e12020-05-04 17:35:20 +0200149 deployChild = true
150 }
151 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
152 deployChild = true
153 upgradeChild = true
154 }
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400155 if (commitMsg ==~ /(?s).*\[child-upgrade-full\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade-full.*/) {
156 deployChild = true
157 upgradeChild = true
Sergey Lalova048df92023-06-19 19:36:41 +0400158 common.warningMsg("2-step child updates are not testing (PRODX-33510)")
159 //TODO: revert after start testing the two-step upgrade again (PRODX-33510)
160 //fullUpgradeChild = true
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400161 }
Sergey Kolekonov5995dfd2023-07-06 16:09:43 +0600162 if ((upgradeMgmt || autoUpgradeMgmt) && deployChild) {
163 upgradeChild = true
164 common.warningMsg('child upgrade is automatically enabled as mgmt upgrade and child deploy are enabled')
165 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400166 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
167 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400168 // override child version when it set explicitly
169 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400170 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400171 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
172 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400173 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
174 mosDeployChild = true
175 }
176 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
177 mosDeployChild = true
178 mosUpgradeChild = true
179 }
Sergey Kolekonov5995dfd2023-07-06 16:09:43 +0600180 if ((upgradeMgmt || autoUpgradeMgmt) && mosDeployChild) {
181 mosUpgradeChild = true
182 common.warningMsg('MOSK child upgrade is automatically enabled as mgmt upgrade and MOSK child deploy are enabled')
183 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100184 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
185 attachBYO = true
186 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100187 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
188 attachBYO = true
189 upgradeBYO = true
190 }
Sergey Lalovacec3c12022-07-20 16:00:14 +0400191 if (commitMsg ==~ /(?s).*\[ui-test-on-all-providers\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-test-on-all-providers.*/) {
192 enableVsphereDemo = true
193 enableOSDemo = true
194 awsOnDemandDemo = true
195 azureOnDemandDemo = true
196 equinixOnDemandDemo = true
197 equinixMetalV2OnDemandDemo = true
198 runUie2e = true
Sergey Lalovacec3c12022-07-20 16:00:14 +0400199 // Edit after fix PRODX-3961
200 enableBMDemo = false
201 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400202 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
203 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 +0100204 runBYOMatrix = true
205
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400206 if (byoDeployMatches.size() > 0) {
207 defaultBYOOs = byoDeployMatches[0][2]
208 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
209 }
210
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100211 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
212 attachBYO = false
213 upgradeBYO = false
214 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400215 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
216 enableLMALogging = true
217 }
Sergey Lalovb2f60372022-09-20 23:58:47 +0400218 if (commitMsg ==~ /(?s).*\[deploy-os-on-mos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*deploy-os-on-mos.*/) {
219 deployOsOnMos = true
220 mosDeployChild = true
221 openstackIMC = 'eu2'
222 }
Sergey Lalov95040602023-03-07 16:42:16 +0400223 if (commitMsg ==~ /(?s).*\[ui-e2e-nw\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-nw.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200224 runUie2e = true
225 }
Sergey Lalov95040602023-03-07 16:42:16 +0400226 if (commitMsg ==~ /(?s).*\[ui-e2e-pw\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-pw.*/) {
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400227 runUie2eNew = true
228 }
vnaumov33747e12020-05-04 17:35:20 +0200229 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
230 runMgmtConformance = true
231 }
Sergey Lalovafcc0432023-04-13 14:59:06 +0400232 if (commitMsg ==~ /(?s).*\[mgmt-cfm-netpolicy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm-netpolicy.*/) {
233 runMgmtConformanceNetworkPolicy = true
234 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200235 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
236 runMgmtUserControllerTest = true
237 }
slalov574123e2022-04-06 17:24:19 +0400238 if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) {
239 runProxyChildTest = true
240 deployChild = true
241 common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed')
242 }
vnaumov33747e12020-05-04 17:35:20 +0200243 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
244 runChildConformance = true
245 deployChild = true
246 }
Sergey Lalovafcc0432023-04-13 14:59:06 +0400247 if (commitMsg ==~ /(?s).*\[child-cfm-netpolicy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm-netpolicy.*/) {
248 runChildConformanceNetworkPolicy = true
249 deployChild = true
250 }
vryzhenkinb286bd82023-04-04 07:17:52 +0400251 if (commitMsg ==~ /(?s).*\[child-hpa\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-hpa.*/) {
252 runChildHPA = true
253 deployChild = true
254 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200255 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
256 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400257 enableLMALogging = true
258 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400259 }
slalov13e579c2022-01-31 21:37:02 +0400260 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
261 runMaintenanceTest = true
262 }
slalov0a4947a2022-06-09 15:44:35 +0400263 if (commitMsg ==~ /(?s).*\[container-registry-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*container-registry-test.*/) {
264 runContainerregistryTest = true
265 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300266 if (commitMsg ==~ /(?s).*\[mgmt-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-delete-master-test.*/) {
267 runMgmtDeleteMasterTest = true
268 }
269 if (commitMsg ==~ /(?s).*\[rgnl-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*rgnl-delete-master-test.*/) {
270 runRgnlDeleteMasterTest = true
271 }
272 if (commitMsg ==~ /(?s).*\[child-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-delete-master-test.*/) {
Sergey Lalov47e21592023-07-18 23:36:32 +0400273 if (!mosDeployChild) {
274 deployChild = true
275 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300276 runChildDeleteMasterTest = true
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300277 common.infoMsg('Child cluster deployment will be enabled since delete child master node test suite will be executed')
278 }
279 if (commitMsg ==~ /(?s).*\[child-machine-deletion-policy-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-machine-deletion-policy-test.*/) {
280 runChildMachineDeletionPolicyTest = true
281 deployChild = true
282 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 +0300283 }
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300284 if (commitMsg ==~ /(?s).*\[graceful-reboot-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*graceful-reboot-test.*/) {
285 runGracefulRebootTest = true
286 }
Sergey Lalovbc68d752022-11-08 13:40:53 +0400287 if (commitMsg ==~ /(?s).*\[pause-for-debug\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*pause-for-debug.*/) {
288 pauseForDebug = true
289 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200290 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
291 proxyConfig['childOffline'] = true
292 deployChild = true
293 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200294 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
295 proxyConfig['childOffline'] = true
296 proxyConfig['childProxy'] = true
297 deployChild = true
298 }
vnaumov33747e12020-05-04 17:35:20 +0200299 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
300 fetchServiceBinaries = true
301 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200302 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400303 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200304 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 +0400305 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200306 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
307 azureOnAwsDemo = true
308 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
309 }
310 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
311 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
312 attachBYO ||
313 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100314 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200315 seedMacOs ||
316 equinixOnAwsDemo ||
317 azureOnAwsDemo) {
318
vnaumov33747e12020-05-04 17:35:20 +0200319 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200320 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 +0200321 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200322 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200323 equinixOnDemandDemo = true
324 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200325 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200326 equinixMetalV2OnDemandDemo = true
327 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100328 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
329 equinixMetalV2OnDemandDemo = true
330 equinixMetalV2ChildDiffMetro = true
331 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200332 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
333 azureOnDemandDemo = true
334 }
Sergey Lalov10cb3502023-03-27 22:13:49 +0400335 if (commitMsg ==~ /(?s).*\[disable-all-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-all-demo\.*/) {
336 enableVsphereDemo = false
337 enableOSDemo = false
338 enableBMDemo = false
Sergey Lalov781fccc2023-10-12 21:55:17 +0400339 enableBv2Smoke = false
340 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 +0400341 }
342
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200343 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
344 enableOSDemo = false
345 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200346 }
347
azvyagintsev1761bdc2020-09-04 17:24:12 +0300348 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
349 enableBMDemo = false
350 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
351 }
352
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400353 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
354 enableVsphereDemo = false
355 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
356 }
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300357 if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) {
358 enableVsphereUbuntu = true
359 common.warningMsg('Ubuntu will be used to deploy vsphere machines')
360 }
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500361 if (commitMsg ==~ /(?s).*\[vsphere-rhel\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-rhel\.*/) {
362 enableVsphereRHEL = true
363 common.warningMsg('RHEL will be used to deploy vsphere machines')
364 }
vryzhenkin4fd3f242023-03-29 15:13:46 +0400365 if (commitMsg ==~ /(?s).*\[disable-bv2-smoke\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bv2-smoke\.*/) {
366 enableBv2Smoke = false
367 common.errorMsg('Bootstrap v2 smoke checks will be aborted, WF -1 will be set')
368 }
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400369
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400370 if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
371 enableArtifactsBuild = false
372 common.errorMsg('artifacts build will be aborted, VF -1 will be set')
373 }
374
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300375 if (commitMsg ==~ /(?s).*\[child-os-boot-from-volume\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-os-boot-from-volume\.*/) {
376 childOsBootFromVolume = true
377 common.warningMsg('OS will be booted from Ceph volumes')
378 }
379
Sergey Lalovd5efcd52023-03-01 22:42:17 +0400380 if (commitMsg ==~ /(?s).*\[child-custom-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-custom-cert-test\.*/) {
381 runChildCustomCertTest = true
382 deployChild = true
383 common.warningMsg('Child cluster deployment will be enabled since custom cert child test suite will be executed')
384 }
385
Sergey Lalovf6fbfea2023-04-06 17:05:40 +0400386 if (commitMsg ==~ /(?s).*\[mgmt-custom-cache-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-custom-cache-cert-test\.*/) {
387 runMgmtCustomCacheCertTest = true
388 deployChild = true
389 common.warningMsg('Child cluster deployment will be enabled as the test replaces the mgmt and cluster childcertificates')
390 }
391
Sergey Lalov48e69022023-07-25 16:08:00 +0400392 if (commitMsg ==~ /(?s).*\[mke-custom-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mke-custom-cert-test\.*/) {
393 runMkeCustomCertTest = true
394 }
395
Sergey Lalov62c28312023-10-18 19:23:59 +0400396 if (commitMsg ==~ /(?s).*\[custom-hostnames\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*custom-hostnames\.*/) {
397 runCustomHostnames = true
398 common.warningMsg('All clusters will be deployed with Custom Hostnames')
399 }
400
vryzhenkin504dfc92023-11-01 15:49:47 +0400401 if (commitMsg ==~ /(?s).*\[sl-latest\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*sl-latest\.*/) {
402 slLatest = true
403 common.warningMsg('All clusters will be deployed with Stacklight version from artifact-metadata')
404 }
405
Sergey Lalov430fcd72023-03-20 17:19:44 +0400406 if (commitMsg ==~ /(?s).*\[byo-child-custom-cert-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-child-custom-cert-test\.*/) {
407 runByoChildCustomCertTest = true
408 attachBYO = true
409 common.warningMsg('Byo child cluster deployment will be enabled since custom cert child test suite will be executed')
410 }
411
vnaumov33747e12020-05-04 17:35:20 +0200412 // TODO (vnaumov) remove below condition after moving all releases to UCP
413 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
414 if (ucpChildMatches.size() > 0) {
415 deployChild = true
416 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
417
418 // TODO(vnaumov) delete after ucp upgrades support
419 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
420 upgradeChild = false
421 }
422
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300423 if (commitMsg ==~ /(?s).*\[aio-cluster\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aio-cluster.*/) {
424 aioCluster = true
425 }
426
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400427 if (commitMsg ==~ /(?s).*\[cache-warmup\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*cache-warmup.*/) {
428 runCacheWarmup = true
429 }
430
431 if (runCacheWarmup && (!deployChild && !mosDeployChild)) {
432 runCacheWarmup = false
433 common.errorMsg('Child cluster deployment is not enabled, skipping Cache Warmup')
434 }
435
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200436 // multiregional tests
437 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
438 if (multiRegionalMatches.size() > 0) {
439 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
440 }
441 switch (multiregionalMappings['managementLocation']) {
442 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100443 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200444 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100445
446 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
447 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
448 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200449 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200450 case 'os':
451 if (enableOSDemo == false) {
452 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
453 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200454 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200455 case 'vsphere':
456 if (enableVsphereDemo == false) {
457 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
458 }
459 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200460 case 'equinix':
461 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
462 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400463 break
eromanova8c702ae2021-12-24 17:43:12 +0400464 case 'equinixmetalv2':
465 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
466 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400467 break
slalovfd0b7e62021-07-28 18:05:16 +0400468 case 'azure':
469 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
470 azureOnDemandDemo = true
471 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200472 }
473
Владислав Наумовb8305e22021-02-10 17:23:12 +0100474 // CDN configuration
475 def cdnConfig = [
476 mgmt: [
Sergey Lalovde909ea2023-05-31 20:21:02 +0400477 openstack: 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200478 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100479 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200480 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200481 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200482 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100483 ]
484
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400485 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
486 openstackIMC = 'eu'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400487 }
slalov021171f2022-03-04 14:48:38 +0400488 if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) {
489 openstackIMC = 'eu2'
Mikhail Ivanovf05b8252022-04-27 18:14:03 +0400490 }
491 if (openstackIMC == 'eu' || openstackIMC == 'eu2') {
slalov021171f2022-03-04 14:48:38 +0400492 // use internal-eu because on internal-ci with eu cloud image pull takes much time
Sergey Lalovde909ea2023-05-31 20:21:02 +0400493 def cdnRegion = 'internal-eu'
slalov021171f2022-03-04 14:48:38 +0400494 common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}")
495 cdnConfig['mgmt']['openstack'] = cdnRegion
496 }
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400497
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100498 // calculate weight of current demo run to manage lockable resources
Sergey Lalov46deb442022-08-18 12:11:03 +0400499 def demoWeight = deployChild ? 2 : 1 // management = 1, child += 1
Sergey Lalov95040602023-03-07 16:42:16 +0400500 if (runUie2e || runUie2eNew) {
Sergey Lalov46deb442022-08-18 12:11:03 +0400501 demoWeight += 1
502 }
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100503
Sergey Laloveb611b22023-09-22 16:59:09 +0400504 if (commitMsg ==~ /(?s).*\[bootstrapv1-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv1-scenario\.*/) {
505 bootstrapV2Scenario = false
506 }
507
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400508 if (commitMsg ==~ /(?s).*\[bootstrapv2-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv2-scenario\.*/) {
509 bootstrapV2Scenario = true
510 }
511
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400512 if (commitMsg ==~ /(?s).*\[enable-fips\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*enable-fips\.*/) {
513 enableFips = true
514 }
515
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400516 if (commitMsg ==~ /(?s).*\[enable-mke-debug\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*enable-mke-debug\.*/) {
517 enableMkeDebug = true
518 }
519
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100520 if (commitMsg ==~ /(?s).*\[vsphere-vvmt-obj\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-vvmt-obj\.*/) {
521 useVsphereVvmtObjects = true
522 }
523
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300524 // parse equinixmetalv2-metro trigger
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300525 def equinixMetalV2MetroMatcher = (commitMsg =~ /\[equinixmetalv2-metro(\s+.*)?\]/)
526 if (equinixMetalV2OnDemandDemo && equinixMetalV2MetroMatcher.size() > 0) {
Sergey Zhemerdeevcc785e42022-07-22 17:15:47 +0300527 equinixMetalV2Metro = equinixMetalV2MetroMatcher[0][1].trim().toLowerCase()
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300528 common.infoMsg("Forced Equnix mgmt deployment using custom metro ${equinixMetalV2Metro}")
529 }
530
vnaumov33747e12020-05-04 17:35:20 +0200531 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400532 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100533 CDN deployment configuration: ${cdnConfig}
534 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100535 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200536 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400537 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200538 Child cluster release upgrade scheduled: ${upgradeChild}
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400539 Full Child cluster release upgrade scheduled: ${fullUpgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400540 MOS child deploy scheduled: ${mosDeployChild}
541 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200542 Child conformance testing scheduled: ${runChildConformance}
Sergey Lalovafcc0432023-04-13 14:59:06 +0400543 Child conformance network policy testing scheduled: ${runChildConformanceNetworkPolicy}
vryzhenkinb286bd82023-04-04 07:17:52 +0400544 Child HPA testing scheduled: ${runChildHPA}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100545 Single BYO cluster attachment scheduled: ${attachBYO}
546 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
547 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400548 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200549 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
slalov1202bba2022-04-20 22:31:07 +0400550 Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400551 Mgmt LMA logging enabled: ${enableLMALogging}
Sergey Lalovb2f60372022-09-20 23:58:47 +0400552 Deploy Os on child with mos release ${deployOsOnMos}
vnaumov33747e12020-05-04 17:35:20 +0200553 Mgmt conformance testing scheduled: ${runMgmtConformance}
Sergey Lalovafcc0432023-04-13 14:59:06 +0400554 Mgmt conformance network policy testing scheduled: ${runMgmtConformanceNetworkPolicy}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200555 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200556 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200557 Mgmt UI e2e testing scheduled: ${runUie2e}
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400558 Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
slalov13e579c2022-01-31 21:37:02 +0400559 Maintenance test: ${runMaintenanceTest}
slalov0a4947a2022-06-09 15:44:35 +0400560 Container Registry test: ${runContainerregistryTest}
slalov574123e2022-04-06 17:24:19 +0400561 Child proxy test: ${runProxyChildTest}
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300562 Graceful reboot test: ${runGracefulRebootTest}
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300563 Delete mgmt master node test: ${runMgmtDeleteMasterTest}
564 Delete rgnl master node test: ${runRgnlDeleteMasterTest}
565 Delete child master node test: ${runChildDeleteMasterTest}
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300566 Child machine deletion policy test: ${runChildMachineDeletionPolicyTest}
Sergey Lalovd5efcd52023-03-01 22:42:17 +0400567 Custom cert test for child clusters: ${runChildCustomCertTest}
Sergey Lalov430fcd72023-03-20 17:19:44 +0400568 Custom cert test for Byo child clusters: ${runByoChildCustomCertTest}
Sergey Lalovf6fbfea2023-04-06 17:05:40 +0400569 Custom cache cert test for mgmt and child clusters: ${runMgmtCustomCacheCertTest}
Sergey Lalov48e69022023-07-25 16:08:00 +0400570 MKE custom cert test for mgmt/region: ${runMkeCustomCertTest}
Sergey Lalov62c28312023-10-18 19:23:59 +0400571 Custom hostnames for all clisuers: ${runCustomHostnames}
vryzhenkin504dfc92023-11-01 15:49:47 +0400572 Stacklight templates enchanced with latest version from artifact-metadata: ${slLatest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200573 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200574 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200575 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100576 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Sergey Zhemerdeev019c45a2022-08-13 00:09:07 +0300577 EquinixmetalV2 mgmt will be deployed on the metro: ${equinixMetalV2Metro?:'auto'}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200578 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200579 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200580 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400581 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200582 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300583 BM provider deployment scheduled: ${enableBMDemo}
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300584 Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500585 RHEL on vSphere scheduled: ${enableVsphereRHEL}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400586 Artifacts build scheduled: ${enableArtifactsBuild}
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300587 Boot OS child from Ceph volumes: ${childOsBootFromVolume}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200588 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200589 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100590 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400591 Bootstrap v2 scenario enabled: ${bootstrapV2Scenario}
Mikhail Ivanov3088d3d2022-10-24 14:05:46 +0400592 FIPS enabled: ${enableFips}
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400593 MKE DEBUG enabled: ${enableMkeDebug}
Sergey Lalovbc68d752022-11-08 13:40:53 +0400594 Pause for debug enabled: ${pauseForDebug}
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300595 AIO cluster: ${aioCluster}
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100596 Use Vsphere VVMT Objects: ${useVsphereVvmtObjects}
vryzhenkin4fd3f242023-03-29 15:13:46 +0400597 Bootsrap v2 smoke checks enabled: ${enableBv2Smoke}
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400598 Run Cache warmup for child clusters: ${runCacheWarmup}
Владислав Наумов81777472021-03-09 15:14:27 +0400599 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200600 return [
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300601 osCloudLocation : openstackIMC,
602 cdnConfig : cdnConfig,
603 proxyConfig : proxyConfig,
604 useMacOsSeedNode : seedMacOs,
605 deployChildEnabled : deployChild,
606 childDeployCustomRelease : customChildRelease,
607 upgradeChildEnabled : upgradeChild,
608 fullUpgradeChildEnabled : fullUpgradeChild,
609 mosDeployChildEnabled : mosDeployChild,
610 mosUpgradeChildEnabled : mosUpgradeChild,
611 runChildConformanceEnabled : runChildConformance,
Sergey Lalovafcc0432023-04-13 14:59:06 +0400612 runChildConformanceNetworkPolicyEnabled : runChildConformanceNetworkPolicy,
vryzhenkinb286bd82023-04-04 07:17:52 +0400613 runChildHPAEnabled : runChildHPA,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300614 attachBYOEnabled : attachBYO,
615 upgradeBYOEnabled : upgradeBYO,
616 runBYOMatrixEnabled : runBYOMatrix,
617 defaultBYOOs : defaultBYOOs,
618 upgradeMgmtEnabled : upgradeMgmt,
619 autoUpgradeMgmtEnabled : autoUpgradeMgmt,
620 enableLMALoggingEnabled : enableLMALogging,
621 deployOsOnMosEnabled : deployOsOnMos,
622 runUie2eEnabled : runUie2e,
623 runUie2eNewEnabled : runUie2eNew,
624 runMgmtConformanceEnabled : runMgmtConformance,
Sergey Lalovafcc0432023-04-13 14:59:06 +0400625 runMgmtConformanceNetworkPolicyEnabled : runMgmtConformanceNetworkPolicy,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300626 runMaintenanceTestEnabled : runMaintenanceTest,
627 runContainerregistryTestEnabled : runContainerregistryTest,
628 runGracefulRebootTestEnabled : runGracefulRebootTest,
629 pauseForDebugEnabled : pauseForDebug,
630 runMgmtDeleteMasterTestEnabled : runMgmtDeleteMasterTest,
631 runRgnlDeleteMasterTestEnabled : runRgnlDeleteMasterTest,
632 runChildDeleteMasterTestEnabled : runChildDeleteMasterTest,
Sergey Lalovd5efcd52023-03-01 22:42:17 +0400633 runChildCustomCertTestEnabled : runChildCustomCertTest,
Sergey Lalovf6fbfea2023-04-06 17:05:40 +0400634 runMgmtCustomCacheCertTestEnabled : runMgmtCustomCacheCertTest,
Sergey Lalov48e69022023-07-25 16:08:00 +0400635 runMkeCustomCertTestEnabled : runMkeCustomCertTest,
Sergey Lalov62c28312023-10-18 19:23:59 +0400636 runCustomHostnamesEnabled : runCustomHostnames,
vryzhenkin504dfc92023-11-01 15:49:47 +0400637 slLatestEnabled : slLatest,
Sergey Lalov430fcd72023-03-20 17:19:44 +0400638 runByoChildCustomCertTestEnabled : runByoChildCustomCertTest,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300639 runChildMachineDeletionPolicyTestEnabled : runChildMachineDeletionPolicyTest,
640 runLMATestEnabled : runLMATest,
641 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
642 runProxyChildTestEnabled : runProxyChildTest,
643 fetchServiceBinariesEnabled : fetchServiceBinaries,
644 awsOnDemandDemoEnabled : awsOnDemandDemo,
645 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
646 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
647 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
648 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
649 azureOnDemandDemoEnabled : azureOnDemandDemo,
650 azureOnAwsDemoEnabled : azureOnAwsDemo,
651 vsphereDemoEnabled : enableVsphereDemo,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300652 bmDemoEnabled : enableBMDemo,
653 osDemoEnabled : enableOSDemo,
654 vsphereUbuntuEnabled : enableVsphereUbuntu,
Ivan Berezovskiy30c4b122023-11-06 18:03:18 +0500655 vsphereRHELEnabled : enableVsphereRHEL,
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300656 artifactsBuildEnabled : enableArtifactsBuild,
657 childOsBootFromVolume : childOsBootFromVolume,
658 multiregionalConfiguration : multiregionalMappings,
659 demoWeight : demoWeight,
660 bootstrapV2Scenario : bootstrapV2Scenario,
661 equinixMetalV2Metro : equinixMetalV2Metro,
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300662 enableFips : enableFips,
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400663 enableMkeDebugEnabled : enableMkeDebug,
Mikhail Morgoev58855c12023-02-10 14:57:31 +0100664 aioCluster : aioCluster,
vryzhenkin4fd3f242023-03-29 15:13:46 +0400665 useVsphereVvmtObjects : useVsphereVvmtObjects,
Ivan Berezovskiy02baa982023-06-06 12:46:27 +0400666 bv2SmokeEnabled : enableBv2Smoke,
667 runCacheWarmup : runCacheWarmup,
668 ]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200669}
670
671/**
672 * Determine management and regional setup for demo workflow scenario
673 *
674 *
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300675 * @param: keyword (string) string , represents keyword trigger, specified in gerrit commit body, like `[multiregion aws,os]`
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200676 or Jenkins environment string variable in form like 'aws,os'
677 * @return (map)[
678 enabled: (bool),
679 * managementLocation: (string), //aws,os
680 * regionLocation: (string), //aws,os
681 * ]
682 */
683def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200684 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400685 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
686 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200687
688 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200689 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200690 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
691 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
692 } else {
693 common.infoMsg('Multiregion definition configured via environment variable')
694 clusterTypes = keyword.trim().split(',')
695 }
696
697 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100698 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200699 }
700
Владислав Наумовf793fe32020-09-11 15:19:19 +0200701 def desiredManagementProvider = clusterTypes[0].trim()
702 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200703 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
704 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200705 management providers list - ${supportedManagementProviders}
706 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200707 }
708
709 return [
710 enabled: true,
711 managementLocation: desiredManagementProvider,
712 regionLocation: desiredRegionalProvider,
713 ]
vnaumov33747e12020-05-04 17:35:20 +0200714}
715
716/**
717 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
718
Владислав Наумов81777472021-03-09 15:14:27 +0400719 * 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 +0200720 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
721 * Example scheme:
722 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
723 * manage refspecs through Jenkins Job Parameters
724 *
azvyagintseva12230a2020-06-05 13:24:06 +0300725 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200726 * siPipelines: (string) final refspec for si-pipelines
727 * ]
728 */
729def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200730 def common = new com.mirantis.mk.Common()
731
vnaumov33747e12020-05-04 17:35:20 +0200732 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200733 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
734 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200735 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
736 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200737 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200738
739 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
740 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
741
742 if (siTestMatches.size() > 0) {
743 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400744 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200745 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200746 }
747 if (siPipelinesMatches.size() > 0) {
748 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
749 }
750
751 common.infoMsg("""
752 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
753 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200754 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400755 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200756 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200757}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200758
Владислав Наумов9080f372020-06-08 13:57:16 +0200759/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200760 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200761 * @param configurationFile (str) path to configuration file in yaml format
762 *
763 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300764 * siTestsFeatureFlagsStable (string) dedicated feature flags that will be used in SI tests for deploying stable release
Владислав Наумов30a516c2020-07-09 13:15:41 +0200765 * ]
766 */
767def parseKaaSComponentCIParameters(configurationFile){
768 def common = new com.mirantis.mk.Common()
769 def ciConfig = readYaml file: configurationFile
770 def ciSpec = [
771 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300772 siTestsFeatureFlagsStable: env.SI_TESTS_FEATURE_FLAGS_STABLE ?: '',
Владислав Наумов30a516c2020-07-09 13:15:41 +0200773 ]
774
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300775 // If exists and not empty
776 if (ciConfig.getOrDefault('si-tests-feature-flags', [])) {
Владислав Наумов30a516c2020-07-09 13:15:41 +0200777 common.infoMsg("""SI tests feature flags customization detected,
778 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
779
780 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
781 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200782
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200783 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200784 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
785 }
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300786 if (ciConfig.getOrDefault('si-tests-feature-flags-stable', [])) {
787 common.infoMsg("""SI tests feature flags for stable release customization detected,
788 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlagsStable']}] identification...""")
789
790 def ffMeta = ciSpec['siTestsFeatureFlagsStable'].tokenize(',').collect { it.trim() }
791 ffMeta.addAll(ciConfig['si-tests-feature-flags-stable'])
792
793 ciSpec['siTestsFeatureFlagsStable'] = ffMeta.unique().join(',')
794 common.infoMsg("SI tests custom feature flags for stable release: ${ciSpec['siTestsFeatureFlagsStable']}")
795 }
Владислав Наумов30a516c2020-07-09 13:15:41 +0200796
797 common.infoMsg("""Additional ci configuration parsed successfully:
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300798 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}
799 siTestsFeatureFlagsStable: ${ciSpec['siTestsFeatureFlagsStable']}""")
Владислав Наумов30a516c2020-07-09 13:15:41 +0200800 return ciSpec
801}
802
803/**
804 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200805
Владислав Наумов81777472021-03-09 15:14:27 +0400806 * 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 +0200807 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
808 * Example scheme:
809 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
810 * manage refspecs through Jenkins Job Parameters
811 *
812 * @return (map)[ core: (string) final refspec for kaas/core
813 * corePipelines: (string) final refspec for pipelines in kaas/core
814 * ]
815 */
816def checkCustomCoreRefspec() {
817 def common = new com.mirantis.mk.Common()
818
819 // Available triggers and its sane defaults
820 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
821 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
822 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
823 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
824
825 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
826 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
827
828 if (coreMatches.size() > 0) {
829 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
830 }
831 if (corePipelinesMatches.size() > 0) {
832 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
833 }
834
835 common.infoMsg("""
836 kaas/core will be fetched from: ${coreRefspec}
837 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400838 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200839 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
840}
841
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200842
843/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200844 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
845 * needed to forward inside kaas core set of jobs
846 *
847 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
848 * @return (list)[ string(name: '', value: ''),
849 * ]
850 */
851def generateKaaSVarsFromContext(context) {
852 def common = new com.mirantis.mk.Common()
853 def parameters = []
854 def config = readYaml text: context
855
856 config.each { k,v ->
857 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
858 parameters.add(string(name: k, value: v))
859 }
860
861 return parameters
862}
863
864/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200865 * 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 +0400866 * 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 +0200867 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
868 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200869 * @param: component (string) component name [iam, lcm, stacklight]
870 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
871 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200872 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200873def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200874 def common = new com.mirantis.mk.Common()
875 // Determine if custom trigger keywords forwarded from gerrit
876 def triggers = checkDeploymentTestSuite()
877 // Determine SI refspecs
878 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200879 // Determine Core refspecs
880 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200881
Владислав Наумов418042b2020-07-09 18:31:10 +0200882 // Determine component repo ci configuration
883 def ciSpec = [:]
884 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
885 if (fileExists(configurationFile)) {
886 common.infoMsg('Component CI configuration file detected, parsing...')
887 ciSpec = parseKaaSComponentCIParameters(configurationFile)
888 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
889 } else {
890 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200891 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200892 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
893 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200894 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400895
896 def platforms = []
897 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
898 // Currently only vsphere demo is required for IPAM component
899 platforms.add('vsphere')
900 } else {
901 if (triggers.osDemoEnabled) {
902 platforms.add('openstack')
903 }
904 if (triggers.awsOnDemandDemoEnabled) {
905 platforms.add('aws')
906 }
907 if (triggers.equinixOnDemandDemoEnabled) {
908 platforms.add('equinix')
909 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200910 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
911 platforms.add('equinixmetalv2')
912 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200913 if (triggers.azureOnDemandDemoEnabled) {
914 platforms.add('azure')
915 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400916 if (triggers.vsphereDemoEnabled) {
917 platforms.add('vsphere')
918 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400919 }
920
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200921 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200922 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200923 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
924 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200925 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200926 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200927 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
928 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200929 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200930 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400931 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400932 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100933 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200934 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200935 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100936 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200937 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
slalov1202bba2022-04-20 22:31:07 +0400938 booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400939 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Sergey Lalovb2f60372022-09-20 23:58:47 +0400940 booleanParam(name: 'DEPLOY_OS_ON_MOS', value: triggers.deployOsOnMosEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200941 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200942 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
Sergey Lalovafcc0432023-04-13 14:59:06 +0400943 booleanParam(name: 'RUN_MGMT_CFM_NETWORK_POLICY', value: triggers.runMgmtConformanceNetworkPolicyEnabled),
slalov0a4947a2022-06-09 15:44:35 +0400944 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnabled),
945 booleanParam(name: 'RUN_CONTAINER_REGISTRY_TEST', value: triggers.runContainerregistryTestEnabled),
Mikhail Nikolaenko7e632cd2022-10-24 16:20:31 +0300946 booleanParam(name: 'RUN_GRACEFUL_REBOOT_TEST', value: triggers.runGracefulRebootTestEnabled),
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300947 booleanParam(name: 'RUN_MGMT_DELETE_MASTER_TEST', value: triggers.runMgmtDeleteMasterTestEnabled),
948 booleanParam(name: 'RUN_RGNL_DELETE_MASTER_TEST', value: triggers.runRgnlDeleteMasterTestEnabled),
949 booleanParam(name: 'RUN_CHILD_DELETE_MASTER_TEST', value: triggers.runChildDeleteMasterTestEnabled),
Sergey Lalovd5efcd52023-03-01 22:42:17 +0400950 booleanParam(name: 'RUN_CHILD_CUSTOM_CERT_TEST', value: triggers.runChildCustomCertTestEnabled),
Sergey Lalovf6fbfea2023-04-06 17:05:40 +0400951 booleanParam(name: 'RUN_MGMT_CUSTOM_CACHE_CERT_TEST', value: triggers.runMgmtCustomCacheCertTestEnabled),
Sergey Lalov48e69022023-07-25 16:08:00 +0400952 booleanParam(name: 'RUN_MKE_CUSTOM_CERT_TEST', value: triggers.runMkeCustomCertTestEnabled),
Sergey Lalov62c28312023-10-18 19:23:59 +0400953 booleanParam(name: 'RUN_CUSTOM_HOSTNAMES', value: triggers.runCustomHostnamesEnabled),
vryzhenkin504dfc92023-11-01 15:49:47 +0400954 booleanParam(name: 'SL_LATEST', value: triggers.slLatestEnabled),
Sergey Lalov430fcd72023-03-20 17:19:44 +0400955 booleanParam(name: 'RUN_BYO_CHILD_CUSTOM_CERT_TEST', value: triggers.runByoChildCustomCertTestEnabled),
Dmitriy Kasyanov43cb06e2022-08-17 14:35:39 +0300956 booleanParam(name: 'RUN_CHILD_MACHINE_DELETION_POLICY_TEST', value: triggers.runChildMachineDeletionPolicyTestEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200957 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200958 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200959 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
960 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400961 booleanParam(name: 'FULL_UPGRADE_CHILD_CLUSTER', value: triggers.fullUpgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +0400962 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100963 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100964 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100965 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200966 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Sergey Lalovafcc0432023-04-13 14:59:06 +0400967 booleanParam(name: 'RUN_CHILD_CFM_NETPOLICY', value: triggers.runChildConformanceNetworkPolicyEnabled),
vryzhenkinb286bd82023-04-04 07:17:52 +0400968 booleanParam(name: 'RUN_CHILD_HPA', value: triggers.runChildHPAEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400969 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200970 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200971 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100972 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400973 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200974 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200975 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Sergey Zhemerdeev9074f6e2022-06-07 12:03:16 +0300976 booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled),
Sergey Lalovbc68d752022-11-08 13:40:53 +0400977 booleanParam(name: 'PAUSE_FOR_DEBUG', value: triggers.pauseForDebugEnabled),
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300978 booleanParam(name: 'ENABLE_FIPS', value: triggers.enableFips),
Sergey Lalov00bea0f2023-08-14 16:46:33 +0400979 booleanParam(name: 'ENABLE_MKE_DUBUG', value: triggers.enableMkeDebugEnabled),
Mikhail Nikolaenkoc36dea92022-12-12 02:40:40 +0300980 booleanParam(name: 'AIO_CLUSTER', value: triggers.aioCluster),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200981 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200982
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200983 // customize multiregional demo
984 if (triggers.multiregionalConfiguration.enabled) {
985 parameters.add(string(name: 'MULTIREGION_SETUP',
986 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
987 ))
988 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200989
Владислав Наумов92288d92020-07-13 18:36:21 +0200990 // Determine component team custom context
991 if (coreContext != '') {
992 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
993 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200994 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200995 }
996
Владислав Наумовaa430612020-06-08 17:18:31 +0200997 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400998
999 platforms.each { platform ->
1000 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +00001001 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +04001002 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
1003 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
1004 def build_description = job_info.getDescription()
1005 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +00001006 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +02001007
Vladislav Naumov5313a202021-04-07 17:13:39 +00001008 if (build_description) {
1009 currentBuild.description += build_description
1010 }
1011 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +04001012 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +00001013 }
1014 }
1015 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001016
1017 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +04001018 if (jobs.size() == 0) {
1019 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
1020 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001021 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
1022 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +02001023
1024 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +02001025 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +02001026 currentBuild.result = 'FAILURE'
1027 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +02001028}
Владислав Наумов30a516c2020-07-09 13:15:41 +02001029
1030
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001031/**
1032 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +02001033 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001034 *
1035 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
1036 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
1037 * @param: multiregionalConfiguration (map) Multiregional configuration
1038 * @return (map) Return aggregated map with lockResources and netMap
1039 */
1040
1041
1042def generateLockResources(callBackDemo, triggers) {
1043 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +02001044 def netMap = [
1045 vsphere: [:],
1046 equinix: [:],
1047 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001048 // Define vsphere locklabels with initial quantity
1049 def lockLabels = [
1050 vsphere_networking_core_ci: 0,
1051 vsphere_offline_networking_core_ci: 0,
1052 ]
1053 def deployChild = triggers.deployChildEnabled
Sergey Lalov13eea422023-08-21 23:10:17 +04001054 def testUiVsphere = triggers.runUie2eEnabled || triggers.runUie2eNewEnabled
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001055 def multiregionConfig = triggers.multiregionalConfiguration
1056 def runMultiregion = multiregionConfig.enabled
1057
1058 // Generate vsphere netMap and lockLabels based on demo context
1059 switch (callBackDemo) {
1060 case 'aws':
1061 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
1062 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +04001063 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001064
1065 // Define netMap for Vsphere region
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +04001066 if (runMultiregion && multiregionConfig.managementLocation == 'aws') {
1067 if (multiregionConfig.regionLocation == 'vsphere') {
1068 if (deployChild) {
1069 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
1070 }
1071 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001072 }
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +04001073
1074 if (multiregionConfig.regionLocation == 'azure') {
1075 lockLabels['azure_core_ci_queue'] = 1
1076 if (deployChild) {
1077 lockLabels['azure_core_ci_queue'] += 1
1078 }
1079 }
1080 }
1081 if (triggers.azureOnAwsDemoEnabled) {
1082 lockLabels['azure_core_ci_queue'] = 1
1083 }
1084
1085 if (triggers.equinixOnAwsDemoEnabled) {
1086 lockLabels['equinix_core_ci_queue'] = 1
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001087 }
1088 break
1089 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +02001090 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
slalov27833272022-06-30 02:13:50 +04001091 if (deployChild || testUiVsphere) {
Владислав Наумов33e1e812021-08-17 17:09:25 +02001092 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001093 }
1094 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
1095 multiregionConfig.regionLocation == 'vsphere') {
1096 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +02001097 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001098 }
Владислав Наумов33e1e812021-08-17 17:09:25 +02001099 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001100 }
1101 break
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +04001102 case 'azure':
1103 lockLabels['azure_core_ci_queue'] = triggers.demoWeight
1104 if (runMultiregion && multiregionConfig.managementLocation == 'azure') {
1105 if (multiregionConfig.regionLocation == 'aws') {
1106 lockLabels['aws_core_ci_queue'] = 1
1107 if (deployChild) {
1108 lockLabels['aws_core_ci_queue'] += 1
1109 }
1110 }
1111
1112 if (multiregionConfig.regionLocation == 'equinix') {
1113 lockLabels['equinix_core_ci_queue'] = 1
1114 if (deployChild) {
1115 lockLabels['equinix_core_ci_queue'] +=1
1116 }
1117 }
1118 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001119 default:
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +04001120 error('Supposed to be called from aws, azure or vsphere demos only')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001121 }
1122
1123 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
1124 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +02001125 netMap['vsphere'].each { clusterType, netConfig ->
1126 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
1127 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
1128 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
1129
1130 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001131 lockLabels['vsphere_offline_networking_core_ci']++
1132 } else {
1133 lockLabels['vsphere_networking_core_ci']++
1134 }
1135 }
1136
1137 // generate lock metadata
1138 def lockResources = []
1139 lockLabels.each { label, quantity ->
1140 if (quantity > 0) {
1141 def res = [
1142 label: label,
1143 quantity: quantity,
1144 ]
1145 lockResources.add(res)
1146 }
1147 }
1148
1149 common.infoMsg("""Generated vsphere netMap: ${netMap}
1150 Generated lockResources: ${lockResources}""")
1151
1152 return [
1153 netMap: netMap,
1154 lockResources: lockResources,
1155 ]
1156}
1157
1158/**
1159 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
1160 * and empty rangeConfig to the this map.
1161 *
Владислав Наумов33e1e812021-08-17 17:09:25 +02001162 * @param: netMap (string) vsphere, equinix netMap or empty map
1163 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001164 * @param: clusterType (string) Vsphere cluster type
1165 */
1166
Владислав Наумов33e1e812021-08-17 17:09:25 +02001167def addToProviderNetMap (netMap, provider, clusterType) {
1168 switch (provider) {
1169 case 'equinix':
1170 netMap[provider][clusterType] = [
1171 vlanConfig: '',
1172 ]
1173 break
1174 case 'vsphere':
1175 netMap[provider][clusterType] = [
1176 netName: 'default',
1177 rangeConfig: '',
1178 ]
1179 break
1180 default:
1181 error('Net map locks supported for Equinix/Vsphere providers only')
1182 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +04001183}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +03001184
1185/**
1186* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
1187* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
1188* If keyword contains only 'key' part then 'value' is boolean True.
1189* This function does not perform keywords validation.
1190* First line of a commit message is ignored.
1191* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
1192* TODO: Remove backslash chars from values if they prepend '[' or ']'.
1193**/
1194
1195List getCIKeywordsFromCommitMsg() {
1196 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
1197 List commitMsgLines = commitMsg.split('\n')
1198 List keywords = []
1199 if (commitMsgLines.size() < 2) {
1200 return keywords
1201 }
1202
1203 String commitMsgBody = commitMsgLines[1..-1].join('\n')
1204
1205 // Split commit message body to chunks using '[' or ']' as delimiter,
1206 // ignoring them if prepended by backslash (regex negative lookbehind).
1207 // Resulting list will have chunks between '[' and ']' at odd indexes.
1208 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
1209
1210 // Iterate chunks by odd indexes only, trim values and split to
1211 // <key> / <value> pair where <key> is the part of a sting before the first
1212 // whitespace delimiter, and <value> is the rest (may include whitespaces).
1213 // If there is no whitespace in the string then this is a 'switch'
1214 // and <value> will be boolean True.
1215 for (i = 1; i < parts.size(); i += 2) {
1216 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
1217 keywords.add(['key': key, 'value': value])
1218 }
1219
1220 return keywords
1221}
1222
1223/**
1224* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
1225* that were specified for given job name. `job-params` keyword has the following structure
1226*
1227* [job-params <job name> <parameter name> <parameter value>]
1228*
1229* Return value is a Map that contains those parameters using the following structure:
1230*
1231* <job name>:
1232* <parameter name>: <parameter value>
1233*
1234**/
1235Map getJobsParamsFromCommitMsg() {
1236 List keywords = getCIKeywordsFromCommitMsg()
1237
1238 List jobsParamsList = []
1239 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
1240 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
1241 def (key, value) = params.split(/\s+/, 2)
1242 ['name': name, 'key': key, 'value': value]
1243 }
1244
1245 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
1246 if (!result.containsKey(it.name)) {
1247 result[it.name] = [:]
1248 }
1249 result[it.name][it.key] = it.value
1250 result
1251 }
1252
1253 return jobsParams
1254}
1255
1256
1257/**
1258* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
1259* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
1260* uses only those parametes that were set to all jobs (with <job name> == '*') or to
1261* a particular job. Parameters set to a particular job have higher precedence.
1262*
1263* Return value is a Map that contains those parameters:
1264*
1265* <parameter name>: <parameter value>
1266*
1267**/
1268Map getJobParamsFromCommitMsg(String jobName) {
1269 jobsParams = getJobsParamsFromCommitMsg()
1270 jobParams = jobsParams.getOrDefault('*', [:])
1271 if (jobName) {
1272 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
1273 }
1274 return jobParams
1275}
azvyagintsevc17d14b2022-06-06 19:06:33 +03001276
1277/** Getting test scheme from text, which should be
1278Imput example:
1279text="""
1280 DATA
1281
1282 kaas_bm_test_schemas:
1283 KAAS_RELEASES_REFSPEC: ''
1284 KEY: VAL
1285
1286 DATA
1287 """
1288
1289 Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas'])
1290
1291 Return:
1292 ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL']
1293 **/
1294def parseTextForTestSchemas(Map opts) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001295 String text = opts.getOrDefault('text', '')
azvyagintsevc17d14b2022-06-06 19:06:33 +03001296 String keyLine = opts.getOrDefault('keyLine', '')
1297 Map testScheme = [:]
1298 if (!text || !keyLine) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001299 return testScheme
azvyagintsevc17d14b2022-06-06 19:06:33 +03001300 }
1301 if (text =~ /\n$keyLine\n.*/) {
1302 def common = new com.mirantis.mk.Common()
1303 try {
1304 String regExp = '\\n' + keyLine + '\\n'
1305 // regexep block must be followed by empty line
1306 testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}"
1307 common.infoMsg("parseTextForTestSchemas result:\n" + testScheme)
1308 common.mergeEnv(env, toJson(testScheme))
1309 }
1310 catch (Exception e) {
1311 common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}")
1312 throw e
1313 }
1314 }
azvyagintsevd96aac22022-06-10 14:23:26 +03001315 return testScheme
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +03001316}
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001317
1318
1319/**
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001320* getEquinixFacilityWithCapacity returns list of Equinix facilities using specified
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001321* instance type (nodeType), desired count of facilities (facilityCount) and
1322* instances (nodeCount) in a facility using specified matal version.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001323* Function downloads metal CLI from the
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001324* https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux
1325* 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 +03001326* Non-empty list is shuffled.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001327*
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001328* @param: facilityCount (int) Desired count of facilities
1329* @param: nodeCount (int) Desired count of instances
1330* @param: nodeType (string) Instance type
1331* @param: version (string) Metal version to use
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001332* @return ([]string) List of selected facilities
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001333*
1334**/
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001335def getEquinixFacilityWithCapacity(facilityCount = 1, nodeCount = 50, nodeType = 'c3.small.x86', version = '0.9.0') {
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001336 def common = new com.mirantis.mk.Common()
1337 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 +03001338 def metal = './metal --config metal.yaml'
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001339 def facility = []
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001340 def out = ''
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001341 def retries = 3 // number of retries
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001342 def i = 0
1343 def delay = 60 // 1 minute sleep
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001344 def excludeFacility = [] // list of facilities to exclude from selection
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001345 try {
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001346 if (excludeFacility.size() > 0) {
1347 common.infoMsg("Excluded facilities: ${excludeFacility}")
1348 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001349 sh "curl -o metal -# ${metalUrl} && chmod +x metal"
1350 withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) {
1351 sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml'
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001352 }
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001353 while (facility.size() < facilityCount && i < retries) {
1354 common.infoMsg("Selecting ${facilityCount} available Equinix facilities with free ${nodeCount} ${nodeType} hosts, try ${i+1}/${retries} ...")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001355 if (i > 0 ) { // skip sleep on first step
1356 sleep(delay)
1357 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001358 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()
1359 facility = out.tokenize(',')
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001360 facility -= excludeFacility
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001361 if (facility.size() < facilityCount) {
1362 nodeCount -= 10
1363 // We need different metros for the [equinixmetalv2-child-diff-metro] case, facility[][0, 1] contains a metro name
1364 } else if (facility.size() == 2 && facility[0][0, 1] == facility[1][0, 1]) {
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001365 nodeCount -= 10
1366 }
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001367 i++
1368 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001369 if (facility.size() > 0) {
1370 f = facility.size() > 1 ? "${facility[0]},${facility[1]}" : "${facility[0]}"
1371 sh "${metal} capacity check -P ${nodeType} -f ${f} -q ${nodeCount}"
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001372 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001373 } catch (Exception e) {
1374 common.errorMsg "Exception: '${e}'"
1375 return []
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001376 } finally {
1377 sh 'rm metal.yaml'
1378 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001379 if (facility.size() > 0) {
Sergey Zhemerdeev15aa8602022-10-13 11:10:02 +03001380 Collections.shuffle(facility)
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001381 common.infoMsg("Selected facilities: ${facility}")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001382 } else {
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001383 common.warningMsg('No any facilities have been selected !!! :(')
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001384 }
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001385 return facility
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001386}
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001387
1388
1389/**
1390 * genCommandLine prepares command line for artifactory-replication
1391 * command using legacy environment variables
1392 *
1393 * @return: (string) Prepared command line
1394 */
1395def genCommandLine() {
1396 def envToParam = [
1397 'DESTINATION_USER': '-dst-user',
1398 'ARTIFACT_FILTER': '-artifact-filter',
1399 'ARTIFACT_FILTER_PROD': '-artifact-filter-prod',
1400 'ARTIFACT_TYPE': '-artifact-type',
1401 'BINARY_CLEAN': '-bin-cleanup',
1402 'BINARY_CLEAN_KEEP_DAYS': '-bin-clean-keep-days',
1403 'BINARY_CLEAN_PREFIX': '-bin-clean-prefix',
1404 'BUILD_URL': '-slack-build-url',
1405 'CHECK_REPOS': '-check-repos',
1406 'DESTINATION_REGISTRY': '-dst-repo',
1407 'DESTINATION_REGISTRY_TYPE': '-dst-repo-type',
1408 'DOCKER_CLEAN': '-cleanup',
1409 'DOCKER_REPO_PREFIX': '-docker-repo-prefix',
1410 'DOCKER_TAG': '-docker-tag',
1411 'FORCE': '-force',
1412 'HELM_CDN_DOMAIN': '-helm-cdn-domain',
1413 'SLACK_CHANNEL': '-slack-channel',
1414 'SLACK_USER': '-slack-user',
1415 'SOURCE_REGISTRY': '-src-repo',
1416 'SOURCE_REGISTRY_TYPE': '-src-repo-type',
1417 'SYNC_PATTERN': '-sync-pattern'
1418 ]
1419 def cmdParams = ''
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001420 def isCheckClean = false
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001421 for (e in envToParam) {
1422 if (env[e.key] == null) {
1423 continue
1424 }
1425 if (e.key == 'CHECK_REPOS' || e.key == 'DOCKER_CLEAN') {
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001426 // Avoid CHECK_REPOS=true and DOCKER_CLEAN=true
1427 if (env[e.key].toBoolean() && !isCheckClean) {
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001428 cmdParams += e.value + ' '
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001429 isCheckClean = true
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001430 }
1431 } else if (e.key == 'FORCE') {
1432 if (env[e.key].toBoolean()) {
1433 cmdParams += e.value + ' '
1434 }
1435 } else {
Sergey Zhemerdeeve2926cd2022-08-29 15:28:47 +03001436 cmdParams += "${e.value} '${env[e.key]}' "
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001437 }
1438 }
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001439 // No any check or clean was specified - take a default action
1440 if (!isCheckClean) {
1441 cmdParams += '-replicate'
1442 }
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001443 return cmdParams
1444}
Sergey Kolekonov0e60a942022-09-05 13:02:22 +04001445
1446/**
1447 * custom scheduling algorithm
1448 * it ensures that builds of the same job are distributed as much as possible between different nodes
1449 * @param label (string) desired node label
1450 * @return: (string) node name
1451 */
1452def schedule (label='docker') {
1453 def common = new com.mirantis.mk.Common()
1454 def freeNodes = []
1455 def nodesMap = [:]
1456
1457 // filter nodes with the specified label and at least one free executor
1458 timeout(time: 30, unit: 'MINUTES') {
1459 while (!freeNodes) {
1460 freeNodes = jenkins.model.Jenkins.instance.computers.findAll { node ->
1461 label in node.getAssignedLabels().collect { it.name } &&
Sergey Kolekonovd5887172022-11-10 12:13:22 +06001462 node.isPartiallyIdle() &&
1463 node.isOnline()
Sergey Kolekonov0e60a942022-09-05 13:02:22 +04001464 }
1465 if (!freeNodes) {
1466 echo 'No nodes available for scheduling, retrying...'
1467 sleep 30
1468 }
1469 }
1470 }
1471
1472 // generate a map of nodes matching other criteria
1473 for (node in freeNodes) {
1474 // sameJobExecutors is the number of executors running the same job as the calling one
1475 sameJobExecutors = node.getExecutors() // get all executors
1476 .collect { executor -> executor.getCurrentExecutable() } // get running "threads"
1477 .collect { thread -> thread?.displayName } // filter job names from threads
1478 .minus(null) // null = empty executors, remove them from the list
1479 .findAll { it.contains(env.JOB_NAME) } // filter the same jobs as the calling one
1480 .size()
1481
1482 // calculate busy executors, we don't want to count "sameJobExecutors" twice
1483 totalBusyExecutors = node.countBusy() - sameJobExecutors
1484 // generate the final map which contains nodes matching criteria with their load score
1485 // builds of the same jobs have x10 score, all others x1
1486 nodesMap += ["${node.getName()}" : sameJobExecutors * 10 + totalBusyExecutors]
1487 }
1488
1489 // return the least loaded node
1490 return common.SortMapByValueAsc(nodesMap).collect { it.key }[0]
1491}
Sergey Zhemerdeev78a65272023-03-23 18:05:22 +02001492
1493
1494/**
1495 * Get latest tag for test/frontend & equinix-private-infra images
1496 * @param version (str) default tag value from main workflow
1497 * @param isChanged (bool) is dependent directory files were changed
1498 * @param imageName (string) image name for information message
1499 * @return: (string) tag name
1500 */
1501def getImageTag(version, isChanged, imageName) {
1502 def common = new com.mirantis.mk.Common()
Sergey Zhemerdeev5fbf2022023-04-28 14:51:36 +03001503 def latestTag = ''
1504 if (env.GERRIT_EVENT_TYPE && !(env.GERRIT_EVENT_TYPE in ['change-merged', 'ref-updated']) && isChanged) {
Sergey Zhemerdeev78a65272023-03-23 18:05:22 +02001505 latestTag = version
Sergey Zhemerdeevebdcad22023-04-25 16:58:28 +03001506 } else {
1507 if (env.GERRIT_EVENT_TYPE == 'ref-updated') {
1508 latestTag = env.GERRIT_REFNAME.replace('refs/tags/v', '').trim()
1509 } else {
1510 latestTag = env.GERRIT_BRANCH ? env.GERRIT_BRANCH : env.GERRIT_REFSPEC ? env.GERRIT_REFSPEC : 'master'
1511 if (latestTag != 'master') {
1512 latestTag = latestTag.replaceAll('/', '_')
1513 }
1514 }
Sergey Zhemerdeev78a65272023-03-23 18:05:22 +02001515 }
1516 common.infoMsg("${imageName} image will use tag '${latestTag}'")
1517 return latestTag
1518}
Sergey Zhemerdeev1d2c03e2023-04-28 11:07:24 +03001519
1520
1521/**
1522 * Translates set of environment vars into actual replicator command line
1523 * @return: (string cmdParams, string jobDescription)
1524 * cmdParams - generated command line
1525 * jobDescription - job description
1526 */
1527def genReplicatorCommandLine() {
1528 def mainModes = ['REPLICATE', 'CLEANUP', 'CHECK_REPOS', 'BIN_CLEANUP']
Sergey Zhemerdeev9919b1b2023-04-28 17:24:21 +03001529 def parameterWithoutArgument = mainModes
Sergey Zhemerdeev1d2c03e2023-04-28 11:07:24 +03001530 def parametersList = parameterWithoutArgument + [
1531 'ARTIFACT_FILTER',
1532 'ARTIFACT_TYPE',
1533 'BIN_CLEAN_KEEP_DAYS',
1534 'BIN_CLEAN_PREFIX',
1535 'DOCKER_TAG',
1536 // DST_ will be changed to TARGET_
1537 'DST_REPO',
1538 'DST_REPO_TYPE',
1539 'DST_USER',
1540 'OLDER_THAN_DAYS',
1541 'SLACK_BUILD_URL',
1542 'SLACK_CHANNEL',
1543 'SLACK_USER',
1544 'SRC_REPO',
1545 'SRC_REPO_TYPE',
1546 'SRC_USER',
1547 'SYNC_PATTERN',
1548 'THREAD_COUNT'
1549 ]
1550 def mainModesDescriptions = [
1551 'REPLICATE': 'Replicating binaries/Docker images',
1552 'CLEANUP': 'Cleaning Docker images',
1553 'BIN_CLEANUP': 'Cleaning binaries',
1554 'CHECK_REPOS': 'Checking binaries'
1555 ]
1556
1557 def cmdParams = ''
1558 def jobDescription = ''
1559 for (e in parametersList) {
1560 if (env[e] == null || env[e] == '') {
1561 continue
1562 }
1563 if (e in mainModes) {
1564 jobDescription = mainModesDescriptions[e]
1565 }
1566 cmdParams += "-${e.replaceAll('_', '-').toLowerCase()} "
1567 if (!(e in parameterWithoutArgument)) {
1568 cmdParams += "'${env[e]}' "
1569 }
1570 }
1571 return [cmdParams, jobDescription]
1572}