Repository navigation
feat(helm): add configurable policy CronJobs to the dirctl chart - #1994
Merged
Merged
Conversation
csirmazbendeguz
approved these changes
Aug 7, 2026
There was a problem hiding this comment.
Pull request overview
Adds configurable Helm-managed policy CronJobs that search for records and then sync, prune, publish, or unpublish them.
Changes:
- Generates policy shell pipelines through the existing CronJob template.
- Adds policy examples, documentation, and rendering tests.
- Adds a Taskfile command for Helm policy tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
Taskfile.yml |
Adds the Helm test task. |
install/charts/dirctl/values.yaml |
Defines example policies and configuration guidance. |
install/charts/dirctl/templates/cronjob.yaml |
Integrates policies into CronJob rendering. |
install/charts/dirctl/templates/_policies.tpl |
Generates policy flags and shell pipelines. |
install/charts/dirctl/ci/test-policies.sh |
Tests rendered policy behavior. |
install/charts/dirctl/ci/policies-values.yaml |
Supplies policy test fixtures. |
install/charts/dirctl/.helmignore |
Excludes test fixtures from chart packages. |
docs/content/dir/dir-deployment-kubernetes.md |
Documents content policies and actions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Signed-off-by: András Jáky <[email protected]>
…ive actions Signed-off-by: András Jáky <[email protected]>
akijakya
force-pushed
the
feat/policy-cronjob-helm
branch
from
August 7, 2026 11:39
37633ea to
520f57c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1977. Depends on #1987 (merged) for
--trusted=false, and #1979 for a shell-capable image.What
A node-level content policy — "sync every record in a given domain", "drop records that aren't signed" — previously meant a forked chart or hand-written manifests. The
cronjobsmap runs a singledirctlcall per entry, and a policy is a pipeline: search, then act on the result.policiesdeclares that pipeline from values alone:Four actions, each pairing a search source with a
--stdinsink:syncdirctl routing searchdirctl sync create --stdinprunedirctl searchdirctl delete --stdinpublishdirctl searchdirctl routing publish --stdinunpublishdirctl searchdirctl routing unpublish --stdinRendered outcome
Both examples ship
enabled: false. Enabling them produces exactly this — nothing elided:prune-untrusted— full CronJobsync-netsec, schedule0 3 * * *— same resource shape, differing only in the script:With
dryRun: truethe sink line is replaced byecho "[prune-untrusted] dry run: not applying action 'prune'"— inside the loop, for the paginated actions, so a dry run still reports every page.Design notes
matchkeys aredirctlflag names, passed through mechanically rather than mapped against a whitelist. List → flag repeated per item; bool →--flag=true|false; scalar →--flag 'value'. Any filter the CLI grows works with no chart change — including the--exclude-*flags from #1987, which did not exist when the template was written:The trade is that an unrecognised-but-well-formed key surfaces at run time. Anything that would be silent-wrong rather than loudly-wrong is rejected at
helm templatetime:limit/offset/format/outputinsidematchaction'^[a-z0-9][a-z0-9-]*$name; rm -rf /would be executable shelllimitthat is not a positive integersyncpolicy with noskill/domain/locator/moduledirctl routing searchrequires a criterion; without one it exits 0 printing nothingThree details in the generated script are load-bearing:
cli/util/cids.Collectreturns"at least one CID is required"on empty stdin, sodirctl delete|routing publish|routing unpublish --stdinfail on an empty array. Without the guard, a policy matching nothing would fail on every run.dirctl routing searchdoes exactly that with no criteria, reporting to stderr. That leavescountempty, and[ "" -eq 0 ]errors; because it is anifcondition,set -edoes not stop the script, so it would fall through to the sink with empty input.[ -z "$out" ]turns that into a clear failure.set -o pipefail. Capturing the search into a variable underset -eusurfaces a failing search without it, and yields the match count and dry-run dump for free. (busybox ash does supportpipefail; this shape was preferred for the count, not out of necessity.)Pagination differs by action, because only some of them change whether a record still matches:
prunepublish,unpublish--offsetuntil a short page comes back.syncdirctl routing searchhas no--offset. Processes the firstlimitmatches only; documented as a constraint onlimit.Policies render through the existing
cronjobsloop aspolicy-<name>entries, inheriting the SPIRE, env, volume, resource and security wiring without duplicating the ~100-line pod spec.env,resources,volumes,volumeMounts,concurrencyPolicyand the history limits work per policy exactly as for acronjobsentry. Thepolicy-prefix keeps a policy and acronjobsentry of the same name from colliding.command:now renders viatoYaml, giving the|-block above rather than one escaped line, so the script stays readable inkubectl get cronjob -o yaml. Verified byte-identical output for plain single-line command lists.Notes for reviewers
syncreads the routing index, not the local store, so its usablematchkeys are only thosedirctl routing searchaccepts:skill,domain,locator,module,min-score. The presence of at least one is enforced at template time; which other keys are valid is documented, not enforced, since enforcing that would mean the whitelist the passthrough design avoids.cronjobsexamples which areenabled: true. A default-onprunethat deletes untrusted records is not a default worth having.matchmerges rather than replaces it (Helm deep-merge). Settingmatch: {trusted: false}onprune-untrustedyields--scan-severity 'MEDIUM' --trusted=false. Use a new policy key to avoid this.safe: falseis not the complement ofsafe: true— it matches records with an explicit unsafe scan report, while never-scanned records match neither. Aprunekeyed on it silently spares unscanned records. Called out in a warning admonition in the docs, since it is the kind of thing that makes a destructive policy act on the wrong population.limit: 0is rejected rather than silently becoming 100. Sprig'sdefaulttreats0as empty, so the obvious$policy.limit | default 100would have swallowed it; the template useshasKeyinstead.Testing
install/charts/dirctl/ci/test-policies.sh+task test:helm: 25 assertions overhelm templateoutput covering every action, everymatchvalue kind, per-action pagination, the dry-run path, the disabled path, both guards, the absence ofpipefail, and all six template-time rejections.helm lintcannot check any of this — it only verifies the chart renders. Wired into theLintCI job, which the path filter runs for chart changes. Mutation-tested: breakingdirctl delete --stdinin the template makes the suite fail and exit 1.Beyond that:
helm templateoutput is byte-identical to before this PR.dirctlinvocations were extracted from the manifests and run against the CLI on this branch; each parses and fails only on TCP connect, confirming no unknown flags.runAsUser: 65532,readOnlyRootFilesystem: true,emptyDirat/home/nonroot):/bin/shandjqpresent,dirctlresolves onPATHafter the ENTRYPOINT override, empty match set exits 0, non-empty reaches the sink.ashagainst a stub returning two full pages then a short one: it iterates, stops on the short page, and reports the correct total.Not verified: no live-cluster run. Everything above is rendering plus container-level execution, not a CronJob observed firing in a cluster.
syncis the least covered — it reads the routing index, so a single-node environment can never make it match.Docs
docs/content/dir/dir-deployment-kubernetes.mdgains a Content Policies section: the action table,matchvalue kinds, theexclude-example, thesynccaveat, the field reference, the per-action pagination table, a warning thatsafe: falseis not the complement ofsafe: true, and a dry-run admonition showing real log output.