Skip to content

Refactor ConfigMap-based teardown and remove DaemonSet finaliser #438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

frobware
Copy link
Contributor

@frobware frobware commented Apr 30, 2025

While we have no issue tracking this change, this refactor consolidates finaliser handling by ensuring all teardown is coordinated via the ConfigMap. The operator now only places a finaliser on the ConfigMap and removes finalisers from the DaemonSet.

TODO:

  • Reconcile SCCs
  • Reconcile CSIDriver

Note: If either the SCC or the CSIDriver is manually removed, it will not be recreated.


Previously, a finaliser was added to the DaemonSet, which blocked its deletion unless explicitly removed. However, the operator only watched the ConfigMap—not the DaemonSet—so forced DaemonSet deletions went unnoticed, and the DaemonSet was never recreated.

This change reworks that behaviour to match standard Kubernetes operator design:

  • Adds a Watches(&DaemonSet{}, EnqueueRequestsFromMapFunc(...)) that maps all DaemonSet events back to the ConfigMap. This enables self-healing: if the DaemonSet is deleted, the operator observes the event and recreates it.

  • Removes the DaemonSet finaliser entirely. It's unnecessary because the parent ConfigMap holds the only finaliser. This is in line with Kubernetes guidance: only finalise the resource responsible for managing others.

  • Replaces monolithic teardown with ordered, step-wise deletion of managed resources (DaemonSet, CSIDriver, SCC), requeuing between each step. This ensures deletion is safe, idempotent, and resilient to propagation delays or transient failures.

  • Removes the ConfigMap finaliser only after all dependent resources have been confirmed deleted. This prevents race conditions and ensures a clean operator shutdown.

These changes bring the controller in line with normal operator architecture: use a single "source of truth" object (ConfigMap in this case), watch and reconcile dependents explicitly, and rely on finalisers only where needed.

@frobware frobware marked this pull request as draft April 30, 2025 16:20
@frobware frobware force-pushed the fix-finalizers branch 2 times, most recently from ca3856b to d7128f9 Compare May 1, 2025 11:54
Copy link
Contributor

mergify bot commented May 1, 2025

@frobware, this pull request is now in conflict and requires a rebase.

@mergify mergify bot added the needs-rebase label May 1, 2025
Copy link

codecov bot commented May 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (4e2b3e7) to head (d7128f9).
Report is 6 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff     @@
##   main   #438   +/-   ##
===========================
===========================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Previously, a finaliser was added to the DaemonSet, which blocked its
deletion unless explicitly removed. However, the operator only watched
the ConfigMap—not the DaemonSet—so forced DaemonSet deletions went
unnoticed, and the DaemonSet was never recreated.

This change reworks that behaviour to match standard Kubernetes
operator design:

- Adds a `Watches(&DaemonSet{}, EnqueueRequestsFromMapFunc(...))` that
  maps all DaemonSet events back to the ConfigMap. This enables
  self-healing: if the DaemonSet is deleted, the operator observes the
  event and recreates it.

- Removes the DaemonSet finaliser entirely. It's unnecessary because
  the parent ConfigMap holds the only finaliser. This is in line with
  Kubernetes guidance: only finalise the resource responsible for
  managing others.

- Replaces monolithic teardown with ordered, step-wise deletion of
  managed resources (DaemonSet, CSIDriver, SCC), requeuing between
  each step. This ensures deletion is safe, idempotent, and resilient
  to propagation delays or transient failures.

- Removes the ConfigMap finaliser only after all dependent resources
  have been confirmed deleted. This prevents race conditions and
  ensures a clean operator shutdown.

These changes bring the controller in line with normal operator
architecture: use a single "source of truth" object (ConfigMap in this
case), watch and reconcile dependents explicitly, and rely on
finalisers only where needed.

Signed-off-by: Andrew McDermott <[email protected]>
@mergify mergify bot removed the needs-rebase label May 1, 2025
frobware pushed a commit to frobware/bpfman-operator that referenced this pull request May 6, 2025
…s/component-update-ocp-bpfman-operator-bundle

chore(deps): update ocp-bpfman-operator-bundle to 227930a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant