From 99de33f6159ac7d0ce9f22cbe899eff1f16e7cb4 Mon Sep 17 00:00:00 2001 From: Robert Marsal <507871+robertmarsal@users.noreply.github.com> Date: Wed, 22 Oct 2025 14:56:46 +0100 Subject: [PATCH] feat: add support for `volumeAttributesClass` for pvcs (#396) closes #365 --- charts/qdrant/templates/statefulset.yaml | 6 ++++ charts/qdrant/values.yaml | 2 ++ test/qdrant_statefulset_test.go | 38 ++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/charts/qdrant/templates/statefulset.yaml b/charts/qdrant/templates/statefulset.yaml index c0aa419..a4a6d8a 100644 --- a/charts/qdrant/templates/statefulset.yaml +++ b/charts/qdrant/templates/statefulset.yaml @@ -266,6 +266,9 @@ spec: {{- end }} spec: storageClassName: {{ .Values.persistence.storageClassName }} + {{- if .Values.persistence.volumeAttributesClassName }} + volumeAttributesClassName: {{ .Values.persistence.volumeAttributesClassName }} + {{- end }} accessModes: {{- range .Values.persistence.accessModes }} - {{ . | quote }} @@ -284,6 +287,9 @@ spec: {{- end }} spec: storageClassName: {{ .Values.snapshotPersistence.storageClassName }} + {{- if .Values.snapshotPersistence.volumeAttributesClassName }} + volumeAttributesClassName: {{ .Values.snapshotPersistence.volumeAttributesClassName }} + {{- end }} accessModes: {{- range .Values.snapshotPersistence.accessModes }} - {{ . | quote }} diff --git a/charts/qdrant/values.yaml b/charts/qdrant/values.yaml index 77bc0b8..ab17bc0 100644 --- a/charts/qdrant/values.yaml +++ b/charts/qdrant/values.yaml @@ -148,6 +148,7 @@ persistence: # storageVolumeName: qdrant-storage # storageSubPath: "" # storageClassName: local-path + # volumeAttributesClassName: "" # If you use snapshots or the snapshot shard transfer mechanism, we recommend # creating a separate volume of the same size as your main volume so that your @@ -161,6 +162,7 @@ snapshotPersistence: # snapshotsSubPath: "" # You can change the storageClassName to ensure snapshots are saved to cold storage. # storageClassName: local-path + # volumeAttributesClassName: "" snapshotRestoration: enabled: false diff --git a/test/qdrant_statefulset_test.go b/test/qdrant_statefulset_test.go index 9659430..d56ddec 100644 --- a/test/qdrant_statefulset_test.go +++ b/test/qdrant_statefulset_test.go @@ -1,15 +1,16 @@ package test import ( + "path/filepath" + "strings" + "testing" + "github.com/gruntwork-io/terratest/modules/helm" "github.com/gruntwork-io/terratest/modules/k8s" "github.com/gruntwork-io/terratest/modules/logger" "github.com/gruntwork-io/terratest/modules/random" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" - "path/filepath" - "strings" - "testing" ) func TestContainerSecurityContextUserAndGroupDefault(t *testing.T) { @@ -69,3 +70,34 @@ func TestContainerSecurityContextUserAndGroupLargeValues(t *testing.T) { require.Equal(t, int64(1000740000), *statefulSet.Spec.Template.Spec.SecurityContext.FSGroup) require.Equal(t, int64(1000840000), *statefulSet.Spec.Template.Spec.Containers[0].SecurityContext.RunAsGroup) } + +func TestCanAttachVolumeAttributesClassToPersistence(t *testing.T) { + t.Parallel() + + helmChartPath, err := filepath.Abs("../charts/qdrant") + releaseName := "qdrant" + require.NoError(t, err) + + namespaceName := "qdrant-" + strings.ToLower(random.UniqueId()) + logger.Log(t, "Namespace: %s\n", namespaceName) + + options := &helm.Options{ + SetJsonValues: map[string]string{ + "persistence": `{ + "volumeAttributesClassName": "my-class" + }`, + "snapshotPersistence": `{ + "enabled": true, + "volumeAttributesClassName": "my-class" + }`, + }, + KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName), + } + + statefulsetOutput := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"}) + + var statefulSet appsv1.StatefulSet + helm.UnmarshalK8SYaml(t, statefulsetOutput, &statefulSet) + require.Equal(t, "my-class", *statefulSet.Spec.VolumeClaimTemplates[0].Spec.VolumeAttributesClassName) + require.Equal(t, "my-class", *statefulSet.Spec.VolumeClaimTemplates[1].Spec.VolumeAttributesClassName) +}