Skip to content

agent: fix cgroups_notifier deadlock when cgroup is destroyed#350

Draft
snir911 wants to merge 1 commit into
openshift:osc-releasefrom
snir911:osc-release_hang_fix
Draft

agent: fix cgroups_notifier deadlock when cgroup is destroyed#350
snir911 wants to merge 1 commit into
openshift:osc-releasefrom
snir911:osc-release_hang_fix

Conversation

@snir911

@snir911 snir911 commented Jun 24, 2026

Copy link
Copy Markdown
Member

When a cgroup is destroyed while the notifier event loop is processing events, the loop attempts to read from non-existent cgroup files (memory.events, cgroup.events) repeatedly. This causes:

  • Thousands of failed read attempts flooding the logging subsystem
  • Log buffer overflow (1000+ dropped messages)
  • CPU spinning in the event loop
  • Tokio async runtime becoming overwhelmed
  • RPC handlers unable to complete, causing pod deletion to hang

The issue is triggered when systemd deactivates the cgroup scope before kata-agent finishes processing the signal_process RPC, which can happen due to timing races in systemd service dependencies.

Fix by checking if cgroup paths exist BEFORE attempting to read from them, rather than after. This allows the event loop to exit cleanly when the cgroup is destroyed, preventing the infinite loop.

Fixes: Container deletion hanging indefinitely
Fixes: Node corruption due to leaked vxlan interfaces

Co-Authored-By:: Claude Code noreply@anthropic.com

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 24, 2026
@gkurz

gkurz commented Jun 24, 2026

Copy link
Copy Markdown
Member

Hi Snir ! Please fix this upstream and we will cherry-pick.

When a cgroup is destroyed while kata-agent is processing container deletion
(e.g., systemd deactivates the scope before signal_process completes), two
issues occur that cause the deletion to hang:

1. **cgroups_notifier infinite loop**: The inotify event loop attempts to read
   from non-existent cgroup files (memory.events, cgroup.events) repeatedly,
   causing thousands of failed read attempts, log buffer overflow (1000+ dropped
   messages), CPU spinning, and overwhelming the tokio async runtime.

2. **signal_process RPC hang**: The get_pids() call fails with an error when
   trying to read from the destroyed cgroup, causing the RPC to return an error
   instead of completing successfully. This leaves CRI-O waiting indefinitely
   for the response.

**Fixes:**

1. **notifier.rs**: Check if cgroup paths exist BEFORE attempting to read from
   them in the event loop. This allows clean exit when the cgroup is destroyed.

2. **rpc.rs**: Make get_pids() failure non-fatal in signal_process. If the
   cgroup is already destroyed, there are no processes left to signal anyway,
   so we can safely continue and return success.

Together, these fixes allow container deletion to complete cleanly even when
systemd races to clean up the cgroup before kata-agent finishes processing.

Fixes: Container deletion hanging indefinitely
Fixes: Node corruption due to leaked vxlan interfaces

Signed-off-by: Snir Schreiber <ssheribe@redhat.com>
@snir911 snir911 force-pushed the osc-release_hang_fix branch from eaa56a7 to 89e9ebd Compare June 25, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants