[K8s] Faster boot/shutdown + concurrency fixes - #996
Conversation
| # Confirm against this uuid's batch | ||
| with self._pending_deletion_lock: | ||
| batch = self._pending_deletion_batches.pop(proc_uuid, None) | ||
| if batch is not None: |
There was a problem hiding this comment.
If the only use of the lock is to retrieve the batch from the dict, why split the batch is not None logic between in the lock and out of the lock?
| return None | ||
|
|
||
| connection_server_ip = None | ||
| connection_server_ip = lcs.cluster_ip |
There was a problem hiding this comment.
Haven't finished reading this through, but this seems unclear already - in the function description this states
For non-LCS pods when a local connection server is booted
But in the function, this change introcues dependence on an object called lcs?
| self.log.debug( | ||
| f"notify_termination called for '{proc_uuid}'. Pending={self.uuids_pending_deletion}" | ||
| ) | ||
| self.log.debug(f"notify_termination called for '{proc_uuid}'.") |
There was a problem hiding this comment.
Can we have the process name here?
|
I timed the deployment of an With this branch, With Doing the same with and with `develop This PR, however, does resolve #791 Running MSQT was successful with This PR does address a lot of safety in the code, but I think the pod speedup issue will need to remain open. The reference |
|
Note - once the above comments are resolved, and the relevant issue this PR fixes is updated, we can close this issue |
Description
Fixes issue
#771
(and listed in #336)
One line summary: Speeds up k8s pod boot/shutdown and fixes several related correctness/race bugs (false dead-pod reporting, opmon false alarms, constructor thread-safety).
Type of change
Change log
Boot speedup
-- Removed per-pod/namespace label-patch API calls (_add_label/_add_creator_label) — labels are now set directly at creation time.
-- Cache the connection-server ClusterIP on the LCS session state once.
Shutdown speedup
-- Replaced the single global "pending deletion" set/event with per-batch tracking.
-- Added a fallback poll during kill_and_wait
-- Split the pod-ready and service-ready wait stages into independent timeouts
Correctness fixes
-- _ps_impl no longer reports a pod as DEAD because it's Pending/starting — only a missing pod or a terminal phase (Succeeded/Failed) counts as dead. Fixes false "Booted, but N processes died" messages right after boot.
-- Killed processes are now marked in expected_dead_applications (cleaned up once confirmed dead). Fixes false CRITICAL "has died" alarms during staged shutdown.
-- Fixed a constructor-ordering bug: the opmon publish thread and the pod watcher thread are started inside init, and could begin executing before the rest of the constructor had finished setting up the state they read.
-- Added boot_request_lock to protect boot_request inserts/deletes against concurrent iteration in _get_process_uid.
-- Two race conditions in the new batch/fallback-poll kill logic fixed with an idempotency guard.
Suggested manual testing checklist
Take any run using k8s PM. Ideally compare the result of develop and this branch.
Developer checklist
Prior to marking this as "Ready for Review"
Tests ran on: WHAT HOSTNAME from release RELEASE_NAME
Unit tests - some tests can't be ran on the CI. This is documented. If this PR checks a feature that can't be tested with CI, this has been marked appropriately.
Integration tests - the
daqsystemtest_integtest_bundlerequires a lot of resources, and connections to the EHN1 infrastructure. Check the cross referenced list if you can't run these. The developer needs to run at least the .pytest --marker) passeddaqsystemtest_integtest_bundle.sh -k minimal_system_quick_test.pydaqsystemtest_integtest_bundle.sh./scripts/drunc_integtest_bundle.sh)Final checklist prior to marking this as "Ready for Review"
Reviewer checklist
src/daqsystemtest_integtest_bundle.sh -k minimal_system_quick_test.pyifdaqsystemtest_integtest_bundle.shdruncare in the log filesdruncfailure appears:scripts/drunc_integtest_bundle.sh)Once the above boxes are checked, the PR(s) can be merged following the steps below.
Choose one of the following an complete all substepsPrior to merging
Once completed, the reviewer can merge the PR.
Notification message for a Slack channel
Note - this should be to #dunedaq-integration for general workflow that isn't during a release candidate period, and to #daq-release-prep otherwise.
For an single merge that changes the user workflow
For co-ordinated merge