Skip to content

Commit ec4e82f

Browse files
Merge branch 'stable' into update-250925
2 parents 3302c12 + 9f2b43d commit ec4e82f

File tree

4 files changed

+67
-4
lines changed

4 files changed

+67
-4
lines changed

.secrets.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-02-28T10:11:51Z",
6+
"generated_at": "2025-09-30T07:33:15Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -92,7 +92,7 @@
9292
"hashed_secret": "a4b48a81cdab1e1a5dd37907d6c85ca1c61ddc7c",
9393
"is_secret": false,
9494
"is_verified": false,
95-
"line_number": 263,
95+
"line_number": 290,
9696
"type": "Secret Keyword",
9797
"verified_result": null
9898
}

src/mas/devops/db2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,12 @@ def check_reg_cfg(db2u_instance_cr: dict, core_v1_api: client.CoreV1Api, mas_ins
237237
for cr_k, cr_v in reg_cfg_cr.items():
238238
# regex ignores any trailing [O] (which indicates the param has been overridden I think)
239239
matches = re.search(fr"{cr_k}=(.*?)(?:\s\[O\])?$", reg_cfg_pod, re.MULTILINE)
240-
if matches is None:
240+
if matches is None and cr_v != '':
241241
failures.append(f"[registry cfg] {cr_k} not found in output of db2set command")
242242
continue
243-
pod_v = matches.group(1)
243+
pod_v = ''
244+
if cr_v != '':
245+
pod_v = matches.group(1)
244246

245247
if not cr_pod_v_matches(cr_k, cr_v, pod_v):
246248
failures.append(f"[registry cfg] {cr_k}: {cr_v} != {pod_v}")

src/mas/devops/mas.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,41 @@ def getMasChannel(dynClient: DynamicClient, instanceId: str) -> str:
225225
return masSubscription.spec.channel
226226

227227

228+
def getAppsSubscriptionChannel(dynClient: DynamicClient, instanceId: str) -> list:
229+
"""
230+
Return list of installed apps with their subscribed channel
231+
"""
232+
try:
233+
installedApps = []
234+
appKinds = [
235+
"assist",
236+
"facilities",
237+
"health",
238+
"hputilities",
239+
"iot",
240+
"manage",
241+
"monitor",
242+
"mso",
243+
"optimizer",
244+
"safety",
245+
"predict",
246+
"visualinspection",
247+
"aibroker"
248+
]
249+
for appKind in appKinds:
250+
appSubscription = getSubscription(dynClient, f"mas-{instanceId}-{appKind}", f"ibm-mas-{appKind}")
251+
if appSubscription is not None:
252+
installedApps.append({"appId": appKind, "channel": appSubscription.spec.channel})
253+
return installedApps
254+
except NotFoundError:
255+
return []
256+
except ResourceNotFoundError:
257+
return []
258+
except UnauthorizedError:
259+
logger.error("Error: Unable to get MAS app subscriptions due to failed authorization: {e}")
260+
return []
261+
262+
228263
def updateIBMEntitlementKey(dynClient: DynamicClient, namespace: str, icrUsername: str, icrPassword: str, artifactoryUsername: str = None, artifactoryPassword: str = None, secretName: str = "ibm-entitlement") -> ResourceInstance:
229264
if secretName is None:
230265
secretName = "ibm-entitlement"

test/src/test_db2.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,32 @@ def test_check_reg_cfg(mocker):
274274
])
275275

276276

277+
def test_check_reg_cfg_with_empty_value_in_cr(mocker):
278+
279+
mock_db2_pod_exec_db2set = mocker.patch("mas.devops.db2.db2_pod_exec_db2set")
280+
mock_db2_pod_exec_db2set.return_value = '''
281+
DB2AUTH=OSAUTHDB,ALLOW_LOCAL_FALLBACK,PLUGIN_AUTO_RELOAD
282+
DB2_FMP_COMM_HEAPSZ=65536 [O]
283+
'''
284+
285+
db2_instance_cr = dict(
286+
spec=dict(
287+
environment=dict(
288+
instance=dict(
289+
registry=dict(
290+
DB2AUTH='WRONG',
291+
NOTFOUNDINOUTPUT="",
292+
)
293+
)
294+
)
295+
)
296+
)
297+
298+
assert set(db2.check_reg_cfg(db2_instance_cr, None, None, None)) == set([
299+
"[registry cfg] DB2AUTH: WRONG != OSAUTHDB,ALLOW_LOCAL_FALLBACK,PLUGIN_AUTO_RELOAD"
300+
])
301+
302+
277303
@pytest.mark.parametrize("test_case_name, expected_failures", [
278304
# This test case simulates what will happen when we run the validate_db2_config using the IoT Db2uInstance CR
279305
# as we have it today in fvtsaas after the CR settings have been applied successfully to DB2

0 commit comments

Comments
 (0)