blob: a96bd2da51fc5ae3087b1bd96dd87692456ce833 [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
Владислав Наумов9cec55d2021-08-03 15:00:59 +020072 def runLMATest = env.RUN_LMA_TEST ? env.RUN_LMA_TEST.toBoolean() : false
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +020073 def runMgmtUserControllerTest = env.RUN_MGMT_USER_CONTROLLER_TEST ? env.RUN_MGMT_USER_CONTROLLER_TEST.toBoolean() : false
Mikhail Ivanov2907e4d2022-04-25 16:41:21 +040074 def runProxyChildTest = env.RUN_PROXY_CHILD_TEST ? env.RUN_PROXY_CHILD_TEST.toBoolean() : false
Владислав Наумов6c2afff2020-06-05 12:54:53 +020075 def runChildConformance = env.RUN_CHILD_CFM ? env.RUN_CHILD_CFM.toBoolean() : false
76 def fetchServiceBinaries = env.FETCH_BINARIES_FROM_UPSTREAM ? env.FETCH_BINARIES_FROM_UPSTREAM.toBoolean() : false
Vladislav Naumov42b71dc2021-11-22 13:09:42 +010077 def equinixMetalV2ChildDiffMetro = env.EQUINIXMETALV2_CHILD_DIFF_METRO ? env.EQUINIXMETALV2_CHILD_DIFF_METRO.toBoolean() : false
slalov13e579c2022-01-31 21:37:02 +040078 def runMaintenanceTest = env.RUN_MAINTENANCE_TEST ? env.RUN_MAINTENANCE_TEST.toBoolean() : false
slalov0a4947a2022-06-09 15:44:35 +040079 def runContainerregistryTest = env.RUN_CONTAINER_REGISTRY_TEST ? env.RUN_CONTAINER_REGISTRY_TEST.toBoolean() : false
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +030080 def runMgmtDeleteMasterTest = env.RUN_MGMT_DELETE_MASTER_TEST ? env.RUN_MGMT_DELETE_MASTER_TEST.toBoolean() : false
81 def runRgnlDeleteMasterTest = env.RUN_RGNL_DELETE_MASTER_TEST ? env.RUN_RGNL_DELETE_MASTER_TEST.toBoolean() : false
82 def runChildDeleteMasterTest = env.RUN_CHILD_DELETE_MASTER_TEST ? env.RUN_CHILD_DELETE_MASTER_TEST.toBoolean() : false
Владислав Наумов765f3bd2020-09-07 18:09:24 +020083 // multiregion configuration from env variable: comma-separated string in form $mgmt_provider,$regional_provider
84 def multiregionalMappings = env.MULTIREGION_SETUP ? multiregionWorkflowParser(env.MULTIREGION_SETUP) : [
85 enabled: false,
86 managementLocation: '',
87 regionLocation: '',
88 ]
Владислав Наумов4eb1da32020-08-31 14:45:16 +020089
Владислав Наумовb8305e22021-02-10 17:23:12 +010090 // proxy customization
91 def proxyConfig = [
Владислав Наумовf8f23fa2021-04-01 16:57:52 +020092 mgmtOffline: env.OFFLINE_MGMT_CLUSTER ? env.OFFLINE_MGMT_CLUSTER.toBoolean() : false,
93 childOffline: env.OFFLINE_CHILD_CLUSTER ? env.OFFLINE_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумов257ea132021-04-14 14:44:13 +020094 childProxy: env.PROXY_CHILD_CLUSTER ? env.PROXY_CHILD_CLUSTER.toBoolean() : false,
Владислав Наумовb8305e22021-02-10 17:23:12 +010095 ]
96
Владислав Наумов4eb1da32020-08-31 14:45:16 +020097 // optional demo deployment customization
Владислав Наумов905dd362020-06-08 16:37:01 +020098 def awsOnDemandDemo = env.ALLOW_AWS_ON_DEMAND ? env.ALLOW_AWS_ON_DEMAND.toBoolean() : false
Владислав Наумовe021b022021-05-06 11:26:38 +020099 def equinixOnDemandDemo = env.ALLOW_EQUINIX_ON_DEMAND ? env.ALLOW_EQUINIX_ON_DEMAND.toBoolean() : false
Владислав Наумов82305e92021-10-14 20:45:20 +0200100 def equinixMetalV2OnDemandDemo = env.ALLOW_EQUINIXMETALV2_ON_DEMAND ? env.ALLOW_EQUINIXMETALV2_ON_DEMAND.toBoolean() : false
Владислав Наумовf3715802021-05-03 18:06:45 +0200101 def equinixOnAwsDemo = env.EQUINIX_ON_AWS_DEMO ? env.EQUINIX_ON_AWS_DEMO.toBoolean() : false
Владислав Наумов2d3db332021-06-15 15:19:19 +0200102 def azureOnAwsDemo = env.AZURE_ON_AWS_DEMO ? env.AZURE_ON_AWS_DEMO.toBoolean() : false
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200103 def azureOnDemandDemo = env.ALLOW_AZURE_ON_DEMAND ? env.ALLOW_AZURE_ON_DEMAND.toBoolean() : false
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400104 def enableVsphereDemo = true
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200105 def enableOSDemo = true
azvyagintsev1761bdc2020-09-04 17:24:12 +0300106 def enableBMDemo = true
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400107 def enableArtifactsBuild = true
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400108 def openstackIMC = env.OPENSTACK_CLOUD_LOCATION ? env.OPENSTACK_CLOUD_LOCATION : 'us'
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300109 def enableVsphereUbuntu = env.VSPHERE_DEPLOY_UBUNTU ? env.VSPHERE_DEPLOY_UBUNTU.toBoolean() : false
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300110 def childOsBootFromVolume = env.OPENSTACK_BOOT_FROM_VOLUME ? env.OPENSTACK_BOOT_FROM_VOLUME.toBoolean() : false
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400111 def bootstrapV2Scenario = env.BOOTSTRAP_V2_ENABLED ? env.BOOTSTRAP_V2_ENABLED.toBoolean() : false
Sergey Lalovacec3c12022-07-20 16:00:14 +0400112 def equinixMetalV2Metro = env.EQUINIX_MGMT_METRO ? env.EQUINIX_MGMT_METRO : ''
vnaumov33747e12020-05-04 17:35:20 +0200113
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200114 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
Владислав Наумовb8305e22021-02-10 17:23:12 +0100115 if (commitMsg ==~ /(?s).*\[mgmt-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-proxy.*/) {
116 proxyConfig['mgmtOffline'] = true
Владислав Наумов70c02422021-04-19 14:29:41 +0200117 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 +0100118 }
Владислав Наумов44c64b72020-12-04 20:22:53 +0100119 if (commitMsg ==~ /(?s).*\[seed-macos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*seed-macos.*/) {
120 seedMacOs = true
121 }
slalov574123e2022-04-06 17:24:19 +0400122 if (commitMsg ==~ /(?s).*\[child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-deploy.*/ || upgradeChild || runChildConformance || runProxyChildTest) {
vnaumov33747e12020-05-04 17:35:20 +0200123 deployChild = true
124 }
125 if (commitMsg ==~ /(?s).*\[child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade.*/) {
126 deployChild = true
127 upgradeChild = true
128 }
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400129 if (commitMsg ==~ /(?s).*\[child-upgrade-full\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-upgrade-full.*/) {
130 deployChild = true
131 upgradeChild = true
132 fullUpgradeChild = true
133 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400134 def childDeployMatches = (commitMsg =~ /(\[child-deploy\s*(\w|\-)+?\])/)
135 if (childDeployMatches.size() > 0) {
Mikhail Ivanov74504372021-05-21 17:01:06 +0400136 // override child version when it set explicitly
137 deployChild = true
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400138 customChildRelease = childDeployMatches[0][0].split('child-deploy')[1].replaceAll('[\\[\\]]', '').trim()
Mikhail Ivanov74504372021-05-21 17:01:06 +0400139 common.warningMsg("Forced child deployment using custom release version ${customChildRelease}")
140 }
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400141 if (commitMsg ==~ /(?s).*\[mos-child-deploy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-deploy.*/) {
142 mosDeployChild = true
143 }
144 if (commitMsg ==~ /(?s).*\[mos-child-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-child-upgrade.*/) {
145 mosDeployChild = true
146 mosUpgradeChild = true
147 }
Владислав Наумов0dc99252020-11-13 13:30:48 +0100148 if (commitMsg ==~ /(?s).*\[byo-attach\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-attach.*/) {
149 attachBYO = true
150 }
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100151 if (commitMsg ==~ /(?s).*\[byo-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*byo-upgrade.*/) {
152 attachBYO = true
153 upgradeBYO = true
154 }
Sergey Lalovacec3c12022-07-20 16:00:14 +0400155 if (commitMsg ==~ /(?s).*\[ui-test-on-all-providers\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-test-on-all-providers.*/) {
156 enableVsphereDemo = true
157 enableOSDemo = true
158 awsOnDemandDemo = true
159 azureOnDemandDemo = true
160 equinixOnDemandDemo = true
161 equinixMetalV2OnDemandDemo = true
162 runUie2e = true
Sergey Lalovacec3c12022-07-20 16:00:14 +0400163 // Edit after fix PRODX-3961
164 enableBMDemo = false
165 }
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400166 def byoDeployMatches = (commitMsg =~ /(\[run-byo-matrix\s*(ubuntu|centos)\])/)
167 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 +0100168 runBYOMatrix = true
169
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400170 if (byoDeployMatches.size() > 0) {
171 defaultBYOOs = byoDeployMatches[0][2]
172 common.warningMsg("Custom BYO OS detected, using ${defaultBYOOs}")
173 }
174
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100175 common.warningMsg('Forced byo matrix test via run-byo-matrix, all other byo triggers will be skipped')
176 attachBYO = false
177 upgradeBYO = false
178 }
Владислав Наумов7f8c9872021-03-08 17:33:08 +0400179 if (commitMsg ==~ /(?s).*\[mgmt-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-upgrade.*/) {
vnaumov33747e12020-05-04 17:35:20 +0200180 upgradeMgmt = true
181 }
slalov1202bba2022-04-20 22:31:07 +0400182 if (commitMsg ==~ /(?s).*\[auto-upgrade\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*auto-upgrade.*/) {
183 autoUpgradeMgmt = true
184 }
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400185 if (commitMsg ==~ /(?s).*\[lma-logging\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-logging.*/) {
186 enableLMALogging = true
187 }
Sergey Lalovb2f60372022-09-20 23:58:47 +0400188 if (commitMsg ==~ /(?s).*\[deploy-os-on-mos\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*deploy-os-on-mos.*/) {
189 deployOsOnMos = true
190 mosDeployChild = true
191 openstackIMC = 'eu2'
192 }
vnaumov33747e12020-05-04 17:35:20 +0200193 if (commitMsg ==~ /(?s).*\[ui-e2e\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e.*/) {
194 runUie2e = true
195 }
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400196 if (commitMsg ==~ /(?s).*\[ui-e2e-new\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*ui-e2e-new.*/) {
197 runUie2eNew = true
198 }
vnaumov33747e12020-05-04 17:35:20 +0200199 if (commitMsg ==~ /(?s).*\[mgmt-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-cfm.*/) {
200 runMgmtConformance = true
201 }
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200202 if (commitMsg ==~ /(?s).*\[test-user-controller\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-user-controller.*/) {
203 runMgmtUserControllerTest = true
204 }
slalov574123e2022-04-06 17:24:19 +0400205 if (commitMsg ==~ /(?s).*\[test-proxy-child\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*test-proxy-child.*/) {
206 runProxyChildTest = true
207 deployChild = true
208 common.infoMsg('Child cluster deployment will be enabled since proxy child test suite will be executed')
209 }
vnaumov33747e12020-05-04 17:35:20 +0200210 if (commitMsg ==~ /(?s).*\[child-cfm\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-cfm.*/) {
211 runChildConformance = true
212 deployChild = true
213 }
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200214 if (commitMsg ==~ /(?s).*\[lma-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*lma-test.*/) {
215 runLMATest = true
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400216 enableLMALogging = true
217 common.infoMsg('LMA logging will be enabled since LMA test suite will be executed')
Victor Ryzhenkin15206592021-06-21 17:38:23 +0400218 }
slalov13e579c2022-01-31 21:37:02 +0400219 if (commitMsg ==~ /(?s).*\[maintenance-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*maintenance-test.*/) {
220 runMaintenanceTest = true
221 }
slalov0a4947a2022-06-09 15:44:35 +0400222 if (commitMsg ==~ /(?s).*\[container-registry-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*container-registry-test.*/) {
223 runContainerregistryTest = true
224 }
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300225 if (commitMsg ==~ /(?s).*\[mgmt-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mgmt-delete-master-test.*/) {
226 runMgmtDeleteMasterTest = true
227 }
228 if (commitMsg ==~ /(?s).*\[rgnl-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*rgnl-delete-master-test.*/) {
229 runRgnlDeleteMasterTest = true
230 }
231 if (commitMsg ==~ /(?s).*\[child-delete-master-test\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-delete-master-test.*/) {
232 runChildDeleteMasterTest = true
233 }
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200234 if (commitMsg ==~ /(?s).*\[child-offline\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-offline.*/) {
235 proxyConfig['childOffline'] = true
236 deployChild = true
237 }
Владислав Наумов257ea132021-04-14 14:44:13 +0200238 if (commitMsg ==~ /(?s).*\[child-proxy\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-proxy.*/) {
239 proxyConfig['childOffline'] = true
240 proxyConfig['childProxy'] = true
241 deployChild = true
242 }
vnaumov33747e12020-05-04 17:35:20 +0200243 if (commitMsg ==~ /(?s).*\[fetch.*binaries\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*fetch.*binaries.*/) {
244 fetchServiceBinaries = true
245 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200246 if (commitMsg ==~ /(?s).*\[equinix-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-on-aws.*/) {
eromanovadf247c32020-12-25 15:44:13 +0400247 equinixOnAwsDemo = true
Владислав Наумовf1665b52021-05-13 10:51:17 +0200248 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 +0400249 }
Владислав Наумов2d3db332021-06-15 15:19:19 +0200250 if (commitMsg ==~ /(?s).*\[azure-on-aws\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-on-aws.*/) {
251 azureOnAwsDemo = true
252 common.warningMsg('Forced running child cluster deployment on Azure provider based on AWS management cluster, triggered on patchset using custom keyword: \'[azure-on-aws]\' ')
253 }
254 if (commitMsg ==~ /(?s).*\[aws-demo\].*/ ||
255 env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*aws-demo.*/ ||
256 attachBYO ||
257 upgradeBYO ||
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100258 runBYOMatrix ||
Владислав Наумов2d3db332021-06-15 15:19:19 +0200259 seedMacOs ||
260 equinixOnAwsDemo ||
261 azureOnAwsDemo) {
262
vnaumov33747e12020-05-04 17:35:20 +0200263 awsOnDemandDemo = true
Владислав Наумов2d3db332021-06-15 15:19:19 +0200264 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 +0200265 }
Владислав Наумовf1665b52021-05-13 10:51:17 +0200266 if (commitMsg ==~ /(?s).*\[equinix-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinix-demo\.*/) {
Владислав Наумовe021b022021-05-06 11:26:38 +0200267 equinixOnDemandDemo = true
268 }
Владислав Наумов82305e92021-10-14 20:45:20 +0200269 if (commitMsg ==~ /(?s).*\[equinixmetalv2-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-demo\.*/) {
Владислав Наумов144956f2021-10-14 17:49:19 +0200270 equinixMetalV2OnDemandDemo = true
271 }
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100272 if (commitMsg ==~ /(?s).*\[equinixmetalv2-child-diff-metro\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*equinixmetalv2-child-diff-metro\.*/) {
273 equinixMetalV2OnDemandDemo = true
274 equinixMetalV2ChildDiffMetro = true
275 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200276 if (commitMsg ==~ /(?s).*\[azure-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*azure-demo\.*/) {
277 azureOnDemandDemo = true
278 }
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200279 if (commitMsg ==~ /(?s).*\[disable-os-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-os-demo\.*/) {
280 enableOSDemo = false
281 common.errorMsg('Openstack demo deployment will be aborted, VF -1 will be set')
vnaumov33747e12020-05-04 17:35:20 +0200282 }
283
azvyagintsev1761bdc2020-09-04 17:24:12 +0300284 if (commitMsg ==~ /(?s).*\[disable-bm-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-bm-demo\.*/) {
285 enableBMDemo = false
286 common.errorMsg('BM demo deployment will be aborted, VF -1 will be set')
287 }
288
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400289 if (commitMsg ==~ /(?s).*\[disable-vsphere-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-vsphere-demo\.*/) {
290 enableVsphereDemo = false
291 common.errorMsg('vSphere demo deployment will be aborted, VF -1 will be set')
292 }
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300293 if (commitMsg ==~ /(?s).*\[vsphere-ubuntu\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*vsphere-ubuntu\.*/) {
294 enableVsphereUbuntu = true
295 common.warningMsg('Ubuntu will be used to deploy vsphere machines')
296 }
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400297
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400298 if (commitMsg ==~ /(?s).*\[disable-artifacts-build\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*disable-artifacts-build\.*/) {
299 enableArtifactsBuild = false
300 common.errorMsg('artifacts build will be aborted, VF -1 will be set')
301 }
302
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300303 if (commitMsg ==~ /(?s).*\[child-os-boot-from-volume\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*child-os-boot-from-volume\.*/) {
304 childOsBootFromVolume = true
305 common.warningMsg('OS will be booted from Ceph volumes')
306 }
307
vnaumov33747e12020-05-04 17:35:20 +0200308 // TODO (vnaumov) remove below condition after moving all releases to UCP
309 def ucpChildMatches = (commitMsg =~ /(\[child-ucp\s*ucp-.*?\])/)
310 if (ucpChildMatches.size() > 0) {
311 deployChild = true
312 common.warningMsg('Forced UCP based child deployment triggered on patchset using custom keyword: \'[child-ucp ucp-5-1-0-3-3-0-example]\' ')
313
314 // TODO(vnaumov) delete after ucp upgrades support
315 common.errorMsg('Child upgrade test will be skipped, UCP upgrades temporally disabled')
316 upgradeChild = false
317 }
318
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200319 // multiregional tests
320 def multiRegionalMatches = (commitMsg =~ /(\[multiregion\s*.*?\])/)
321 if (multiRegionalMatches.size() > 0) {
322 multiregionalMappings = multiregionWorkflowParser(multiRegionalMatches)
323 }
324 switch (multiregionalMappings['managementLocation']) {
325 case 'aws':
Владислав Наумов53b07e52021-01-07 15:08:27 +0100326 common.warningMsg('Forced running additional kaas deployment with AWS provider according multiregional demo request')
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200327 awsOnDemandDemo = true
Владислав Наумов53b07e52021-01-07 15:08:27 +0100328
329 if (multiregionalMappings['regionLocation'] != 'aws' && seedMacOs) { // macstadium seed node has access only to *public* providers
330 error('incompatible triggers: [seed-macos] and multiregional deployment based on *private* regional provider cannot be applied simultaneously')
331 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200332 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200333 case 'os':
334 if (enableOSDemo == false) {
335 error('incompatible triggers: [disable-os-demo] and multiregional deployment based on OSt management region cannot be applied simultaneously')
336 }
Владислав Наумов3e4b5a32020-09-11 17:05:34 +0200337 break
Владислав Наумов865ba6c2021-05-13 13:05:45 +0200338 case 'vsphere':
339 if (enableVsphereDemo == false) {
340 error('incompatible triggers: [disable-vsphere-demo] and multiregional deployment based on Vsphere management region cannot be applied simultaneously')
341 }
342 break
Владислав Наумов5be02942021-05-13 12:34:37 +0200343 case 'equinix':
344 common.warningMsg('Forced running additional kaas deployment with Equinix provider according multiregional demo request')
345 equinixOnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400346 break
eromanova8c702ae2021-12-24 17:43:12 +0400347 case 'equinixmetalv2':
348 common.warningMsg('Forced running additional kaas deployment with Equinix Metal V2 provider according multiregional demo request')
349 equinixMetalV2OnDemandDemo = true
eromanova35359162021-12-30 14:13:13 +0400350 break
slalovfd0b7e62021-07-28 18:05:16 +0400351 case 'azure':
352 common.warningMsg('Forced running additional kaas deployment with Azure provider according multiregional demo request')
353 azureOnDemandDemo = true
354 break
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200355 }
356
Владислав Наумовb8305e22021-02-10 17:23:12 +0100357 // CDN configuration
358 def cdnConfig = [
359 mgmt: [
360 openstack: (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-ci',
Владислав Наумов70c02422021-04-19 14:29:41 +0200361 vsphere: 'internal-ci',
Владислав Наумовb8305e22021-02-10 17:23:12 +0100362 aws: 'public-ci',
Владислав Наумовe021b022021-05-06 11:26:38 +0200363 equinix: 'public-ci',
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200364 azure: 'public-ci',
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200365 ],
Владислав Наумовb8305e22021-02-10 17:23:12 +0100366 ]
367
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400368 if (commitMsg ==~ /(?s).*\[eu-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*eu-demo.*/) {
369 openstackIMC = 'eu'
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400370 }
slalov021171f2022-03-04 14:48:38 +0400371 if (commitMsg ==~ /(?s).*\[mos-tf-demo\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*mos-tf-demo.*/) {
372 openstackIMC = 'eu2'
Mikhail Ivanovf05b8252022-04-27 18:14:03 +0400373 }
374 if (openstackIMC == 'eu' || openstackIMC == 'eu2') {
slalov021171f2022-03-04 14:48:38 +0400375 // use internal-eu because on internal-ci with eu cloud image pull takes much time
376 def cdnRegion = (proxyConfig['mgmtOffline'] == true) ? 'public-ci' : 'internal-eu'
377 common.infoMsg("eu2-demo was triggered, force switching CDN region to ${cdnRegion}")
378 cdnConfig['mgmt']['openstack'] = cdnRegion
379 }
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400380
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100381 // calculate weight of current demo run to manage lockable resources
Sergey Lalov46deb442022-08-18 12:11:03 +0400382 def demoWeight = deployChild ? 2 : 1 // management = 1, child += 1
383 if (runUie2e) {
384 demoWeight += 1
385 }
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100386
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400387 if (commitMsg ==~ /(?s).*\[bootstrapv2-scenario\].*/ || env.GERRIT_EVENT_COMMENT_TEXT ==~ /(?s).*bootstrapv2-scenario\.*/) {
388 bootstrapV2Scenario = true
389 }
390
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300391 // parse equinixmetalv2-metro trigger
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300392 def equinixMetalV2MetroMatcher = (commitMsg =~ /\[equinixmetalv2-metro(\s+.*)?\]/)
393 if (equinixMetalV2OnDemandDemo && equinixMetalV2MetroMatcher.size() > 0) {
Sergey Zhemerdeevcc785e42022-07-22 17:15:47 +0300394 equinixMetalV2Metro = equinixMetalV2MetroMatcher[0][1].trim().toLowerCase()
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300395 common.infoMsg("Forced Equnix mgmt deployment using custom metro ${equinixMetalV2Metro}")
396 }
397
vnaumov33747e12020-05-04 17:35:20 +0200398 common.infoMsg("""
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400399 OpenStack Cloud location: ${openstackIMC}
Владислав Наумовb8305e22021-02-10 17:23:12 +0100400 CDN deployment configuration: ${cdnConfig}
401 MCC offline deployment configuration: ${proxyConfig}
Владислав Наумов44c64b72020-12-04 20:22:53 +0100402 Use MacOS node as seed: ${seedMacOs}
vnaumov33747e12020-05-04 17:35:20 +0200403 Child cluster deployment scheduled: ${deployChild}
Mikhail Ivanov74504372021-05-21 17:01:06 +0400404 Custom child cluster release: ${customChildRelease}
vnaumov33747e12020-05-04 17:35:20 +0200405 Child cluster release upgrade scheduled: ${upgradeChild}
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400406 Full Child cluster release upgrade scheduled: ${fullUpgradeChild}
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400407 MOS child deploy scheduled: ${mosDeployChild}
408 MOS child upgrade scheduled: ${mosUpgradeChild}
vnaumov33747e12020-05-04 17:35:20 +0200409 Child conformance testing scheduled: ${runChildConformance}
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100410 Single BYO cluster attachment scheduled: ${attachBYO}
411 Single Attached BYO cluster upgrade test scheduled: ${upgradeBYO}
412 BYO test matrix whole suite scheduled: ${runBYOMatrix}
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400413 Default BYO OS: ${defaultBYOOs}
vnaumov33747e12020-05-04 17:35:20 +0200414 Mgmt cluster release upgrade scheduled: ${upgradeMgmt}
slalov1202bba2022-04-20 22:31:07 +0400415 Mgmt cluster release auto upgrade scheduled: ${autoUpgradeMgmt}
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400416 Mgmt LMA logging enabled: ${enableLMALogging}
Sergey Lalovb2f60372022-09-20 23:58:47 +0400417 Deploy Os on child with mos release ${deployOsOnMos}
vnaumov33747e12020-05-04 17:35:20 +0200418 Mgmt conformance testing scheduled: ${runMgmtConformance}
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200419 LMA testing scheduled: ${runLMATest}
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200420 Mgmt user controller testing scheduled: ${runMgmtUserControllerTest}
vnaumov33747e12020-05-04 17:35:20 +0200421 Mgmt UI e2e testing scheduled: ${runUie2e}
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400422 Mgmt UI e2e playwrite testing scheduled: ${runUie2eNew}
slalov13e579c2022-01-31 21:37:02 +0400423 Maintenance test: ${runMaintenanceTest}
slalov0a4947a2022-06-09 15:44:35 +0400424 Container Registry test: ${runContainerregistryTest}
slalov574123e2022-04-06 17:24:19 +0400425 Child proxy test: ${runProxyChildTest}
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300426 Delete mgmt master node test: ${runMgmtDeleteMasterTest}
427 Delete rgnl master node test: ${runRgnlDeleteMasterTest}
428 Delete child master node test: ${runChildDeleteMasterTest}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200429 AWS provider deployment scheduled: ${awsOnDemandDemo}
Владислав Наумовe021b022021-05-06 11:26:38 +0200430 Equinix provider deployment scheduled: ${equinixOnDemandDemo}
Владислав Наумов144956f2021-10-14 17:49:19 +0200431 EquinixmetalV2 provider deployment scheduled: ${equinixMetalV2OnDemandDemo}
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100432 EquinixmetalV2 child deploy in a separate metro scheduled: ${equinixMetalV2ChildDiffMetro}
Sergey Zhemerdeev019c45a2022-08-13 00:09:07 +0300433 EquinixmetalV2 mgmt will be deployed on the metro: ${equinixMetalV2Metro?:'auto'}
Владислав Наумовf1665b52021-05-13 10:51:17 +0200434 Equinix@AWS child cluster deployment scheduled: ${equinixOnAwsDemo}
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200435 Azure provider deployment scheduled: ${azureOnDemandDemo}
Владислав Наумов2d3db332021-06-15 15:19:19 +0200436 Azure@AWS child cluster deployment scheduled: ${azureOnAwsDemo}
Ivan Berezovskiyf9bcfd62021-03-18 18:41:38 +0400437 VSPHERE provider deployment scheduled: ${enableVsphereDemo}
Владислав Наумов4eb1da32020-08-31 14:45:16 +0200438 OS provider deployment scheduled: ${enableOSDemo}
azvyagintsev1761bdc2020-09-04 17:24:12 +0300439 BM provider deployment scheduled: ${enableBMDemo}
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300440 Ubuntu on vSphere scheduled: ${enableVsphereUbuntu}
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400441 Artifacts build scheduled: ${enableArtifactsBuild}
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300442 Boot OS child from Ceph volumes: ${childOsBootFromVolume}
Владислав Наумовf793fe32020-09-11 15:19:19 +0200443 Multiregional configuration: ${multiregionalMappings}
vnaumov33747e12020-05-04 17:35:20 +0200444 Service binaries fetching scheduled: ${fetchServiceBinaries}
Владислав Наумов74e2d6e2020-12-30 17:05:40 +0100445 Current weight of the demo run: ${demoWeight} (Used to manage lockable resources)
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400446 Bootstrap v2 scenario enabled: ${bootstrapV2Scenario}
Владислав Наумов81777472021-03-09 15:14:27 +0400447 Triggers: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
vnaumov33747e12020-05-04 17:35:20 +0200448 return [
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400449 osCloudLocation : openstackIMC,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100450 cdnConfig : cdnConfig,
451 proxyConfig : proxyConfig,
452 useMacOsSeedNode : seedMacOs,
453 deployChildEnabled : deployChild,
454 childDeployCustomRelease : customChildRelease,
455 upgradeChildEnabled : upgradeChild,
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400456 fullUpgradeChildEnabled : fullUpgradeChild,
Mikhail Ivanov38ee4382022-01-27 16:21:51 +0400457 mosDeployChildEnabled : mosDeployChild,
458 mosUpgradeChildEnabled : mosUpgradeChild,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100459 runChildConformanceEnabled : runChildConformance,
460 attachBYOEnabled : attachBYO,
461 upgradeBYOEnabled : upgradeBYO,
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100462 runBYOMatrixEnabled : runBYOMatrix,
Mikhail Ivanoveabc9d92021-12-30 16:40:14 +0400463 defaultBYOOs : defaultBYOOs,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100464 upgradeMgmtEnabled : upgradeMgmt,
slalov1202bba2022-04-20 22:31:07 +0400465 autoUpgradeMgmtEnabled : autoUpgradeMgmt,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100466 enableLMALoggingEnabled : enableLMALogging,
Sergey Lalovb2f60372022-09-20 23:58:47 +0400467 deployOsOnMosEnabled : deployOsOnMos,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100468 runUie2eEnabled : runUie2e,
Mikhail Ivanovf5e20af2022-03-24 15:38:06 +0400469 runUie2eNewEnabled : runUie2eNew,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100470 runMgmtConformanceEnabled : runMgmtConformance,
slalov0a4947a2022-06-09 15:44:35 +0400471 runMaintenanceTestEnabled : runMaintenanceTest,
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300472 runContainerregistryTestEnabled : runContainerregistryTest,
473 runMgmtDeleteMasterTestEnabled : runMgmtDeleteMasterTest,
474 runRgnlDeleteMasterTestEnabled : runRgnlDeleteMasterTest,
475 runChildDeleteMasterTestEnabled : runChildDeleteMasterTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100476 runLMATestEnabled : runLMATest,
477 runMgmtUserControllerTestEnabled : runMgmtUserControllerTest,
slalov574123e2022-04-06 17:24:19 +0400478 runProxyChildTestEnabled : runProxyChildTest,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100479 fetchServiceBinariesEnabled : fetchServiceBinaries,
480 awsOnDemandDemoEnabled : awsOnDemandDemo,
481 equinixOnDemandDemoEnabled : equinixOnDemandDemo,
482 equinixMetalV2OnDemandDemoEnabled : equinixMetalV2OnDemandDemo,
483 equinixMetalV2ChildDiffMetroEnabled : equinixMetalV2ChildDiffMetro,
484 equinixOnAwsDemoEnabled : equinixOnAwsDemo,
485 azureOnDemandDemoEnabled : azureOnDemandDemo,
486 azureOnAwsDemoEnabled : azureOnAwsDemo,
487 vsphereDemoEnabled : enableVsphereDemo,
488 vsphereOnDemandDemoEnabled : enableVsphereDemo, // TODO: remove after MCC 2.7 is out
489 bmDemoEnabled : enableBMDemo,
490 osDemoEnabled : enableOSDemo,
Alexandr Lovtsov36473f32022-04-28 15:46:09 +0300491 vsphereUbuntuEnabled : enableVsphereUbuntu,
Mikhail Ivanovbd1a9fd2022-03-29 21:36:21 +0400492 artifactsBuildEnabled : enableArtifactsBuild,
Sergey Zhemerdeeve67fb262022-06-21 00:49:34 +0300493 childOsBootFromVolume : childOsBootFromVolume,
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100494 multiregionalConfiguration : multiregionalMappings,
Ivan Berezovskiy29e72b72022-07-12 21:03:24 +0400495 demoWeight : demoWeight,
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300496 bootstrapV2Scenario : bootstrapV2Scenario,
497 equinixMetalV2Metro : equinixMetalV2Metro]
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200498}
499
500/**
501 * Determine management and regional setup for demo workflow scenario
502 *
503 *
Sergey Zhemerdeevdd31ce92022-07-19 14:15:22 +0300504 * @param: keyword (string) string , represents keyword trigger, specified in gerrit commit body, like `[multiregion aws,os]`
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200505 or Jenkins environment string variable in form like 'aws,os'
506 * @return (map)[
507 enabled: (bool),
508 * managementLocation: (string), //aws,os
509 * regionLocation: (string), //aws,os
510 * ]
511 */
512def multiregionWorkflowParser(keyword) {
Владислав Наумов8c0c39d2020-09-11 14:46:48 +0200513 def common = new com.mirantis.mk.Common()
eromanova8c702ae2021-12-24 17:43:12 +0400514 def supportedManagementProviders = ['os', 'aws', 'vsphere', 'equinix', 'equinixmetalv2', 'azure']
515 def supportedRegionalProviders = ['os', 'vsphere', 'equinix', 'equinixmetalv2', 'bm', 'azure', 'aws']
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200516
517 def clusterTypes = ''
Владислав Наумов38ed7bf2020-09-11 14:43:39 +0200518 if (keyword.toString().contains('multiregion')) {
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200519 common.infoMsg('Multiregion definition configured via gerrit keyword trigger')
520 clusterTypes = keyword[0][0].split('multiregion')[1].replaceAll('[\\[\\]]', '').trim().split(',')
521 } else {
522 common.infoMsg('Multiregion definition configured via environment variable')
523 clusterTypes = keyword.trim().split(',')
524 }
525
526 if (clusterTypes.size() != 2) {
Владислав Наумов482fb502020-10-30 17:59:27 +0100527 error("Incorrect regions definiton, valid scheme: [multiregion ${management}, ${region}], got: ${clusterTypes}")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200528 }
529
Владислав Наумовf793fe32020-09-11 15:19:19 +0200530 def desiredManagementProvider = clusterTypes[0].trim()
531 def desiredRegionalProvider = clusterTypes[1].trim()
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200532 if (! supportedManagementProviders.contains(desiredManagementProvider) || ! supportedRegionalProviders.contains(desiredRegionalProvider)) {
533 error("""unsupported management <-> regional bundle, available options:
Владислав Наумовf793fe32020-09-11 15:19:19 +0200534 management providers list - ${supportedManagementProviders}
535 regional providers list - ${supportedRegionalProviders}""")
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200536 }
537
538 return [
539 enabled: true,
540 managementLocation: desiredManagementProvider,
541 regionLocation: desiredRegionalProvider,
542 ]
vnaumov33747e12020-05-04 17:35:20 +0200543}
544
545/**
546 * Determine if custom si tests/pipelines refspec forwarded from gerrit change request
547
Владислав Наумов81777472021-03-09 15:14:27 +0400548 * 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 +0200549 * Used for components team to test component changes w/ custom SI refspecs using kaas/core deployment jobs
550 * Example scheme:
551 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
552 * manage refspecs through Jenkins Job Parameters
553 *
azvyagintseva12230a2020-06-05 13:24:06 +0300554 * @return (map)[* siTests: (string) final refspec for si-tests
vnaumov33747e12020-05-04 17:35:20 +0200555 * siPipelines: (string) final refspec for si-pipelines
556 * ]
557 */
558def checkCustomSIRefspec() {
vnaumovbdb90222020-05-04 18:25:50 +0200559 def common = new com.mirantis.mk.Common()
560
vnaumov33747e12020-05-04 17:35:20 +0200561 // Available triggers and its sane defaults
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200562 def siTestsRefspec = env.SI_TESTS_REFSPEC ?: 'master'
563 def siPipelinesRefspec = env.SI_PIPELINES_REFSPEC ?: 'master'
Владислав Наумов2db15e22020-07-14 12:29:22 +0200564 def siTestsDockerImage = env.SI_TESTS_DOCKER_IMAGE ?: 'docker-dev-kaas-local.docker.mirantis.net/mirantis/kaas/si-test'
565 def siTestsDockerImageTag = env.SI_TESTS_DOCKER_IMAGE_TAG ?: 'master'
Владислав Наумов6c2afff2020-06-05 12:54:53 +0200566 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
vnaumov33747e12020-05-04 17:35:20 +0200567
568 def siTestMatches = (commitMsg =~ /(\[si-tests-ref\s*refs\/changes\/.*?\])/)
569 def siPipelinesMatches = (commitMsg =~ /(\[si-pipelines-ref\s*refs\/changes\/.*?\])/)
570
571 if (siTestMatches.size() > 0) {
572 siTestsRefspec = siTestMatches[0][0].split('si-tests-ref')[1].replaceAll('[\\[\\]]', '').trim()
Владислав Наумов7f6c0882021-03-23 19:10:57 +0400573 siTestsDockerImage = "docker-review-local.docker.mirantis.net/review/kaas-si-test-${siTestsRefspec.split('/')[-2]}"
Владислав Наумов2db15e22020-07-14 12:29:22 +0200574 siTestsDockerImageTag = siTestsRefspec.split('/')[-1]
vnaumov33747e12020-05-04 17:35:20 +0200575 }
576 if (siPipelinesMatches.size() > 0) {
577 siPipelinesRefspec = siPipelinesMatches[0][0].split('si-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
578 }
579
580 common.infoMsg("""
581 kaas/si-pipelines will be fetched from: ${siPipelinesRefspec}
582 kaas/si-tests will be fetched from: ${siTestsRefspec}
Владислав Наумов2db15e22020-07-14 12:29:22 +0200583 kaas/si-tests as dockerImage will be fetched from: ${siTestsDockerImage}:${siTestsDockerImageTag}
Владислав Наумов81777472021-03-09 15:14:27 +0400584 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов2db15e22020-07-14 12:29:22 +0200585 return [siTests: siTestsRefspec, siPipelines: siPipelinesRefspec, siTestsDockerImage: siTestsDockerImage, siTestsDockerImageTag: siTestsDockerImageTag]
vnaumov33747e12020-05-04 17:35:20 +0200586}
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200587
Владислав Наумов9080f372020-06-08 13:57:16 +0200588/**
Владислав Наумов418042b2020-07-09 18:31:10 +0200589 * Parse additional configuration for kaas component CICD repo
Владислав Наумов30a516c2020-07-09 13:15:41 +0200590 * @param configurationFile (str) path to configuration file in yaml format
591 *
592 * @return (map)[ siTestsFeatureFlags (string) dedicated feature flags that will be used in SI tests,
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300593 * siTestsFeatureFlagsStable (string) dedicated feature flags that will be used in SI tests for deploying stable release
Владислав Наумов30a516c2020-07-09 13:15:41 +0200594 * ]
595 */
596def parseKaaSComponentCIParameters(configurationFile){
597 def common = new com.mirantis.mk.Common()
598 def ciConfig = readYaml file: configurationFile
599 def ciSpec = [
600 siTestsFeatureFlags: env.SI_TESTS_FEATURE_FLAGS ?: '',
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300601 siTestsFeatureFlagsStable: env.SI_TESTS_FEATURE_FLAGS_STABLE ?: '',
Владислав Наумов30a516c2020-07-09 13:15:41 +0200602 ]
603
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300604 // If exists and not empty
605 if (ciConfig.getOrDefault('si-tests-feature-flags', [])) {
Владислав Наумов30a516c2020-07-09 13:15:41 +0200606 common.infoMsg("""SI tests feature flags customization detected,
607 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlags']}] identification...""")
608
609 def ffMeta = ciSpec['siTestsFeatureFlags'].tokenize(',').collect { it.trim() }
610 ffMeta.addAll(ciConfig['si-tests-feature-flags'])
Владислав Наумов30a516c2020-07-09 13:15:41 +0200611
Владислав Наумовcb5ffca2020-07-14 15:28:36 +0200612 ciSpec['siTestsFeatureFlags'] = ffMeta.unique().join(',')
Владислав Наумов30a516c2020-07-09 13:15:41 +0200613 common.infoMsg("SI tests custom feature flags: ${ciSpec['siTestsFeatureFlags']}")
614 }
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300615 if (ciConfig.getOrDefault('si-tests-feature-flags-stable', [])) {
616 common.infoMsg("""SI tests feature flags for stable release customization detected,
617 results will be merged with existing flags: [${ciSpec['siTestsFeatureFlagsStable']}] identification...""")
618
619 def ffMeta = ciSpec['siTestsFeatureFlagsStable'].tokenize(',').collect { it.trim() }
620 ffMeta.addAll(ciConfig['si-tests-feature-flags-stable'])
621
622 ciSpec['siTestsFeatureFlagsStable'] = ffMeta.unique().join(',')
623 common.infoMsg("SI tests custom feature flags for stable release: ${ciSpec['siTestsFeatureFlagsStable']}")
624 }
Владислав Наумов30a516c2020-07-09 13:15:41 +0200625
626 common.infoMsg("""Additional ci configuration parsed successfully:
Alexandr Lovtsov1c78e452022-08-29 20:57:51 +0300627 siTestsFeatureFlags: ${ciSpec['siTestsFeatureFlags']}
628 siTestsFeatureFlagsStable: ${ciSpec['siTestsFeatureFlagsStable']}""")
Владислав Наумов30a516c2020-07-09 13:15:41 +0200629 return ciSpec
630}
631
632/**
633 * Determine if custom kaas core/pipelines refspec forwarded from gerrit change request
Владислав Наумов9080f372020-06-08 13:57:16 +0200634
Владислав Наумов81777472021-03-09 15:14:27 +0400635 * 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 +0200636 * Used for components team to test component changes w/ custom Core refspecs using kaas/core deployment jobs
637 * Example scheme:
638 * New CR pushed in kubernetes/lcm-ansible -> parsing it's commit body and get custom test refspecs -> trigger deployment jobs from kaas/core
639 * manage refspecs through Jenkins Job Parameters
640 *
641 * @return (map)[ core: (string) final refspec for kaas/core
642 * corePipelines: (string) final refspec for pipelines in kaas/core
643 * ]
644 */
645def checkCustomCoreRefspec() {
646 def common = new com.mirantis.mk.Common()
647
648 // Available triggers and its sane defaults
649 def coreRefspec = env.KAAS_CORE_REFSPEC ?: 'master'
650 // by default using value of GERRIT_REFSPEC parameter in *kaas/core jobs*
651 def corePipelinesRefspec = env.KAAS_PIPELINE_REFSPEC ?: '\$GERRIT_REFSPEC'
652 def commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
653
654 def coreMatches = (commitMsg =~ /(\[core-ref\s*refs\/changes\/.*?\])/)
655 def corePipelinesMatches = (commitMsg =~ /(\[core-pipelines-ref\s*refs\/changes\/.*?\])/)
656
657 if (coreMatches.size() > 0) {
658 coreRefspec = coreMatches[0][0].split('core-ref')[1].replaceAll('[\\[\\]]', '').trim()
659 }
660 if (corePipelinesMatches.size() > 0) {
661 corePipelinesRefspec = corePipelinesMatches[0][0].split('core-pipelines-ref')[1].replaceAll('[\\[\\]]', '').trim()
662 }
663
664 common.infoMsg("""
665 kaas/core will be fetched from: ${coreRefspec}
666 kaas/core pipelines will be fetched from: ${corePipelinesRefspec}
Владислав Наумов81777472021-03-09 15:14:27 +0400667 Keywords: https://gerrit.mcp.mirantis.com/plugins/gitiles/kaas/core/+/refs/heads/master/hack/ci-gerrit-keywords.md""")
Владислав Наумов9080f372020-06-08 13:57:16 +0200668 return [core: coreRefspec, corePipelines: corePipelinesRefspec]
669}
670
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200671
672/**
Владислав Наумов92288d92020-07-13 18:36:21 +0200673 * generate Jenkins Parameter objects from from text parameter with additonal kaas core context
674 * needed to forward inside kaas core set of jobs
675 *
676 * @param context (string) Representation of the string enviroment variables needed for kaas core jobs in yaml format
677 * @return (list)[ string(name: '', value: ''),
678 * ]
679 */
680def generateKaaSVarsFromContext(context) {
681 def common = new com.mirantis.mk.Common()
682 def parameters = []
683 def config = readYaml text: context
684
685 config.each { k,v ->
686 common.infoMsg("Custom KaaS Core context parameter: ${k}=${v}")
687 parameters.add(string(name: k, value: v))
688 }
689
690 return parameters
691}
692
693/**
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200694 * 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 +0400695 * 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 +0200696 * Used for components team to test component changes w/ customized SI tests/refspecs using kaas/core deployment jobs
697 *
Владислав Наумов418042b2020-07-09 18:31:10 +0200698 * @param: component (string) component name [iam, lcm, stacklight]
699 * @param: patchSpec (string) Patch for kaas/cluster releases in json format
700 * @param: configurationFile (string) Additional file for component repo CI config in yaml format
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200701 */
Владислав Наумов92288d92020-07-13 18:36:21 +0200702def triggerPatchedComponentDemo(component, patchSpec = '', configurationFile = '.ci-parameters.yaml', coreContext = '') {
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200703 def common = new com.mirantis.mk.Common()
704 // Determine if custom trigger keywords forwarded from gerrit
705 def triggers = checkDeploymentTestSuite()
706 // Determine SI refspecs
707 def siRefspec = checkCustomSIRefspec()
Владислав Наумов9080f372020-06-08 13:57:16 +0200708 // Determine Core refspecs
709 def coreRefspec = checkCustomCoreRefspec()
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200710
Владислав Наумов418042b2020-07-09 18:31:10 +0200711 // Determine component repo ci configuration
712 def ciSpec = [:]
713 def componentFeatureFlags = env.SI_TESTS_FEATURE_FLAGS ?: ''
714 if (fileExists(configurationFile)) {
715 common.infoMsg('Component CI configuration file detected, parsing...')
716 ciSpec = parseKaaSComponentCIParameters(configurationFile)
717 componentFeatureFlags = ciSpec['siTestsFeatureFlags']
718 } else {
719 common.warningMsg('''Component CI configuration file is not exists,
Владислав Наумовc17dd552020-07-29 17:07:38 +0200720 several code-management features may be unavailable,
Владислав Наумов92288d92020-07-13 18:36:21 +0200721 follow https://mirantis.jira.com/wiki/spaces/QA/pages/2310832276/SI-tests+feature+flags#%5BUpdated%5D-Using-a-feature-flag
722 to create the configuration file''')
Владислав Наумов418042b2020-07-09 18:31:10 +0200723 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400724
725 def platforms = []
726 if (component == 'ipam' && triggers.vsphereDemoEnabled) {
727 // Currently only vsphere demo is required for IPAM component
728 platforms.add('vsphere')
729 } else {
730 if (triggers.osDemoEnabled) {
731 platforms.add('openstack')
732 }
733 if (triggers.awsOnDemandDemoEnabled) {
734 platforms.add('aws')
735 }
736 if (triggers.equinixOnDemandDemoEnabled) {
737 platforms.add('equinix')
738 }
Владислав Наумов144956f2021-10-14 17:49:19 +0200739 if (triggers.equinixMetalV2OnDemandDemoEnabled) {
740 platforms.add('equinixmetalv2')
741 }
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200742 if (triggers.azureOnDemandDemoEnabled) {
743 platforms.add('azure')
744 }
Ivan Berezovskiyb0229d02021-05-17 16:55:18 +0400745 if (triggers.vsphereDemoEnabled) {
746 platforms.add('vsphere')
747 }
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400748 }
749
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200750 def jobs = [:]
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200751 def parameters = [
Владислав Наумов9080f372020-06-08 13:57:16 +0200752 string(name: 'GERRIT_REFSPEC', value: coreRefspec.core),
753 string(name: 'KAAS_PIPELINE_REFSPEC', value: coreRefspec.corePipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200754 string(name: 'SI_TESTS_REFSPEC', value: siRefspec.siTests),
Владислав Наумов418042b2020-07-09 18:31:10 +0200755 string(name: 'SI_TESTS_FEATURE_FLAGS', value: componentFeatureFlags),
Владислав Наумов2db15e22020-07-14 12:29:22 +0200756 string(name: 'SI_TESTS_DOCKER_IMAGE', value: siRefspec.siTestsDockerImage),
757 string(name: 'SI_TESTS_DOCKER_IMAGE_TAG', value: siRefspec.siTestsDockerImageTag),
Владислав Наумов4a5c3242020-06-08 14:36:11 +0200758 string(name: 'SI_PIPELINES_REFSPEC', value: siRefspec.siPipelines),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200759 string(name: 'CUSTOM_RELEASE_PATCH_SPEC', value: patchSpec),
Mikhail Ivanov74504372021-05-21 17:01:06 +0400760 string(name: 'KAAS_CHILD_CLUSTER_RELEASE_NAME', value: triggers.childDeployCustomRelease),
Mikhail Ivanovb6283f72021-11-24 18:34:57 +0400761 string(name: 'OPENSTACK_CLOUD_LOCATION', value: triggers.osCloudLocation),
Владислав Наумовb8305e22021-02-10 17:23:12 +0100762 booleanParam(name: 'OFFLINE_MGMT_CLUSTER', value: triggers.proxyConfig['mgmtOffline']),
Владислав Наумовf8f23fa2021-04-01 16:57:52 +0200763 booleanParam(name: 'OFFLINE_CHILD_CLUSTER', value: triggers.proxyConfig['childOffline']),
Владислав Наумов257ea132021-04-14 14:44:13 +0200764 booleanParam(name: 'PROXY_CHILD_CLUSTER', value: triggers.proxyConfig['childProxy']),
Владислав Наумов44c64b72020-12-04 20:22:53 +0100765 booleanParam(name: 'SEED_MACOS', value: triggers.useMacOsSeedNode),
Владислав Наумов080d9412020-07-29 13:05:14 +0200766 booleanParam(name: 'UPGRADE_MGMT_CLUSTER', value: triggers.upgradeMgmtEnabled),
slalov1202bba2022-04-20 22:31:07 +0400767 booleanParam(name: 'AUTO_UPGRADE_MCC', value: triggers.autoUpgradeMgmtEnabled),
Victor Ryzhenkind2b7b662021-08-23 14:18:38 +0400768 booleanParam(name: 'ENABLE_LMA_LOGGING', value: triggers.enableLMALoggingEnabled),
Sergey Lalovb2f60372022-09-20 23:58:47 +0400769 booleanParam(name: 'DEPLOY_OS_ON_MOS', value: triggers.deployOsOnMosEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200770 booleanParam(name: 'RUN_UI_E2E', value: triggers.runUie2eEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200771 booleanParam(name: 'RUN_MGMT_CFM', value: triggers.runMgmtConformanceEnabled),
slalov0a4947a2022-06-09 15:44:35 +0400772 booleanParam(name: 'RUN_MAINTENANCE_TEST', value: triggers.runMaintenanceTestEnabled),
773 booleanParam(name: 'RUN_CONTAINER_REGISTRY_TEST', value: triggers.runContainerregistryTestEnabled),
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +0300774 booleanParam(name: 'RUN_MGMT_DELETE_MASTER_TEST', value: triggers.runMgmtDeleteMasterTestEnabled),
775 booleanParam(name: 'RUN_RGNL_DELETE_MASTER_TEST', value: triggers.runRgnlDeleteMasterTestEnabled),
776 booleanParam(name: 'RUN_CHILD_DELETE_MASTER_TEST', value: triggers.runChildDeleteMasterTestEnabled),
Владислав Наумов9cec55d2021-08-03 15:00:59 +0200777 booleanParam(name: 'RUN_LMA_TEST', value: triggers.runLMATestEnabled),
Vladyslav Drokc4f9c1b2021-07-22 15:34:24 +0200778 booleanParam(name: 'RUN_MGMT_USER_CONTROLLER_TEST', value: triggers.runMgmtUserControllerTestEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200779 booleanParam(name: 'DEPLOY_CHILD_CLUSTER', value: triggers.deployChildEnabled),
780 booleanParam(name: 'UPGRADE_CHILD_CLUSTER', value: triggers.upgradeChildEnabled),
Sergey Lalovc1cb49f2022-09-27 01:16:25 +0400781 booleanParam(name: 'FULL_UPGRADE_CHILD_CLUSTER', value: triggers.fullUpgradeChildEnabled),
slalov574123e2022-04-06 17:24:19 +0400782 booleanParam(name: 'RUN_PROXY_CHILD_TEST', value: triggers.runProxyChildTestEnabled),
Владислав Наумов0dc99252020-11-13 13:30:48 +0100783 booleanParam(name: 'ATTACH_BYO', value: triggers.attachBYOEnabled),
Владислав Наумовcdbd84e2020-12-01 16:51:09 +0100784 booleanParam(name: 'UPGRADE_BYO', value: triggers.upgradeBYOEnabled),
Vladislav Naumov7930ab22021-11-22 18:24:24 +0100785 booleanParam(name: 'RUN_BYO_MATRIX', value: triggers.runBYOMatrixEnabled),
Владислав Наумов080d9412020-07-29 13:05:14 +0200786 booleanParam(name: 'RUN_CHILD_CFM', value: triggers.runChildConformanceEnabled),
Ivan Berezovskiycbf9eeb2021-03-22 15:57:32 +0400787 booleanParam(name: 'ALLOW_AWS_ON_DEMAND', value: triggers.awsOnDemandDemoEnabled),
Владислав Наумовe021b022021-05-06 11:26:38 +0200788 booleanParam(name: 'ALLOW_EQUINIX_ON_DEMAND', value: triggers.equinixOnDemandDemoEnabled),
Владислав Наумов82305e92021-10-14 20:45:20 +0200789 booleanParam(name: 'ALLOW_EQUINIXMETALV2_ON_DEMAND', value: triggers.equinixMetalV2OnDemandDemoEnabled),
Vladislav Naumov42b71dc2021-11-22 13:09:42 +0100790 booleanParam(name: 'EQUINIXMETALV2_CHILD_DIFF_METRO', value: triggers.equinixMetalV2ChildDiffMetroEnabled),
eromanovad3397512021-04-01 20:19:19 +0400791 booleanParam(name: 'EQUINIX_ON_AWS_DEMO', value: triggers.equinixOnAwsDemoEnabled),
Владислав Наумовc52dd9d2021-06-28 16:27:29 +0200792 booleanParam(name: 'ALLOW_AZURE_ON_DEMAND', value: triggers.azureOnDemandDemoEnabled),
Владислав Наумов2d3db332021-06-15 15:19:19 +0200793 booleanParam(name: 'AZURE_ON_AWS_DEMO', value: triggers.azureOnAwsDemoEnabled),
Sergey Zhemerdeev9074f6e2022-06-07 12:03:16 +0300794 booleanParam(name: 'VSPHERE_DEPLOY_UBUNTU', value: triggers.vsphereUbuntuEnabled),
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200795 ]
Владислав Наумов92288d92020-07-13 18:36:21 +0200796
Владислав Наумов765f3bd2020-09-07 18:09:24 +0200797 // customize multiregional demo
798 if (triggers.multiregionalConfiguration.enabled) {
799 parameters.add(string(name: 'MULTIREGION_SETUP',
800 value: "${triggers.multiregionalConfiguration.managementLocation},${triggers.multiregionalConfiguration.regionLocation}"
801 ))
802 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200803
Владислав Наумов92288d92020-07-13 18:36:21 +0200804 // Determine component team custom context
805 if (coreContext != '') {
806 common.infoMsg('Additional KaaS Core context detected, will be forwarded into kaas core cicd...')
807 def additionalParameters = generateKaaSVarsFromContext(coreContext)
Владислав Наумовbef51a92020-10-01 17:36:51 +0200808 parameters.addAll(additionalParameters)
Владислав Наумов92288d92020-07-13 18:36:21 +0200809 }
810
Владислав Наумовaa430612020-06-08 17:18:31 +0200811 def jobResults = []
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400812
813 platforms.each { platform ->
814 jobs["kaas-core-${platform}-patched-${component}"] = {
Vladislav Naumov5313a202021-04-07 17:13:39 +0000815 try {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400816 common.infoMsg("Deploy: patched KaaS demo with ${platform} provider")
817 def job_info = build job: "kaas-testing-core-${platform}-workflow-${component}", parameters: parameters, wait: true
818 def build_description = job_info.getDescription()
819 def build_result = job_info.getResult()
Vladislav Naumov5313a202021-04-07 17:13:39 +0000820 jobResults.add(build_result)
Владислав Наумовd044e842020-06-17 15:33:43 +0200821
Vladislav Naumov5313a202021-04-07 17:13:39 +0000822 if (build_description) {
823 currentBuild.description += build_description
824 }
825 } finally {
Ivan Berezovskiy91ede502021-05-13 21:05:36 +0400826 common.infoMsg("Patched KaaS demo with ${platform} provider finished")
Vladislav Naumov5313a202021-04-07 17:13:39 +0000827 }
828 }
829 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200830
831 common.infoMsg('Trigger KaaS demo deployments according to defined provider set')
Владислав Наумов37f7f842021-03-09 16:08:39 +0400832 if (jobs.size() == 0) {
833 error('No demo jobs matched with keywords, execution will be aborted, at least 1 provider should be enabled')
834 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200835 // Limit build concurency workaround examples: https://issues.jenkins-ci.org/browse/JENKINS-44085
836 parallel jobs
Владислав Наумовaa430612020-06-08 17:18:31 +0200837
838 if (jobResults.contains('FAILURE')) {
Владислав Наумовf86b1112020-06-09 14:04:48 +0200839 common.infoMsg('One of parallel downstream jobs is failed, mark executor job as failed')
Владислав Наумовaa430612020-06-08 17:18:31 +0200840 currentBuild.result = 'FAILURE'
841 }
Владислав Наумов2a982ff2020-06-02 19:06:46 +0200842}
Владислав Наумов30a516c2020-07-09 13:15:41 +0200843
844
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400845/**
846 * Function currently supported to be called from aws or vsphere demos. It gets particular demo context
Владислав Наумов33e1e812021-08-17 17:09:25 +0200847 * and generate proper lockResources data and netMap data for vsphere,equinix related clusters.
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400848 *
849 * @param: callBackDemo (string) Demo which requested to generate lockResources [aws or vsphere]
850 * @param: triggers (map) Custom trigger keywords forwarded from gerrit
851 * @param: multiregionalConfiguration (map) Multiregional configuration
852 * @return (map) Return aggregated map with lockResources and netMap
853 */
854
855
856def generateLockResources(callBackDemo, triggers) {
857 def common = new com.mirantis.mk.Common()
Владислав Наумов33e1e812021-08-17 17:09:25 +0200858 def netMap = [
859 vsphere: [:],
860 equinix: [:],
861 ]
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400862 // Define vsphere locklabels with initial quantity
863 def lockLabels = [
864 vsphere_networking_core_ci: 0,
865 vsphere_offline_networking_core_ci: 0,
866 ]
867 def deployChild = triggers.deployChildEnabled
slalov27833272022-06-30 02:13:50 +0400868 def testUiVsphere = triggers.runUie2eEnabled
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400869 def multiregionConfig = triggers.multiregionalConfiguration
870 def runMultiregion = multiregionConfig.enabled
871
872 // Generate vsphere netMap and lockLabels based on demo context
873 switch (callBackDemo) {
874 case 'aws':
875 // Add aws specific lock label with quantity calculated based on single mgmt deploy or mgmt + child
876 lockLabels['aws_core_ci_queue'] = triggers.demoWeight
Sergey Kolekonovf4c1f492022-02-03 14:44:45 +0400877 if (triggers.runBYOMatrixEnabled) { lockLabels['aws_core_ci_queue'] += 6 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400878
879 // Define netMap for Vsphere region
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400880 if (runMultiregion && multiregionConfig.managementLocation == 'aws') {
881 if (multiregionConfig.regionLocation == 'vsphere') {
882 if (deployChild) {
883 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
884 }
885 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400886 }
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400887
888 if (multiregionConfig.regionLocation == 'azure') {
889 lockLabels['azure_core_ci_queue'] = 1
890 if (deployChild) {
891 lockLabels['azure_core_ci_queue'] += 1
892 }
893 }
894 }
895 if (triggers.azureOnAwsDemoEnabled) {
896 lockLabels['azure_core_ci_queue'] = 1
897 }
898
899 if (triggers.equinixOnAwsDemoEnabled) {
900 lockLabels['equinix_core_ci_queue'] = 1
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400901 }
902 break
903 case 'vsphere':
Владислав Наумов33e1e812021-08-17 17:09:25 +0200904 addToProviderNetMap(netMap, 'vsphere', 'mgmt')
slalov27833272022-06-30 02:13:50 +0400905 if (deployChild || testUiVsphere) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200906 addToProviderNetMap(netMap, 'vsphere', 'child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400907 }
908 if (runMultiregion && multiregionConfig.managementLocation == 'vsphere' &&
909 multiregionConfig.regionLocation == 'vsphere') {
910 if (deployChild) {
Владислав Наумов33e1e812021-08-17 17:09:25 +0200911 addToProviderNetMap(netMap, 'vsphere', 'regional-child')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400912 }
Владислав Наумов33e1e812021-08-17 17:09:25 +0200913 addToProviderNetMap(netMap, 'vsphere', 'region')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400914 }
915 break
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400916 case 'azure':
917 lockLabels['azure_core_ci_queue'] = triggers.demoWeight
918 if (runMultiregion && multiregionConfig.managementLocation == 'azure') {
919 if (multiregionConfig.regionLocation == 'aws') {
920 lockLabels['aws_core_ci_queue'] = 1
921 if (deployChild) {
922 lockLabels['aws_core_ci_queue'] += 1
923 }
924 }
925
926 if (multiregionConfig.regionLocation == 'equinix') {
927 lockLabels['equinix_core_ci_queue'] = 1
928 if (deployChild) {
929 lockLabels['equinix_core_ci_queue'] +=1
930 }
931 }
932 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400933 default:
Mikhail Ivanov90a27fa2022-05-30 15:18:24 +0400934 error('Supposed to be called from aws, azure or vsphere demos only')
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400935 }
936
937 // Checking gerrit triggers and manage lock label quantity and network types in case of Offline deployment
938 // Vsphere labels only
Владислав Наумов33e1e812021-08-17 17:09:25 +0200939 netMap['vsphere'].each { clusterType, netConfig ->
940 if (triggers.proxyConfig["${clusterType}Offline"] == true ||
941 (clusterType == 'regional-child' && triggers.proxyConfig['childOffline'] == true) ||
942 (clusterType == 'region' && triggers.proxyConfig['mgmtOffline'])) {
943
944 netMap['vsphere'][clusterType]['netName'] = 'offline'
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400945 lockLabels['vsphere_offline_networking_core_ci']++
946 } else {
947 lockLabels['vsphere_networking_core_ci']++
948 }
949 }
950
951 // generate lock metadata
952 def lockResources = []
953 lockLabels.each { label, quantity ->
954 if (quantity > 0) {
955 def res = [
956 label: label,
957 quantity: quantity,
958 ]
959 lockResources.add(res)
960 }
961 }
962
963 common.infoMsg("""Generated vsphere netMap: ${netMap}
964 Generated lockResources: ${lockResources}""")
965
966 return [
967 netMap: netMap,
968 lockResources: lockResources,
969 ]
970}
971
972/**
973 * Function gets vsphere netMap or empty map and adds new vsphere clusterType with default netName
974 * and empty rangeConfig to the this map.
975 *
Владислав Наумов33e1e812021-08-17 17:09:25 +0200976 * @param: netMap (string) vsphere, equinix netMap or empty map
977 * @param: provider (string) provider type
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400978 * @param: clusterType (string) Vsphere cluster type
979 */
980
Владислав Наумов33e1e812021-08-17 17:09:25 +0200981def addToProviderNetMap (netMap, provider, clusterType) {
982 switch (provider) {
983 case 'equinix':
984 netMap[provider][clusterType] = [
985 vlanConfig: '',
986 ]
987 break
988 case 'vsphere':
989 netMap[provider][clusterType] = [
990 netName: 'default',
991 rangeConfig: '',
992 ]
993 break
994 default:
995 error('Net map locks supported for Equinix/Vsphere providers only')
996 }
Stanislav Riazanov78fa7df2021-05-28 20:28:59 +0400997}
Dmitry Teselkinfce71aa2022-03-05 19:36:52 +0300998
999/**
1000* getCIKeywordsFromCommitMsg parses commit message and returns all gerrit keywords with their values as a list of maps.
1001* Each element (map) contains keys 'key' for keyword name and 'value' for its value.
1002* If keyword contains only 'key' part then 'value' is boolean True.
1003* This function does not perform keywords validation.
1004* First line of a commit message is ignored.
1005* To use '[' or ']' characters inside keyword prepend it with backslash '\'.
1006* TODO: Remove backslash chars from values if they prepend '[' or ']'.
1007**/
1008
1009List getCIKeywordsFromCommitMsg() {
1010 String commitMsg = env.GERRIT_CHANGE_COMMIT_MESSAGE ? new String(env.GERRIT_CHANGE_COMMIT_MESSAGE.decodeBase64()) : ''
1011 List commitMsgLines = commitMsg.split('\n')
1012 List keywords = []
1013 if (commitMsgLines.size() < 2) {
1014 return keywords
1015 }
1016
1017 String commitMsgBody = commitMsgLines[1..-1].join('\n')
1018
1019 // Split commit message body to chunks using '[' or ']' as delimiter,
1020 // ignoring them if prepended by backslash (regex negative lookbehind).
1021 // Resulting list will have chunks between '[' and ']' at odd indexes.
1022 List parts = commitMsgBody.split(/(?<!\\)[\[\]]/)
1023
1024 // Iterate chunks by odd indexes only, trim values and split to
1025 // <key> / <value> pair where <key> is the part of a sting before the first
1026 // whitespace delimiter, and <value> is the rest (may include whitespaces).
1027 // If there is no whitespace in the string then this is a 'switch'
1028 // and <value> will be boolean True.
1029 for (i = 1; i < parts.size(); i += 2) {
1030 def (key, value) = (parts[i].trim().split(/\s+/, 2) + [true, ])[0..1]
1031 keywords.add(['key': key, 'value': value])
1032 }
1033
1034 return keywords
1035}
1036
1037/**
1038* getJobsParamsFromCommitMsg parses list of CI keywords and returns values of 'job-params' keyword
1039* that were specified for given job name. `job-params` keyword has the following structure
1040*
1041* [job-params <job name> <parameter name> <parameter value>]
1042*
1043* Return value is a Map that contains those parameters using the following structure:
1044*
1045* <job name>:
1046* <parameter name>: <parameter value>
1047*
1048**/
1049Map getJobsParamsFromCommitMsg() {
1050 List keywords = getCIKeywordsFromCommitMsg()
1051
1052 List jobsParamsList = []
1053 keywords.findAll{ it.key == 'job-params' }.collect(jobsParamsList) {
1054 def (name, params) = (it['value'].split(/\s+/, 2) + [null, ])[0..1]
1055 def (key, value) = params.split(/\s+/, 2)
1056 ['name': name, 'key': key, 'value': value]
1057 }
1058
1059 Map jobsParams = jobsParamsList.inject([:]) { result, it ->
1060 if (!result.containsKey(it.name)) {
1061 result[it.name] = [:]
1062 }
1063 result[it.name][it.key] = it.value
1064 result
1065 }
1066
1067 return jobsParams
1068}
1069
1070
1071/**
1072* getJobParamsFromCommitMsg returns key:value Map of parameters set for a job in commit message.
1073* It uses getJobsParamsFromCommitMsg to get all parameters from commit message and then
1074* uses only those parametes that were set to all jobs (with <job name> == '*') or to
1075* a particular job. Parameters set to a particular job have higher precedence.
1076*
1077* Return value is a Map that contains those parameters:
1078*
1079* <parameter name>: <parameter value>
1080*
1081**/
1082Map getJobParamsFromCommitMsg(String jobName) {
1083 jobsParams = getJobsParamsFromCommitMsg()
1084 jobParams = jobsParams.getOrDefault('*', [:])
1085 if (jobName) {
1086 jobParams.putAll(jobsParams.getOrDefault(jobName, [:]))
1087 }
1088 return jobParams
1089}
azvyagintsevc17d14b2022-06-06 19:06:33 +03001090
1091/** Getting test scheme from text, which should be
1092Imput example:
1093text="""
1094 DATA
1095
1096 kaas_bm_test_schemas:
1097 KAAS_RELEASES_REFSPEC: ''
1098 KEY: VAL
1099
1100 DATA
1101 """
1102
1103 Call: parseTextForTestSchemas(['text' : text,'keyLine' : 'kaas_bm_test_schemas'])
1104
1105 Return:
1106 ['KAAS_RELEASES_REFSPEC': '', 'KEY' : 'VAL']
1107 **/
1108def parseTextForTestSchemas(Map opts) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001109 String text = opts.getOrDefault('text', '')
azvyagintsevc17d14b2022-06-06 19:06:33 +03001110 String keyLine = opts.getOrDefault('keyLine', '')
1111 Map testScheme = [:]
1112 if (!text || !keyLine) {
azvyagintsevd96aac22022-06-10 14:23:26 +03001113 return testScheme
azvyagintsevc17d14b2022-06-06 19:06:33 +03001114 }
1115 if (text =~ /\n$keyLine\n.*/) {
1116 def common = new com.mirantis.mk.Common()
1117 try {
1118 String regExp = '\\n' + keyLine + '\\n'
1119 // regexep block must be followed by empty line
1120 testScheme = readYaml text: "${text.split(regExp)[1].split('\n\n')[0]}"
1121 common.infoMsg("parseTextForTestSchemas result:\n" + testScheme)
1122 common.mergeEnv(env, toJson(testScheme))
1123 }
1124 catch (Exception e) {
1125 common.errorMsg("There is an error occured during parseTextForTestSchemas execution:\n${e}")
1126 throw e
1127 }
1128 }
azvyagintsevd96aac22022-06-10 14:23:26 +03001129 return testScheme
Dmitriy Kasyanov5f910e62022-02-11 14:57:05 +03001130}
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001131
1132
1133/**
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001134* getEquinixFacilityWithCapacity returns list of Equinix facilities using specified
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001135* instance type (nodeType), desired count of facilities (facilityCount) and
1136* instances (nodeCount) in a facility using specified matal version.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001137* Function downloads metal CLI from the
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001138* https://artifactory.mcp.mirantis.net:443/artifactory/binary-dev-kaas-local/core/bin/mirror/metal-${version}-linux
1139* 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 +03001140* Non-empty list is shuffled.
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001141*
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001142* @param: facilityCount (int) Desired count of facilities
1143* @param: nodeCount (int) Desired count of instances
1144* @param: nodeType (string) Instance type
1145* @param: version (string) Metal version to use
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001146* @return ([]string) List of selected facilities
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001147*
1148**/
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001149def getEquinixFacilityWithCapacity(facilityCount = 1, nodeCount = 50, nodeType = 'c3.small.x86', version = '0.9.0') {
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001150 def common = new com.mirantis.mk.Common()
1151 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 +03001152 def metal = './metal --config metal.yaml'
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001153 def facility = []
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001154 def out = ''
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001155 def retries = 3 // number of retries
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001156 def i = 0
1157 def delay = 60 // 1 minute sleep
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001158 def excludeFacility = [] // list of facilities to exclude from selection
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001159 try {
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001160 if (excludeFacility.size() > 0) {
1161 common.infoMsg("Excluded facilities: ${excludeFacility}")
1162 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001163 sh "curl -o metal -# ${metalUrl} && chmod +x metal"
1164 withCredentials([string(credentialsId: env.KAAS_EQUINIX_API_TOKEN, variable: 'KAAS_EQUINIX_API_TOKEN')]) {
1165 sh 'echo "project-id: ${KAAS_EQUINIX_PROJECT_ID}\ntoken: ${KAAS_EQUINIX_API_TOKEN}" >metal.yaml'
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001166 }
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001167 while (facility.size() < facilityCount && i < retries) {
1168 common.infoMsg("Selecting ${facilityCount} available Equinix facilities with free ${nodeCount} ${nodeType} hosts, try ${i+1}/${retries} ...")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001169 if (i > 0 ) { // skip sleep on first step
1170 sleep(delay)
1171 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001172 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()
1173 facility = out.tokenize(',')
Sergey Zhemerdeevb3575342022-10-04 11:02:19 +03001174 facility -= excludeFacility
Sergey Zhemerdeev46080fa2022-10-06 12:34:12 +03001175 if (facility.size() < facilityCount) {
1176 nodeCount -= 10
1177 // We need different metros for the [equinixmetalv2-child-diff-metro] case, facility[][0, 1] contains a metro name
1178 } else if (facility.size() == 2 && facility[0][0, 1] == facility[1][0, 1]) {
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001179 nodeCount -= 10
1180 }
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001181 i++
1182 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001183 if (facility.size() > 0) {
1184 f = facility.size() > 1 ? "${facility[0]},${facility[1]}" : "${facility[0]}"
1185 sh "${metal} capacity check -P ${nodeType} -f ${f} -q ${nodeCount}"
Sergey Zhemerdeevbcccb912022-08-25 14:26:52 +03001186 }
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001187 } catch (Exception e) {
1188 common.errorMsg "Exception: '${e}'"
1189 return []
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001190 } finally {
1191 sh 'rm metal.yaml'
1192 }
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001193 if (facility.size() > 0) {
Sergey Zhemerdeev15aa8602022-10-13 11:10:02 +03001194 Collections.shuffle(facility)
Sergey Zhemerdeevb68bf612022-09-12 13:12:32 +03001195 common.infoMsg("Selected facilities: ${facility}")
Sergey Zhemerdeev495ba582022-08-16 16:31:43 +03001196 } else {
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001197 common.warningMsg('No any facilities have been selected !!! :(')
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001198 }
Sergey Zhemerdeevde949bf2022-09-14 15:44:33 +03001199 return facility
Sergey Zhemerdeev31569082022-08-10 10:13:19 +03001200}
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001201
1202
1203/**
1204 * genCommandLine prepares command line for artifactory-replication
1205 * command using legacy environment variables
1206 *
1207 * @return: (string) Prepared command line
1208 */
1209def genCommandLine() {
1210 def envToParam = [
1211 'DESTINATION_USER': '-dst-user',
1212 'ARTIFACT_FILTER': '-artifact-filter',
1213 'ARTIFACT_FILTER_PROD': '-artifact-filter-prod',
1214 'ARTIFACT_TYPE': '-artifact-type',
1215 'BINARY_CLEAN': '-bin-cleanup',
1216 'BINARY_CLEAN_KEEP_DAYS': '-bin-clean-keep-days',
1217 'BINARY_CLEAN_PREFIX': '-bin-clean-prefix',
1218 'BUILD_URL': '-slack-build-url',
1219 'CHECK_REPOS': '-check-repos',
1220 'DESTINATION_REGISTRY': '-dst-repo',
1221 'DESTINATION_REGISTRY_TYPE': '-dst-repo-type',
1222 'DOCKER_CLEAN': '-cleanup',
1223 'DOCKER_REPO_PREFIX': '-docker-repo-prefix',
1224 'DOCKER_TAG': '-docker-tag',
1225 'FORCE': '-force',
1226 'HELM_CDN_DOMAIN': '-helm-cdn-domain',
1227 'SLACK_CHANNEL': '-slack-channel',
1228 'SLACK_USER': '-slack-user',
1229 'SOURCE_REGISTRY': '-src-repo',
1230 'SOURCE_REGISTRY_TYPE': '-src-repo-type',
1231 'SYNC_PATTERN': '-sync-pattern'
1232 ]
1233 def cmdParams = ''
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001234 def isCheckClean = false
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001235 for (e in envToParam) {
1236 if (env[e.key] == null) {
1237 continue
1238 }
1239 if (e.key == 'CHECK_REPOS' || e.key == 'DOCKER_CLEAN') {
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001240 // Avoid CHECK_REPOS=true and DOCKER_CLEAN=true
1241 if (env[e.key].toBoolean() && !isCheckClean) {
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001242 cmdParams += e.value + ' '
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001243 isCheckClean = true
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001244 }
1245 } else if (e.key == 'FORCE') {
1246 if (env[e.key].toBoolean()) {
1247 cmdParams += e.value + ' '
1248 }
1249 } else {
Sergey Zhemerdeeve2926cd2022-08-29 15:28:47 +03001250 cmdParams += "${e.value} '${env[e.key]}' "
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001251 }
1252 }
Sergey Zhemerdeev88d1c3d2022-08-31 16:37:48 +03001253 // No any check or clean was specified - take a default action
1254 if (!isCheckClean) {
1255 cmdParams += '-replicate'
1256 }
Sergey Zhemerdeev2a273342022-08-18 12:06:11 +03001257 return cmdParams
1258}
Sergey Kolekonov0e60a942022-09-05 13:02:22 +04001259
1260/**
1261 * custom scheduling algorithm
1262 * it ensures that builds of the same job are distributed as much as possible between different nodes
1263 * @param label (string) desired node label
1264 * @return: (string) node name
1265 */
1266def schedule (label='docker') {
1267 def common = new com.mirantis.mk.Common()
1268 def freeNodes = []
1269 def nodesMap = [:]
1270
1271 // filter nodes with the specified label and at least one free executor
1272 timeout(time: 30, unit: 'MINUTES') {
1273 while (!freeNodes) {
1274 freeNodes = jenkins.model.Jenkins.instance.computers.findAll { node ->
1275 label in node.getAssignedLabels().collect { it.name } &&
1276 node.isPartiallyIdle()
1277 }
1278 if (!freeNodes) {
1279 echo 'No nodes available for scheduling, retrying...'
1280 sleep 30
1281 }
1282 }
1283 }
1284
1285 // generate a map of nodes matching other criteria
1286 for (node in freeNodes) {
1287 // sameJobExecutors is the number of executors running the same job as the calling one
1288 sameJobExecutors = node.getExecutors() // get all executors
1289 .collect { executor -> executor.getCurrentExecutable() } // get running "threads"
1290 .collect { thread -> thread?.displayName } // filter job names from threads
1291 .minus(null) // null = empty executors, remove them from the list
1292 .findAll { it.contains(env.JOB_NAME) } // filter the same jobs as the calling one
1293 .size()
1294
1295 // calculate busy executors, we don't want to count "sameJobExecutors" twice
1296 totalBusyExecutors = node.countBusy() - sameJobExecutors
1297 // generate the final map which contains nodes matching criteria with their load score
1298 // builds of the same jobs have x10 score, all others x1
1299 nodesMap += ["${node.getName()}" : sameJobExecutors * 10 + totalBusyExecutors]
1300 }
1301
1302 // return the least loaded node
1303 return common.SortMapByValueAsc(nodesMap).collect { it.key }[0]
1304}