blob: 601ba8c6bd5ef956115a257859cf29f3796c7de7 [file] [log] [blame]
Roman Lubianyi26701f52021-11-09 17:32:34 +02001package com.mirantis.mcp
2
3/**
4 * Run check with parameters
5 *
6 * @param salt com.mirantis.mk.Salt object
7 * @param venvPepper venvPepper
8 * @param cluster_name MCP cluster name
9 * @param raise_exc Raise exception or return status of check
10**/
11
12def check_34406(salt, venvPepper, String cluster_name, Boolean raise_exc) {
13 def sphinxpasswordPillar = salt.getPillar(venvPepper, 'I@salt:master', '_param:sphinx_proxy_password_generated').get("return")[0].values()[0]
14 def waStatus = [prodId: "PROD-34406", isFixed: "", waInfo: ""]
15 if (sphinxpasswordPillar == '' || sphinxpasswordPillar == 'null' || sphinxpasswordPillar == null) {
16 waStatus.isFixed = "Work-around should be applied manually"
17 waStatus.waInfo = "See https://docs.mirantis.com/mcp/q4-18/mcp-release-notes/mu/mu-9/mu-9-addressed/mu-9-dtrain/mu-9-dt-manual.html#i-34406 for more info"
18 if (raise_exc) {
19 error('Sphinx password is not defined.\n' +
20 waStatus.waInfo)
21 }
22 return waStatus
23 }
24 waStatus.isFixed = "Work-around for PROD-34406 already applied, nothing todo"
25 return waStatus
26}
27
28def check_34645(salt, venvPepper, String cluster_name, Boolean raise_exc) {
29 def updatecellsPillar = salt.getPillar(venvPepper, 'I@nova:controller', 'nova:controller:update_cells').get("return")[0].values()[0]
30 def waStatus = [prodId: "PROD-34645", isFixed: "", waInfo: ""]
31 if (updatecellsPillar.toString().toLowerCase() == 'false') {
32 waStatus.isFixed = "Work-around should be applied manually"
33 waStatus.waInfo = "See https://docs.mirantis.com/mcp/q4-18/mcp-operations-guide/openstack-operations/disable-nova-cell-mapping.html for more info"
34 if (raise_exc) {
35 error('Update cells disabled.\n' +
36 waStatus.waInfo)
37 }
38 return waStatus
39 }
40 waStatus.isFixed = "Work-around for PROD-34645 already applied, nothing todo"
41 return waStatus
42}
43
44def check_35705(salt, venvPepper, String cluster_name, Boolean raise_exc) {
45 def galeracheckpasswordPillar = salt.getPillar(venvPepper, 'I@salt:master', '_param:galera_clustercheck_password').get("return")[0].values()[0]
46 def waStatus = [prodId: "PROD-35705", isFixed: "", waInfo: ""]
47 if (galeracheckpasswordPillar == '' || galeracheckpasswordPillar == 'null' || galeracheckpasswordPillar == null) {
48 waStatus.isFixed = "Work-around should be applied manually"
49 waStatus.waInfo = "See https://docs.mirantis.com/mcp/q4-18/mcp-release-notes/mu/mu-12/mu-12-addressed/mu-12-dtrain/mu-12-dt-manual.html#improper-operation-of-galera-ha for more info"
50 if (raise_exc) {
51 error('Galera clustercheck password is not defined.\n' +
52 waStatus.waInfo)
53 }
54 return waStatus
55 }
56 waStatus.isFixed = "Work-around for PROD-35705 already applied, nothing todo"
57 return waStatus
58}
59
60def check_35884(salt, venvPepper, String cluster_name, Boolean raise_exc) {
61 def waStatus = [prodId: "PROD-35884", isFixed: "", waInfo: ""]
62 if (salt.getMinions(venvPepper, 'I@prometheus:alerta or I@prometheus:alertmanager')) {
63 def alertaApiKeyGenPillar = salt.getPillar(venvPepper, 'I@salt:master', '_param:alerta_admin_api_key_generated').get("return")[0].values()[0]
64 def alertaApiKeyPillar = salt.getPillar(venvPepper, 'I@prometheus:alerta or I@prometheus:alertmanager', '_param:alerta_admin_key').get("return")[0].values()[0]
65 if (alertaApiKeyGenPillar == '' || alertaApiKeyGenPillar == 'null' || alertaApiKeyGenPillar == null || alertaApiKeyPillar == '' || alertaApiKeyPillar == 'null' || alertaApiKeyPillar == null) {
66 waStatus.isFixed = "Work-around should be applied manually"
67 waStatus.waInfo = "See https://docs.mirantis.com/mcp/q4-18/mcp-release-notes/mu/mu-12/mu-12-addressed/mu-12-dtrain/mu-12-dt-manual.html#i-35884 for more info"
68 if (raise_exc) {
69 error('Alerta admin API key not defined.\n' +
70 waStatus.waInfo)
71 }
72 return waStatus
73 }
74 }
75 waStatus.isFixed = "Work-around for PROD-35884 already applied, nothing todo"
76 return waStatus
77}
78
79def check_36461(salt, venvPepper, String cluster_name, Boolean raise_exc){
80 def common = new com.mirantis.mk.Common()
81 def waStatus = [prodId: "PROD-36461", isFixed: "", waInfo: ""]
82 if (!salt.testTarget(venvPepper, 'I@ceph:radosgw')) {
Vladimir Khlyunev450adb42022-08-16 15:33:30 +040083 waStatus.isFixed = 'Nothing to do. Ceph is not enabled.'
84 return waStatus
Roman Lubianyi26701f52021-11-09 17:32:34 +020085 }
86 def clusterModelPath = "/srv/salt/reclass/classes/cluster/${cluster_name}"
87 def checkFile = "${clusterModelPath}/ceph/rgw.yml"
88 def saltTarget = "I@salt:master"
89 try {
90 salt.cmdRun(venvPepper, saltTarget, "test -f ${checkFile}")
91 }
92 catch (Exception e) {
93 waStatus.isFixed = "Check skipped"
94 waStatus.waInfo = "Unable to check ordering of RadosGW imports, file ${checkFile} not found, skipping"
Roman Lubianyi26701f52021-11-09 17:32:34 +020095 return waStatus
96 }
97 def fileContent = salt.cmdRun(venvPepper, saltTarget, "cat ${checkFile}").get('return')[0].values()[0].replaceAll('Salt command execution success', '').trim()
98 def yamlData = readYaml text: fileContent
99 def infraClassImport = "cluster.${cluster_name}.infra"
100 def cephClassImport = "cluster.${cluster_name}.ceph"
101 def cephCommonClassImport = "cluster.${cluster_name}.ceph.common"
102 def infraClassFound = false
103 def importErrorDetected = false
104 def importErrorMessage = """Ceph classes in '${checkFile}' are used in wrong order! Please reorder it:
105'${infraClassImport}' should be placed before '${cephClassImport}' and '${cephCommonClassImport}'.
106For additional information please see https://docs.mirantis.com/mcp/q4-18/mcp-release-notes/mu/mu-15/mu-15-addressed/mu-15-dtrain/mu-15-dtrain-manual.html"""
107 for (yamlClass in yamlData.classes) {
108 switch(yamlClass){
109 case infraClassImport:
110 infraClassFound = true;
111 break;
112 case cephClassImport:
113 if (!infraClassFound) {
114 importErrorDetected = true
115 };
116 break;
117 case cephCommonClassImport:
118 if (!infraClassFound) {
119 importErrorDetected = true
120 };
121 break;
122 }
123 }
124 if (importErrorDetected) {
125 waStatus.isFixed = "Work-around should be applied manually"
126 waStatus.waInfo = importErrorMessage
127 if (raise_exc) {
128 common.errorMsg(importErrorMessage)
129 error(importErrorMessage)
130 }
131 return waStatus
132 }
133 waStatus.isFixed = "Work-around for PROD-36461 already applied, nothing todo"
134 return waStatus
135}
136
137def check_36461_2 (salt, venvPepper, String cluster_name, Boolean raise_exc) {
Vladimir Khlyunevdb4b7572022-08-02 13:57:12 +0400138 def saltTarget = salt.getFirstMinion(venvPepper, 'I@ceph:mon')
Vladimir Khlyunev68b37b52023-02-21 06:24:54 +0400139 def waStatus = [prodId: "PROD-36461,PROD-36942", isFixed: "", waInfo: ""]
140 if (!saltTarget){
141 waStatus.isFixed = "Ceph not enabled, skipping"
142 return waStatus
143 }
Vladimir Khlyunevdb4b7572022-08-02 13:57:12 +0400144 def cephVersionNum = salt.cmdRun(venvPepper, saltTarget, "ceph version | awk '{print \$3}'").get('return')[0].values()[0].replaceAll('Salt command execution success', '').trim()
145 List cephVersion = cephVersionNum.tokenize('.')
146
147 def majorVersion = cephVersion[0].toInteger()
148 def minorVersion = cephVersion[1].toInteger()
149 def minorSubversion = cephVersion[2].toInteger()
150
Vladimir Khlyunevdb4b7572022-08-02 13:57:12 +0400151 def allowInsecureReclaimIdPillar = salt.getPillar(venvPepper, 'I@ceph:mon', 'ceph:common:config:mon:auth_allow_insecure_global_id_reclaim').get("return")[0].values()[0]
152 allowInsecureReclaimIdPillar = allowInsecureReclaimIdPillar.toString().toLowerCase().trim()
153
154 if (majorVersion >= 14 && minorVersion >= 2 && minorSubversion >= 20) {
155 if ( allowInsecureReclaimIdPillar == 'false' ){
156 waStatus.isFixed = "Installed ceph version is 14.2.20+ and insecure global reclaim_id is disabled. Nothing to do."
157 return waStatus
158 }
Roman Lubianyi26701f52021-11-09 17:32:34 +0200159 waStatus.isFixed = "Work-around should be applied manually"
Vladimir Khlyunevdb4b7572022-08-02 13:57:12 +0400160 waStatus.waInfo = "Ceph is vulnerable for CVE-2021-20288. See https://docs.mirantis.com/mcp/q4-18/mcp-release-notes/single/index.html#i-cve-2021-20288 for more info"
Roman Lubianyi26701f52021-11-09 17:32:34 +0200161 if (raise_exc) {
Vladimir Khlyunevdb4b7572022-08-02 13:57:12 +0400162 error('Option is not set to required value.\n' + waStatus.waInfo)
Roman Lubianyi26701f52021-11-09 17:32:34 +0200163 }
164 return waStatus
165 }
Vladimir Khlyunevdb4b7572022-08-02 13:57:12 +0400166
167 if ( allowInsecureReclaimIdPillar == 'false' ) {
168 waStatus.isFixed = "Work-around should be applied manually"
169 waStatus.waInfo = "To upgrade ceph from version below 14.2.20 you MUST set ceph:common:config:mon:auth_allow_insecure_global_id_reclaim pillar to \"true\"."
170 if (raise_exc) {
171 error('Option is not set to required value.\n' + waStatus.waInfo)
172 }
173 return waStatus
174 }
Roman Lubianyi26701f52021-11-09 17:32:34 +0200175 return waStatus
176}
Vladimir Khlyunev37b350a2022-08-11 18:27:48 +0400177
178def check_36960 (salt, venvPepper, String cluster_name, Boolean raise_exc) {
Vladimir Khlyunevf73947e2022-08-16 14:49:38 +0400179 def waStatus = [prodId: "PROD-36960", isFixed: "", waInfo: ""]
180
Vladimir Khlyunev37b350a2022-08-11 18:27:48 +0400181 if (!salt.testTarget(venvPepper, 'I@redis:server')) {
Vladimir Khlyunevf73947e2022-08-16 14:49:38 +0400182 waStatus.isFixed = 'Nothing to do. There are no redis-servers.'
183 return waStatus
Vladimir Khlyunev37b350a2022-08-11 18:27:48 +0400184 }
Vladimir Khlyunevf73947e2022-08-16 14:49:38 +0400185
Vladimir Khlyunev37b350a2022-08-11 18:27:48 +0400186 def redisVersionPillar = salt.getPillar(venvPepper, 'I@redis:server', 'redis:server:version').get("return")[0].values()[0]
187
188 List redisVersion = redisVersionPillar.toString().tokenize('.')
189
190 def majorVersion = redisVersion[0].toInteger()
191 def minorVersion = redisVersion[1].toInteger()
192
Vladimir Khlyunev37b350a2022-08-11 18:27:48 +0400193 if (majorVersion >= 5 && minorVersion >= 0) {
194 waStatus.isFixed = 'Nothing to do. Redis-server version pillar is set to required version (5.0+).'
195 return waStatus
196 }
197 waStatus.isFixed = "Fix should be applied manually"
198 waStatus.waInfo = """To apply latest MU to openstack control plane you MUST set correct version for redis-server package. \n
199Please set pillar "redis:server:version" to "5.0" to openstack/telemetry.yml and refresh pillars."""
200 if (raise_exc) {
201 error('Option is not set to required value.\n' + waStatus.waInfo)
202 }
203 return waStatus
204}
Oleksii Molchanov640b73e2023-01-11 11:15:54 +0200205
206def check_37068 (salt, venvPepper, String cluster_name, Boolean raise_exc) {
207 def waStatus = [prodId: "PROD-37068", isFixed: "", waInfo: ""]
208 def dogtag_enabled = salt.getPillar(venvPepper, 'I@dogtag:server', "dogtag:server:enabled").get("return")[0].values()[0]
209 def pushgateway_enabled = salt.getPillar(venvPepper, 'I@docker:client:stack:monitoring', "prometheus:pushgateway:enabled").get("return")[0].values()[0]
210 if (dogtag_enabled == '' || dogtag_enabled == 'false' || dogtag_enabled == null) {
211 waStatus.isFixed = 'Nothing to do. Dogtag is disabled.'
212 return waStatus
213 } else {
214 if (pushgateway_enabled == '' || pushgateway_enabled == 'false' || pushgateway_enabled == null) {
215 waStatus.isFixed = 'Nothing to do. Pushgateway is disabled.'
216 return waStatus
217 } else {
218 def stacklightMonitorHostnamePillar = salt.getPillar(venvPepper, 'I@dogtag:server', 'dogtag:server:stacklight_monitor_hostname').get("return")[0].values()[0]
219 if (stacklightMonitorHostnamePillar == '' || stacklightMonitorHostnamePillar == 'null' || stacklightMonitorHostnamePillar == null) {
220 waStatus.isFixed = "Work-around should be applied manually"
221 waStatus.waInfo = """To enable dogtag certificates expriration alerts you MUST set stacklight monitor endpoint. \n
222Please set pillar "dogtag:server:stacklight_monitor_hostname" to the value of _param:stacklight_monitor_hostname in openstack/barbican.yml and refresh pillars."""
223 if (raise_exc) {
224 error('Pillar dogtag:server:stacklight_monitor_hostname is not defined.\n' +
225 waStatus.waInfo)
226 }
227 return waStatus
228 }
229 waStatus.isFixed = "Work-around for PROD-37068 already applied, nothing todo"
230 return waStatus
231 }
232 }
233}