Repository navigation
feat: add fsck CronJob to Helm Chart [backport #999] - #1003
Conversation
Added a CronJob to the Helm chart to run periodic integrity checks (fsck). This allows users to automate the consistency checks between the database and storage. The implementation includes: - New 'fsck' section in values.yaml with comprehensive configuration options. - Added JSON schema validation for all new fsck fields in values.schema.json. - Created a new fsck-cronjob.yaml template that uses 'ncps fsck' with configurable '--repair' and '--verified-since' flags. - Added a full suite of unit tests in fsck_cronjob_test.yaml to verify template rendering. Verification: - All 98 helm-unittest cases passed. - Manual template rendering verified correct flag propagation and default behavior (disabled by default). (cherry picked from commit 802523e)
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant enhancement by integrating automated integrity checks into the Helm chart. It allows users to schedule and configure periodic Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a fsck CronJob to the Helm chart, allowing for periodic integrity checks. A potential command injection vulnerability was identified in the initContainer of the CronJob template, where a configuration value is directly interpolated into a shell command. This should be remediated by passing the value as a positional parameter to the shell script, aligning with our guidelines to prevent unsafe configurations in Helm charts. Additionally, there are suggestions to improve the readability of the new Helm template by using more idiomatic ne .Value nil checks over kindIs "invalid", consistent with our Helm templating best practices.
| command: | ||
| - sh | ||
| - -c | ||
| - | | ||
| mkdir -p $(dirname {{ .Values.config.database.sqlite.path | quote }}) |
There was a problem hiding this comment.
The initContainer named create-db-dir uses a shell command to create the database directory. The path is interpolated directly into the shell script using .Values.config.database.sqlite.path. If an attacker can control this value (e.g., through a management platform that allows customizing Helm values), they can perform command injection. For example, setting the path to "/storage/db/$(touch /tmp/pwned).db" would execute touch /tmp/pwned in the context of the initContainer. Although the container runs with restricted privileges, it still has access to the storage volume containing sensitive data like the database and NAR files.
initContainers:
- name: create-db-dir
image: {{ include "ncps.initImage" . }}
imagePullPolicy: {{ .Values.initImage.pullPolicy }}
command:
- sh
- -c
- |
mkdir -p "$(dirname "$1")"
- --
- {{ .Values.config.database.sqlite.path | quote }}References
- In Helm charts, prevent unsafe configurations (e.g., High Availability with initContainer migrations) by adding validation logic that fails template rendering, rather than relying only on documentation.
| {{- if not (kindIs "invalid" .Values.fsck.job.backoffLimit) }} | ||
| backoffLimit: {{ .Values.fsck.job.backoffLimit }} | ||
| {{- end }} |
There was a problem hiding this comment.
While kindIs "invalid" works for checking if a value is nil, a more idiomatic and readable approach in Helm templates is to directly compare with nil using ne .Value nil. This aligns with the principle of preferring concise expressions over verbose kindIs checks for unset or null values, making the template's intent clearer and improving maintainability.
{{- if ne .Values.fsck.job.backoffLimit nil }}
backoffLimit: {{ .Values.fsck.job.backoffLimit }}
{{- end }}References
- In Helm templates, to default a boolean value to
trueunless it is explicitlyfalse, prefer the concise{{ ne .Value false }}expression over a more verboseif kindIs "bool" ...block, as it achieves the same result for boolean, null, or unset values. This principle extends to usingne .Value nilfor checking general unset or null values.
| {{- if not (kindIs "invalid" .Values.fsck.job.ttlSecondsAfterFinished) }} | ||
| ttlSecondsAfterFinished: {{ .Values.fsck.job.ttlSecondsAfterFinished }} | ||
| {{- end }} |
There was a problem hiding this comment.
Similar to the backoffLimit check, using a direct comparison with nil using ne .Value nil is more idiomatic and readable than kindIs "invalid" for checking if ttlSecondsAfterFinished is set. This aligns with the principle of preferring concise expressions over verbose kindIs checks for unset or null values, improving code clarity.
{{- if ne .Values.fsck.job.ttlSecondsAfterFinished nil }}
ttlSecondsAfterFinished: {{ .Values.fsck.job.ttlSecondsAfterFinished }}
{{- end }}References
- In Helm templates, to default a boolean value to
trueunless it is explicitlyfalse, prefer the concise{{ ne .Value false }}expression over a more verboseif kindIs "bool" ...block, as it achieves the same result for boolean, null, or unset values. This principle extends to usingne .Value nilfor checking general unset or null values.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-0.9 #1003 +/- ##
===========================================
Coverage 5.04% 5.04%
===========================================
Files 6 6
Lines 436 436
===========================================
Hits 22 22
Misses 410 410
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bot-based backport to
release-0.9, triggered by a label in #999.Added a CronJob to the Helm chart to run periodic integrity checks (fsck). This allows users to automate the consistency checks between the database and storage.
The implementation includes:
Verification: