Skip to content

feat: Add initial CronJob as external reconciler for resource cleanup#22

Open
lbeckman314 wants to merge 2 commits into
mainfrom
feat/cronjob
Open

feat: Add initial CronJob as external reconciler for resource cleanup#22
lbeckman314 wants to merge 2 commits into
mainfrom
feat/cronjob

Conversation

@lbeckman314

@lbeckman314 lbeckman314 commented May 8, 2026

Copy link
Copy Markdown
Contributor

Overview 🌀

This PR adds an initial cronjob to act as an for resource cleanup in K8s (i.e. "external reconciler")

It runs an example command (funnel kubernetes cleanup) that is designed to call the update "modular reconciler" implemented in uc-cdis:funnel:chore/reconcile_modular

Current Behavior ⚠️

K8s resource cleanup is run in the resource-intensive (and complicated!) functions directly in Funnel:

New Behavior ✔️

Resources are cleaned in a single, user-configurable Helm template.

Caution

TODO: Add examples of defaults + configuration options, for example:

  • Which resources to clean (default: all)
  • Time period between cleans (default: 300s?)

Backwards Compatibilty 🔄

Caution

TODO: Does this new behavior affect existing workflows/setups?

  • Likely yes, as the reconciler was first added to Funnel in Commit c108da6 (Feb 20, 2020)
  • Steps to make ensure compatible with previous builds (e.g. feature flag)?

Signed-off-by: Liam Beckman <lbeckman314@gmail.com>
@lbeckman314 lbeckman314 self-assigned this May 8, 2026
@lbeckman314 lbeckman314 added the enhancement New feature or request label May 8, 2026
Comment thread charts/funnel/templates/cronjob.yaml Outdated
{{- include "funnel.labels" . | nindent 4 }}
spec:
# Offset the minute so deployments in different namespaces don't all fire simultaneously.
schedule: {{ printf "%d %s" (.Values.cleanup.scheduleOffsetMinutes | int) (trimPrefix (printf "%d " (.Values.cleanup.scheduleOffsetMinutes | int)) .Values.cleanup.schedule) | default .Values.cleanup.schedule | quote }}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update this to use the ReconcileRate from Funnel Config instead of cleanup.scheduleOffsetMinutes

@lbeckman314 lbeckman314 marked this pull request as ready for review June 26, 2026 23:23
The cleanup CronJob now derives its schedule from Kubernetes.ReconcileRate so
it shares a single source of truth with the server's reconcile cadence, instead
of requiring a separately-maintained cron expression.

- Add funnel.durationSeconds and funnel.cleanupSchedule template helpers. The
  schedule rounds ReconcileRate up to whole minutes (CronJob minute granularity,
  floor of 1) and honors scheduleOffsetMinutes; an explicit cleanup.schedule
  still overrides it.
- Add the missing cleanup: block (enabled, schedule, scheduleOffsetMinutes) to
  values.yaml; the cronjob template referenced these values but they were
  undefined, so the chart could not render.
- Replace the inline printf/trimPrefix schedule expression with the helper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Assisted-by: Claude Code:claude [Claude Code]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant