Repository navigation
feat: support temp volume as volumeClaimTemplate in StatefulSet [backport #1077] - #1078
Conversation
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)
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 enhances the Helm chart to properly manage temporary volumes for applications deployed as StatefulSets. Previously, temporary PVCs could lead to shared storage or emptyDir volumes across replicas. The changes introduce Highlights
Changelog
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 correctly implements support for using volumeClaimTemplate for temporary volumes in a StatefulSet, which is a valuable enhancement for high-availability deployments. The logic is sound, the changes are well-contained, and the new test cases provide good coverage. I have one suggestion to improve the robustness of the new helper template against potential misconfiguration.
| accessModes: | ||
| {{- range .Values.config.cache.tempVolume.pvc.accessModes }} | ||
| - {{ . | quote }} | ||
| {{- end }} |
There was a problem hiding this comment.
The current implementation will render an invalid accessModes field if .Values.config.cache.tempVolume.pvc.accessModes is an empty list, which would cause the Helm release to fail during Kubernetes resource validation. To improve robustness, it's better to add a validation check that fails the template rendering with a clear error message if accessModes is empty.
accessModes:
{{- if not .Values.config.cache.tempVolume.pvc.accessModes }}
{{- fail "config.cache.tempVolume.pvc.accessModes must not be empty when tempVolume.type is pvc" }}
{{- end }}
{{- range .Values.config.cache.tempVolume.pvc.accessModes }}
- {{ . | quote }}
{{- end }}
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-0.9 #1078 +/- ##
===========================================
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 #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.