Skip to content

feat: support temp volume as volumeClaimTemplate in StatefulSet - #1077

Merged
kalbasit merged 2 commits into
mainfrom
feat-support-temp-volume-as
Mar 12, 2026
Merged

kalbasit merged 2 commits into
mainfrom
feat-support-temp-volume-as

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

This change allows the ncps Helm chart to use a volumeClaimTemplate for the temporary volume when the application is running in StatefulSet mode and config.cache.tempVolume.type is set to pvc.

Previously, the temporary volume was always rendered as a regular volume in the Pod spec, which meant all replicas in a StatefulSet would share the same PVC if a name was provided, or each would get a separate emptyDir if that was the type.

By using volumeClaimTemplates, Kubernetes automatically creates a unique PVC for each replica, providing better isolation and persistence for temporary data (like chunking/downloads) in HA deployments.

The temp-pvc.yaml template was updated to only render in deployment mode, as it's redundant (and potentially conflicting) for StatefulSet mode.

Tests were updated to verify the correct rendering in both StatefulSet and Deployment modes.

This change allows the ncps Helm chart to use a volumeClaimTemplate for the temporary volume when the application is running in StatefulSet mode and config.cache.tempVolume.type is set to pvc.

Previously, the temporary volume was always rendered as a regular volume in the Pod spec, which meant all replicas in a StatefulSet would share the same PVC if a name was provided, or each would get a separate emptyDir if that was the type.

By using volumeClaimTemplates, Kubernetes automatically creates a unique PVC for each replica, providing better isolation and persistence for temporary data (like chunking/downloads) in HA deployments.

The temp-pvc.yaml template was updated to only render in deployment mode, as it's redundant (and potentially conflicting) for StatefulSet mode.

Tests were updated to verify the correct rendering in both StatefulSet and Deployment modes.
@kalbasit

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request helm labels Mar 12, 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 significantly enhances the ncps Helm chart's capability to manage temporary volumes for applications deployed as Kubernetes StatefulSets. By introducing volumeClaimTemplates for temporary PVCs, it ensures proper isolation and persistence of temporary data across individual replicas, addressing previous limitations where temporary volumes were either shared or ephemeral. This change improves the robustness and scalability of StatefulSet deployments requiring dedicated temporary storage.

Highlights

  • StatefulSet Temporary Volume Management: Enabled the ncps Helm chart to utilize volumeClaimTemplate for temporary volumes within StatefulSet deployments when the tempVolume.type is set to pvc.
  • Improved Volume Isolation: Switched from rendering temporary volumes as regular Pod spec volumes to using volumeClaimTemplates, ensuring each StatefulSet replica receives a unique and isolated PVC for temporary data.
  • Helm Chart Logic Refinement: Modified the temp-pvc.yaml template to only render when the application is in deployment mode, preventing conflicts and redundancy in StatefulSet configurations.
  • Test Coverage Expansion: Updated existing tests and added new ones to verify the correct rendering of temporary volumes in both StatefulSet and Deployment modes, covering various PVC configurations.
Changelog
  • charts/ncps/templates/_helpers.tpl
    • Added a new helper template ncps.tempVolumeClaimTemplate to define the structure for a temporary volume claim template.
  • charts/ncps/templates/statefulset.yaml
    • Modified the inclusion of ncps.tempVolume to be conditional, excluding it when a new temporary PVC is to be created via volumeClaimTemplates.
    • Introduced logic to conditionally include the ncps.tempVolumeClaimTemplate helper within the volumeClaimTemplates section of the StatefulSet spec, specifically for temporary PVCs.
  • charts/ncps/templates/temp-pvc.yaml
    • Updated the rendering condition to ensure this template only creates a PersistentVolumeClaim resource when the Helm chart is deployed in deployment mode.
  • charts/ncps/tests/temp_volume_test.yaml
    • Added new test cases to verify that StatefulSet deployments correctly use volumeClaimTemplates for temporary PVCs and do not include them in spec.template.spec.volumes.
    • Included tests to confirm that existing PVC claims are correctly referenced in StatefulSet volumes.
    • Modified existing tests to explicitly specify mode: deployment for scenarios where a standalone PersistentVolumeClaim is expected.
    • Added a test to ensure no standalone PersistentVolumeClaim is created in StatefulSet mode.
Activity
  • No human activity (comments, reviews, etc.) has been recorded on this pull request yet.
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. ↩

@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 support for using volumeClaimTemplate for the temporary volume in StatefulSet mode, which is a great improvement for HA deployments. The changes are well-structured, with a new helper for the template, updated logic in the StatefulSet manifest, and corresponding adjustments to the standalone PVC and tests. The test suite has been thoroughly updated to cover the new functionality and edge cases.

I've found a couple of issues related to incorrect indentation in the new ncps.tempVolumeClaimTemplate helper, which would cause the Helm chart to render invalid YAML. My review comments provide specific fixes for these. Otherwise, the implementation looks solid.

Comment thread charts/ncps/templates/_helpers.tpl Resolved
Comment thread charts/ncps/templates/_helpers.tpl Resolved
@codecov

codecov Bot commented Mar 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 5.04%. Comparing base (46a2d0e) to head (13df24c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1077   +/-   ##
=====================================
  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.

This adds comprehensive unit tests for the recently added volumeClaimTemplates support for temporary volumes in the StatefulSet mode. It validates that annotations and selectors are correctly rendered with the expected indentation in the final manifest.

The tests ensure:
- Annotations are correctly passed to the volumeClaimTemplate's metadata.
- Selectors are correctly passed to the volumeClaimTemplate's spec.
- Indentation in the final output matches the surrounding template (10 spaces for content blocks).

Also addressed PR feedback regarding indentation logic in the helpers.
@kalbasit kalbasit added the backport release-0.9 Backport PR automatically label Mar 12, 2026
@kalbasit
kalbasit enabled auto-merge (squash) March 12, 2026 16:12
@kalbasit
kalbasit merged commit 4d4123e into main Mar 12, 2026
17 checks passed
@kalbasit
kalbasit deleted the feat-support-temp-volume-as branch March 12, 2026 16:26
kalbasit added a commit that referenced this pull request Mar 12, 2026
This change allows the ncps Helm chart to use a volumeClaimTemplate for
the temporary volume when the application is running in StatefulSet mode
and config.cache.tempVolume.type is set to pvc.

Previously, the temporary volume was always rendered as a regular volume
in the Pod spec, which meant all replicas in a StatefulSet would share
the same PVC if a name was provided, or each would get a separate
emptyDir if that was the type.

By using volumeClaimTemplates, Kubernetes automatically creates a unique
PVC for each replica, providing better isolation and persistence for
temporary data (like chunking/downloads) in HA deployments.

The temp-pvc.yaml template was updated to only render in deployment
mode, as it's redundant (and potentially conflicting) for StatefulSet
mode.

Tests were updated to verify the correct rendering in both StatefulSet
and Deployment modes.

(cherry picked from commit 4d4123e)
@kalbasit

Copy link
Copy Markdown
Owner Author

Successfully created backport PR for release-0.9:

kalbasit added a commit that referenced this pull request Mar 12, 2026
…port #1077] (#1078)

Bot-based backport to `release-0.9`, triggered by a label in #1077.

This change allows the ncps Helm chart to use a volumeClaimTemplate for
the temporary volume when the application is running in StatefulSet mode
and config.cache.tempVolume.type is set to pvc.

Previously, the temporary volume was always rendered as a regular volume
in the Pod spec, which meant all replicas in a StatefulSet would share
the same PVC if a name was provided, or each would get a separate
emptyDir if that was the type.

By using volumeClaimTemplates, Kubernetes automatically creates a unique
PVC for each replica, providing better isolation and persistence for
temporary data (like chunking/downloads) in HA deployments.

The temp-pvc.yaml template was updated to only render in deployment
mode, as it's redundant (and potentially conflicting) for StatefulSet
mode.

Tests were updated to verify the correct rendering in both StatefulSet
and Deployment modes.
kalbasit added a commit that referenced this pull request Jun 8, 2026
## Summary

The `[Unreleased]` section was populated in #1309 but skewed toward the
recent CDC-drain, in-flight-staging, and Ent-migration work, omitting
several user-facing features and fixes that also landed since v0.9.4.
This backfills the missing notable changes, each cross-referenced by PR.

**Added**
- `ncps fsck` command + Helm fsck CronJob (#975, #996, #998, #999,
#1000, #1004, #1006, #1176)
- Closure pinning HTTP endpoints `POST`/`DELETE /pin/{hash}.narinfo`,
`GET /pins` (#1108)
- pprof server via `--pprof-addr` (#1063)
- CDC lazy chunking as a feature + `--cache-cdc-lazy-cleanup-schedule` +
recovery cron (#1082, #1083, #1089, #1096)
- Helm: auto `GOMEMLIMIT` (#1061), configurable temp volume /
`volumeClaimTemplate` (#1074, #1077), SQLite `Recreate` strategy (#1012)
- Startup storage reporting + deprecated-narinfo warning (#959, #961)
- `docker-dev` image (#1097)

**Fixed**
- `store/tmp` no longer wiped on startup (#1313)
- `nix-hash` NAR verification (#1101)
- Prometheus counters primed at startup (#1337, #1343)
- 404 on un-reassemblable chunked NARs (#1319), purged narinfo no longer
500 (#1318), fail-fast tmp validation (#1086)
- Further CDC/cache reliability fixes (#1317, #1346, #1341, #1342,
#1331, #1347)

**Changed**
- CDC config now persisted in the DB config table (#971)

Dependency bumps, CI/test-only changes, and the internal Ent-conversion
PRs are intentionally excluded; the existing Ent-migration entry already
covers that work.

## Test plan

- [x] `nix fmt` reports no changes (docs-only edit)
- [x] CHANGELOG section structure intact
(Added/Fixed/Changed/Removed/Migration/CI)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport release-0.9 Backport PR automatically enhancement New feature or request 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