Skip to content

feat: add fsck CronJob to Helm Chart [backport #999] - #1003

Merged
kalbasit merged 1 commit into
release-0.9from
backport-999-to-release-0.9
Mar 1, 2026
Merged

kalbasit merged 1 commit into
release-0.9from
backport-999-to-release-0.9

Conversation

@kalbasit

@kalbasit kalbasit commented Mar 1, 2026

Copy link
Copy Markdown
Owner

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:

  • 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).

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)
@kalbasit
kalbasit enabled auto-merge (squash) March 1, 2026 06:35
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 1, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 fsck operations, ensuring data consistency between the application's database and its storage backend. This feature improves the reliability and maintainability of deployments by proactively identifying and optionally repairing data discrepancies.

Highlights

  • New CronJob for fsck: A new Kubernetes CronJob has been added to the Helm chart to perform periodic integrity checks (fsck) between the database and storage.
  • Comprehensive Configuration: A new 'fsck' section in values.yaml provides extensive configuration options for the CronJob, including schedule, timezone, repair mode, and verified-since duration.
  • Schema Validation: JSON schema validation has been added in values.schema.json for all new fsck-related fields, ensuring proper configuration.
  • Unit Tests: A full suite of unit tests has been included in fsck_cronjob_test.yaml to verify the correct rendering and behavior of the fsck CronJob template.
Changelog
  • charts/ncps/templates/fsck-cronjob.yaml
    • Added a new Kubernetes CronJob resource definition for running periodic ncps fsck commands, configurable via Helm values.
  • charts/ncps/tests/fsck_cronjob_test.yaml
    • Introduced a comprehensive suite of unit tests to validate the rendering of the fsck-cronjob.yaml template under various configurations, including enabling, repair flags, verified-since, and job settings.
  • charts/ncps/values.schema.json
    • Extended the JSON schema to include validation rules for the new fsck configuration section, ensuring proper type and format for all related values such as enabled, schedule, repair, and job-specific settings.
  • charts/ncps/values.yaml
    • Introduced a new fsck section with default configuration values for enabling, scheduling, and configuring the integrity check CronJob, including resource limits and security contexts.
    • Modified the default lruTimezone value from 'Local' to an empty string.
Activity
  • All 98 helm-unittest cases passed, confirming the correctness of the new templates and configurations.
  • Manual template rendering verification confirmed correct flag propagation and default behavior (fsck disabled by default).
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@dosubot dosubot Bot added the helm label Mar 1, 2026
@dosubot

dosubot Bot commented Mar 1, 2026

Copy link
Copy Markdown

Related Documentation

Checked 7 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +53 to +57
command:
- sh
- -c
- |
mkdir -p $(dirname {{ .Values.config.database.sqlite.path | quote }})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-medium medium

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
  1. 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.

Comment on lines +175 to +177
{{- if not (kindIs "invalid" .Values.fsck.job.backoffLimit) }}
backoffLimit: {{ .Values.fsck.job.backoffLimit }}
{{- end }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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
  1. In Helm templates, to default a boolean value to true unless it is explicitly false, prefer the concise {{ ne .Value false }} expression over a more verbose if kindIs "bool" ... block, as it achieves the same result for boolean, null, or unset values. This principle extends to using ne .Value nil for checking general unset or null values.

Comment on lines +178 to +180
{{- if not (kindIs "invalid" .Values.fsck.job.ttlSecondsAfterFinished) }}
ttlSecondsAfterFinished: {{ .Values.fsck.job.ttlSecondsAfterFinished }}
{{- end }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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
  1. In Helm templates, to default a boolean value to true unless it is explicitly false, prefer the concise {{ ne .Value false }} expression over a more verbose if kindIs "bool" ... block, as it achieves the same result for boolean, null, or unset values. This principle extends to using ne .Value nil for checking general unset or null values.

@kalbasit
kalbasit merged commit 85ec7ef into release-0.9 Mar 1, 2026
10 checks passed
@kalbasit
kalbasit deleted the backport-999-to-release-0.9 branch March 1, 2026 06:47
@codecov

codecov Bot commented Mar 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 5.04%. Comparing base (9513b23) to head (5a125ca).
⚠️ Report is 2 commits behind head on release-0.9.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

helm size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant