Skip to content

[barbican] add batched db-cleanup nanny container - #12754

Open
rajivmucheli wants to merge 3 commits into
masterfrom
feat/barbican-nanny-db-cleanup
Open

rajivmucheli wants to merge 3 commits into
masterfrom
feat/barbican-nanny-db-cleanup

Conversation

@rajivmucheli

@rajivmucheli rajivmucheli commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a db-cleanup sidecar container to the barbican-nanny Deployment that periodically runs barbican-manage db clean with the --batch-size flag introduced in sapcc/barbican#52. Without batching, the one-shot DELETE exhausts the InnoDB buffer pool on large deployments.

  • New script template scripts/_db-cleanup.sh.tpl — loops on $BARBICAN_DB_CLEANUP_INTERVAL, passes --batch-size, --min-days, and optional --clean-unassociated-projects / --soft-delete-expired-secrets flags controlled by env vars
  • scripts-configmap.yaml — gate changed from db_secret_move.enabled to or db_secret_move.enabled db_cleanup.enabled; db-cleanup.sh added conditionally
  • barbican-nanny-deployment.yaml — outer gate updated to or; move-secrets and db-cleanup containers each independently conditional; volumes: block moved outside both container conditionals (latent bug in original)
  • values.yaml — new barbican_nanny.db_cleanup block (all defaults off / safe)

New values:

barbican_nanny:
  db_cleanup:
    enabled: false
    batch_size: 10000        # rows per committed batch
    min_num_days: 14         # threshold age for hard-deletes
    interval: 60             # minutes between cleanup runs
    clean_unassociated_projects: false
    soft_delete_expired_secrets: false

Test plan

  • helm template with db_cleanup.enabled: false produces identical output to current master (no regressions)
  • helm template with db_cleanup.enabled: true, db_secret_move.enabled: false renders a single-container nanny Deployment with db-cleanup container and correct env vars
  • helm template with both enabled renders both containers in the same pod

Adds a db-cleanup sidecar to the barbican-nanny Deployment, backed by a
new barbican-manage db clean loop script.  All cleanup operations now
use the --batch-size flag introduced in sapcc/barbican#52 to prevent
InnoDB buffer pool exhaustion on large deployments.

New values under barbican_nanny.db_cleanup:
  enabled                      - toggle the container (default: false)
  batch_size                   - rows per committed batch (default: 10000)
  min_num_days                 - threshold age for hard-deletes (default: 14)
  clean_unassociated_projects  - pass --clean-unassociated-projects flag
  soft_delete_expired_secrets  - pass --soft-delete-expired-secrets flag

The nanny Deployment now renders when either db_secret_move or
db_cleanup is enabled (previously gated on db_secret_move only).
Comment thread openstack/barbican/templates/scripts/_db-cleanup.sh.tpl Outdated
Comment thread openstack/barbican/templates/scripts/_db-cleanup.sh.tpl Outdated
- --min-num-days is not a valid flag; upstream uses --min-days / -m
  (barbican/cmd/db_manage.py:111)
- db cleanup should run on its own cadence, not the shared nanny
  interval; add barbican_nanny.db_cleanup.interval (default 60 min)
  and wire it through the deployment env var and the shell script
@rajivmucheli
rajivmucheli requested a review from s10 September 10, 2026 15:13
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.

3 participants