blob: 8b4279b74d77c64ea09d2b67e4bae62a4ada80aa [file] [log] [blame]
Roman Lubianyi8ac46a92021-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 Khlyunev769d8a92022-08-16 15:33:30 +040083 waStatus.isFixed = 'Nothing to do. Ceph is not enabled.'
84 return waStatus
Roman Lubianyi8ac46a92021-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"
95 if (raise_exc) {
96 common.warningMsg(waStatus.waInfo)
97 return
98 }
99 return waStatus
100 }
101 def fileContent = salt.cmdRun(venvPepper, saltTarget, "cat ${checkFile}").get('return')[0].values()[0].replaceAll('Salt command execution success', '').trim()
102 def yamlData = readYaml text: fileContent
103 def infraClassImport = "cluster.${cluster_name}.infra"
104 def cephClassImport = "cluster.${cluster_name}.ceph"
105 def cephCommonClassImport = "cluster.${cluster_name}.ceph.common"
106 def infraClassFound = false
107 def importErrorDetected = false
108 def importErrorMessage = """Ceph classes in '${checkFile}' are used in wrong order! Please reorder it:
109'${infraClassImport}' should be placed before '${cephClassImport}' and '${cephCommonClassImport}'.
110For 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"""
111 for (yamlClass in yamlData.classes) {
112 switch(yamlClass){
113 case infraClassImport:
114 infraClassFound = true;
115 break;
116 case cephClassImport:
117 if (!infraClassFound) {
118 importErrorDetected = true
119 };
120 break;
121 case cephCommonClassImport:
122 if (!infraClassFound) {
123 importErrorDetected = true
124 };
125 break;
126 }
127 }
128 if (importErrorDetected) {
129 waStatus.isFixed = "Work-around should be applied manually"
130 waStatus.waInfo = importErrorMessage
131 if (raise_exc) {
132 common.errorMsg(importErrorMessage)
133 error(importErrorMessage)
134 }
135 return waStatus
136 }
137 waStatus.isFixed = "Work-around for PROD-36461 already applied, nothing todo"
138 return waStatus
139}
140
141def check_36461_2 (salt, venvPepper, String cluster_name, Boolean raise_exc) {
Vladimir Khlyunev00f00082022-08-02 13:57:12 +0400142 def saltTarget = salt.getFirstMinion(venvPepper, 'I@ceph:mon')
143 def cephVersionNum = salt.cmdRun(venvPepper, saltTarget, "ceph version | awk '{print \$3}'").get('return')[0].values()[0].replaceAll('Salt command execution success', '').trim()
144 List cephVersion = cephVersionNum.tokenize('.')
145
146 def majorVersion = cephVersion[0].toInteger()
147 def minorVersion = cephVersion[1].toInteger()
148 def minorSubversion = cephVersion[2].toInteger()
149
150 def waStatus = [prodId: "PROD-36461,PROD-36942", isFixed: "", waInfo: ""]
151
152 def allowInsecureReclaimIdPillar = salt.getPillar(venvPepper, 'I@ceph:mon', 'ceph:common:config:mon:auth_allow_insecure_global_id_reclaim').get("return")[0].values()[0]
153 allowInsecureReclaimIdPillar = allowInsecureReclaimIdPillar.toString().toLowerCase().trim()
154
155 if (majorVersion >= 14 && minorVersion >= 2 && minorSubversion >= 20) {
156 if ( allowInsecureReclaimIdPillar == 'false' ){
157 waStatus.isFixed = "Installed ceph version is 14.2.20+ and insecure global reclaim_id is disabled. Nothing to do."
158 return waStatus
159 }
Roman Lubianyi8ac46a92021-11-09 17:32:34 +0200160 waStatus.isFixed = "Work-around should be applied manually"
Vladimir Khlyunev00f00082022-08-02 13:57:12 +0400161 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 Lubianyi8ac46a92021-11-09 17:32:34 +0200162 if (raise_exc) {
Vladimir Khlyunev00f00082022-08-02 13:57:12 +0400163 error('Option is not set to required value.\n' + waStatus.waInfo)
Roman Lubianyi8ac46a92021-11-09 17:32:34 +0200164 }
165 return waStatus
166 }
Vladimir Khlyunev00f00082022-08-02 13:57:12 +0400167
168 if ( allowInsecureReclaimIdPillar == 'false' ) {
169 waStatus.isFixed = "Work-around should be applied manually"
170 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\"."
171 if (raise_exc) {
172 error('Option is not set to required value.\n' + waStatus.waInfo)
173 }
174 return waStatus
175 }
Roman Lubianyi8ac46a92021-11-09 17:32:34 +0200176 return waStatus
177}
Vladimir Khlyunev6df38422022-08-11 18:27:48 +0400178
179def check_36960 (salt, venvPepper, String cluster_name, Boolean raise_exc) {
Vladimir Khlyunev9f35c922022-08-16 14:49:38 +0400180 def waStatus = [prodId: "PROD-36960", isFixed: "", waInfo: ""]
181
Vladimir Khlyunev6df38422022-08-11 18:27:48 +0400182 if (!salt.testTarget(venvPepper, 'I@redis:server')) {
Vladimir Khlyunev9f35c922022-08-16 14:49:38 +0400183 waStatus.isFixed = 'Nothing to do. There are no redis-servers.'
184 return waStatus
Vladimir Khlyunev6df38422022-08-11 18:27:48 +0400185 }
Vladimir Khlyunev9f35c922022-08-16 14:49:38 +0400186
Vladimir Khlyunev6df38422022-08-11 18:27:48 +0400187 def redisVersionPillar = salt.getPillar(venvPepper, 'I@redis:server', 'redis:server:version').get("return")[0].values()[0]
188
189 List redisVersion = redisVersionPillar.toString().tokenize('.')
190
191 def majorVersion = redisVersion[0].toInteger()
192 def minorVersion = redisVersion[1].toInteger()
193
Vladimir Khlyunev6df38422022-08-11 18:27:48 +0400194 if (majorVersion >= 5 && minorVersion >= 0) {
195 waStatus.isFixed = 'Nothing to do. Redis-server version pillar is set to required version (5.0+).'
196 return waStatus
197 }
198 waStatus.isFixed = "Fix should be applied manually"
199 waStatus.waInfo = """To apply latest MU to openstack control plane you MUST set correct version for redis-server package. \n
200Please set pillar "redis:server:version" to "5.0" to openstack/telemetry.yml and refresh pillars."""
201 if (raise_exc) {
202 error('Option is not set to required value.\n' + waStatus.waInfo)
203 }
204 return waStatus
205}