Skip to content

feat(deploy): run the portal retention purge as a daily CronJob - #620

Merged
devantler merged 2 commits into
mainfrom
claude/portal-retention-cronjob
Nov 16, 2026
Merged

devantler merged 2 commits into
mainfrom
claude/portal-retention-cronjob

Conversation

@devantler

@devantler devantler commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

#616, which adds --retention-purge, has merged, and this branch is rebased onto it. Package and image ship in the same release.

The privacy notice keeps a former client's portal records for 3 years after their last membership ended (#614). #616 adds the deletion as an exclusive one-shot mode of the executable. This PR runs that mode once a day from the package, beside the portal migration Job (#619).

What changes

  • deploy/cronjob-portal-retention.yaml: a daily CronJob at 03:17 Copenhagen time running --retention-purge --migration-database-projection /run/portal-migration/database-url.
    • Image. It runs the release's own image: kustomization.yaml copies the WebApp's pinned image into it as a second replacements target.
    • Input. It reads the platform's business-site-portal-db-migration Secret (feat(business-site): give the portal migration job its own inputs platform#6372) as the migration role, mounted exactly as for the migration Job.
    • Network. Its pods carry the migration Job's app.kubernetes.io/name: business-site-portal-migration label (plus app.kubernetes.io/component: retention-purge). The platform's migration network policy is therefore their only path to the database, with no platform change.
    • Runs. concurrencyPolicy: Forbid, backoffLimit: 0 and a 300-second deadline. A failed run deletes nothing, and the next day's run tries again.
    • Pod. UID and group 65532 with fsGroup 65532, a memory /tmp, no service-account token, and restricted PSS.
  • scripts/check-tenant-package.mjs admits exactly this CronJob, derived from the migration Job's pod spec, so the two cannot drift. The resource count goes to 11.
  • scripts/tenant-package.test.mjs adds refusal cases. Each must fail:
    • a missing CronJob or another image;
    • migrate arguments, or the strict file option;
    • overlapping runs, more than one run a day, retries, or no deadline;
    • root, a service-account token, the web Secret, or the web label.
    • The image-pinning test now covers the CronJob too.
  • scripts/verify-runtime-publication.sh admits the new manifest member, and scripts/runtime-verification.test.sh refuses its absence or alteration.
  • deploy/README.md adds Portal retention purge.

Flux does not health-check a CronJob, so a failed run never makes the tenant unhealthy. While a new release's migration Job has not finished, the purge's schema ownership check refuses to run.

Validation

  • node --test scripts/tenant-package.test.mjs: 164 pass.
  • bash scripts/runtime-verification.test.sh: PASS.
  • scripts/tenant-runtime-smoke.test.mjs now runs the image CI builds with the rendered Job's and CronJob's own arguments and no Secret mounted. Each must fail on its missing connection, not on its arguments.

Part of #21

🤖 Generated with Claude Code

@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Agentic Engineer

@codex review for A daily retention CronJob mirroring the migration Job from #619: image copied by kustomize replacements, migration Secret via --migration-database-projection, migration pod label, Forbid/no retries/deadline; checker, refusal tests and publication verifier.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T23:54:26.821642Z d483b31 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb647fd437

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread deploy/cronjob-portal-retention.yaml Resolved
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

✅MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Max errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 1.24s
✅ CSS stylelint 1 0 0 0 1.09s
✅ GO golangci-lint yes yes no no 133.83s
✅ GO revive 183 0 0 0.94s
✅ HTML djlint 5 0 0 1.96s
✅ HTML htmlhint 5 0 0 0.56s
✅ JSON jsonlint 2 0 0 0.13s
✅ JSON prettier 2 0 0 0 0.51s
✅ JSON v8r 2 0 0 0.93s
✅ MARKDOWN markdownlint 17 0 0 0 1.49s
✅ MARKDOWN markdown-table-formatter 17 0 0 0 0.58s
✅ REPOSITORY betterleaks yes no no 0.75s
✅ REPOSITORY checkov yes no no 17.49s
✅ REPOSITORY git_diff yes no no 0.13s
✅ REPOSITORY grype yes no no 175.34s
✅ REPOSITORY osv-scanner yes no no 161.84s
✅ REPOSITORY secretlint yes no no 1.31s
✅ REPOSITORY syft yes no no 2.64s
✅ REPOSITORY trivy yes no no 11.8s
✅ REPOSITORY trivy-sbom yes no no 0.2s
✅ REPOSITORY trufflehog yes no no 2.98s
✅ SPELL cspell 210 0 0 6.79s
✅ SPELL lychee 24 0 0 138.26s

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@10.2.0 --custom-flavor-setup --custom-flavor-linters COPYPASTE_JSCPD,CSS_STYLELINT,GO_GOLANGCI_LINT,GO_REVIVE,HTML_DJLINT,HTML_HTMLHINT,JSON_JSONLINT,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_BETTERLEAKS,REPOSITORY_GRYPE,REPOSITORY_OSV_SCANNER,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,SPELL_CSPELL,SPELL_LYCHEE

MegaLinter is provided by OX Security
Show us your support by starring ⭐ the repository

devantler and others added 2 commits November 16, 2026 00:53
The package ships cronjob-portal-retention.yaml beside the migration
Job. It runs the release's own image (kustomization.yaml copies the
WebApp's pinned image into it) once a day with
--retention-purge --migration-database-projection, reading the
platform's migration Secret as the migration role. Its pods carry the
migration Job's label, so the platform's migration network policy is
their only path to the database.

concurrencyPolicy Forbid, no retries, a 300-second deadline, 65532 with
fsGroup 65532, a memory /tmp, no service-account token and restricted
PSS, as for the migration Job. The package checker, its tests and the
publication verifier admit exactly this CronJob.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex review on #620: manifest checks cannot tell whether the image
accepts the arguments the package gives it. The runtime smoke test now
runs the image CI builds with the rendered migration Job's and retention
CronJob's arguments and no Secret mounted. Each must fail on its missing
connection, not on its arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@devantler
devantler force-pushed the claude/portal-retention-cronjob branch from fb647fd to d483b31 Compare November 15, 2026 23:53
@devantler

Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Agentic Engineer

@codex review for Re-review after rebasing onto #616 (which adds --retention-purge) and adding a runtime smoke test that runs the image with the Job's and CronJob's own arguments.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: d483b3102a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@devantler
devantler marked this pull request as ready for review November 16, 2026 00:29
@devantler
devantler requested a review from a team as a code owner November 16, 2026 00:29
@devantler
devantler merged commit 0ef227d into main Nov 16, 2026
40 of 53 checks passed
@devantler
devantler deleted the claude/portal-retention-cronjob branch November 16, 2026 00:29
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