Skip to content

Commit 0b9f81e

Browse files
committed
turn off operator when modifying cm
1 parent 77690a9 commit 0b9f81e

File tree

1 file changed

+68
-6
lines changed

1 file changed

+68
-6
lines changed

tests/e2e/utils/data_collector_control.py

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,27 @@ def set_exporter_collection_interval(self, interval_seconds: int) -> None:
122122
Args:
123123
interval_seconds: Collection interval in seconds.
124124
125-
Note: This requires deployment restart to take effect.
125+
Note: This requires operator and deployment restart to take effect.
126126
"""
127-
# Scale down deployment first
127+
# Scale down operator to prevent ConfigMap reconciliation
128+
print("Scaling down operator to prevent ConfigMap reconciliation...")
129+
try:
130+
cluster_utils.run_oc(
131+
[
132+
"scale",
133+
"deployment/lightspeed-operator-controller-manager",
134+
"-n",
135+
EXPORTER_NAMESPACE,
136+
"--replicas=0",
137+
]
138+
)
139+
print("Operator scaled down")
140+
except Exception as e:
141+
print(f"Warning: Could not scale down operator: {e}")
142+
143+
time.sleep(3)
144+
145+
# Scale down deployment
128146
print("Scaling down deployment before ConfigMap update...")
129147
cluster_utils.run_oc(
130148
[
@@ -150,7 +168,7 @@ def set_exporter_collection_interval(self, interval_seconds: int) -> None:
150168
break
151169
time.sleep(2)
152170

153-
# Now update the ConfigMap
171+
# Now update the ConfigMap (operator won't reconcile it back)
154172
self.update_exporter_config(collection_interval=interval_seconds)
155173

156174
# Wait a moment for ConfigMap update to propagate
@@ -326,13 +344,57 @@ def cleanup_after_data_collection_test(
326344
) -> None:
327345
"""Clean up after data collection test.
328346
329-
Restores a long collection interval to prevent interference with other tests.
347+
Restores a long collection interval and brings back the operator.
330348
331349
Args:
332350
controller: DataCollectorControl instance from prepare_for_data_collection_test.
333351
restore_interval_seconds: Interval to restore (default: 3600s = 1 hour).
334352
"""
335353
print(f"Restoring collection interval to {restore_interval_seconds}s...")
336-
controller.set_exporter_collection_interval(restore_interval_seconds)
337-
controller.restart_exporter_container()
354+
355+
# Scale down deployment
356+
cluster_utils.run_oc(
357+
[
358+
"scale",
359+
"deployment/lightspeed-app-server",
360+
"-n",
361+
EXPORTER_NAMESPACE,
362+
"--replicas=0",
363+
]
364+
)
365+
time.sleep(3)
366+
367+
# Restore the ConfigMap
368+
controller.update_exporter_config(collection_interval=restore_interval_seconds)
369+
time.sleep(2)
370+
371+
# Scale up deployment
372+
cluster_utils.run_oc(
373+
[
374+
"scale",
375+
"deployment/lightspeed-app-server",
376+
"-n",
377+
EXPORTER_NAMESPACE,
378+
"--replicas=1",
379+
]
380+
)
381+
382+
# Scale operator back up so it can manage resources
383+
print("Scaling operator back up...")
384+
try:
385+
cluster_utils.run_oc(
386+
[
387+
"scale",
388+
"deployment/lightspeed-operator-controller-manager",
389+
"-n",
390+
EXPORTER_NAMESPACE,
391+
"--replicas=1",
392+
]
393+
)
394+
print("Operator scaled back up")
395+
except Exception as e:
396+
print(f"Warning: Could not scale up operator: {e}")
397+
398+
# Wait for pod to be ready
399+
time.sleep(10)
338400
print("Data collection test cleanup complete")

0 commit comments

Comments
 (0)