Skip to content

Commit 3acc29c

Browse files
committed
Fix TLS disable test - disable TLS before removing certs
The test was failing because certs were removed while TLS mode was still transitioning. MongoDB requires certs until TLS is fully disabled. Correct order: 1. Set tls.enabled = False (keeping certs for transition) 2. Wait for AppDB to reach Running state 3. Remove certsSecretPrefix (optional cleanup)
1 parent e26016d commit 3acc29c

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

docker/mongodb-kubernetes-tests/tests/opsmanager/withMonitoredAppDB/om_appdb_tls_disable.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,30 @@ def test_disable_tls_on_appdb(ops_manager: MongoDBOpsManager):
7474
"""
7575
CLOUDP-351614: Disable TLS on AppDB and verify the operator correctly handles
7676
the transition without leaving stale TLS params in monitoring config.
77+
78+
TLS must be disabled in the correct order:
79+
1. First disable TLS (tls.enabled = False) while keeping certs
80+
2. Wait for the TLS mode transition to complete
81+
3. Only then remove the certs (certsSecretPrefix)
7782
"""
7883
ops_manager.load()
7984

80-
# Step 1: Transition to allowTLS mode first (required before fully disabling TLS)
81-
ops_manager["spec"]["applicationDatabase"]["additionalMongodConfig"] = {
82-
"net": {"tls": {"mode": "allowTLS"}}
83-
}
85+
# Step 1: Disable TLS mode (keeping certs until mode transition completes)
86+
# The operator will handle the TLS mode transition: requireTLS -> preferTLS -> allowTLS -> disabled
87+
ops_manager["spec"]["applicationDatabase"]["security"]["tls"]["enabled"] = False
8488
ops_manager.update()
89+
90+
# Wait for AppDB to reach Running state after TLS mode is disabled
8591
ops_manager.appdb_status().assert_reaches_phase(Phase.Running, timeout=1200)
8692

87-
# Step 2: Fully disable TLS on AppDB
88-
# Must remove certsSecretPrefix, disable TLS, and remove additionalMongodConfig
93+
# Step 2: Now that TLS is fully disabled, we can safely remove the cert configuration
94+
# This is optional cleanup - the certs are no longer used
95+
ops_manager.load()
8996
ops_manager["spec"]["applicationDatabase"]["security"]["certsSecretPrefix"] = None
90-
ops_manager["spec"]["applicationDatabase"]["security"]["tls"]["enabled"] = False
91-
del ops_manager["spec"]["applicationDatabase"]["additionalMongodConfig"]
9297
ops_manager.update()
9398

94-
# Wait for AppDB to reach Running state after TLS disable
95-
ops_manager.appdb_status().assert_reaches_phase(Phase.Running, timeout=1200)
99+
# Wait for AppDB to reach Running state after cert cleanup
100+
ops_manager.appdb_status().assert_reaches_phase(Phase.Running, timeout=600)
96101

97102

98103
@mark.e2e_om_appdb_tls_disable

0 commit comments

Comments
 (0)