Skip to content

Commit 371e1c5

Browse files
nammnclaude
andcommitted
Fix SSA validation errors: remove nulls and fix test path
1. Add _remove_null_values() to recursively strip null values from objects before SSA - Kubernetes rejects nulls where objects are expected in the CRD schema (e.g., spec.security: null → 422 error) 2. Fix test_appdb_reconcile to use correct schema path: - Wrong: spec.applicationDatabase.logLevel - Correct: spec.applicationDatabase.agent.logLevel This was a latent bug exposed by SSA's strict schema validation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4c63bd5 commit 371e1c5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

docker/mongodb-kubernetes-tests/kubeobject/customobject.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,27 @@
99
from kubernetes.dynamic import DynamicClient
1010

1111

12+
def _remove_null_values(obj):
13+
"""Recursively remove keys with None/null values from a dict.
14+
15+
SSA rejects null values where objects are expected in the schema.
16+
"""
17+
if isinstance(obj, dict):
18+
return {k: _remove_null_values(v) for k, v in obj.items() if v is not None}
19+
elif isinstance(obj, list):
20+
return [_remove_null_values(item) for item in obj]
21+
return obj
22+
23+
1224
def _strip_server_managed_fields(obj: Dict) -> Dict:
1325
"""Strip server-managed fields from object before server-side apply.
1426
1527
Server-side apply (SSA) will reject requests that include certain
1628
server-managed fields. These fields are automatically added by the
1729
server when an object is created/updated and should not be sent
1830
back in SSA requests.
31+
32+
Also removes null values which SSA rejects where objects are expected.
1933
"""
2034
result = copy.deepcopy(obj)
2135

@@ -35,6 +49,9 @@ def _strip_server_managed_fields(obj: Dict) -> Dict:
3549
]:
3650
metadata.pop(field, None)
3751

52+
# Remove null values - SSA rejects nulls where objects are expected
53+
result = _remove_null_values(result)
54+
3855
return result
3956

4057

docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def test_agents_upgraded(self, mdb: MongoDB, ops_manager: MongoDBOpsManager, cus
381381
class TestAppDBScramShaUpdated:
382382
def test_appdb_reconcile(self, ops_manager: MongoDBOpsManager):
383383
ops_manager.load()
384-
ops_manager["spec"]["applicationDatabase"]["logLevel"] = "DEBUG"
384+
ops_manager["spec"]["applicationDatabase"]["agent"]["logLevel"] = "DEBUG"
385385
ops_manager.update()
386386

387387
ops_manager.appdb_status().assert_reaches_phase(Phase.Running)

0 commit comments

Comments
 (0)