Skip to content

Commit d232978

Browse files
authored
Make additional pvc labels consistent to additional labels of other resources, adds test (#423)
1 parent c3f7796 commit d232978

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

charts/qdrant/templates/statefulset.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ spec:
260260
name: {{ .Values.persistence.storageVolumeName | default "qdrant-storage" }}
261261
labels:
262262
app: {{ template "qdrant.name" . }}
263-
{{- with .Values.persistence.labels }}
263+
{{- with .Values.persistence.additionalLabels }}
264264
{{- toYaml . | nindent 10 }}
265265
{{- end }}
266266
{{- with .Values.persistence.annotations }}
@@ -284,7 +284,7 @@ spec:
284284
name: {{ .Values.snapshotPersistence.snapshotsVolumeName | default "qdrant-snapshots" }}
285285
labels:
286286
app: {{ template "qdrant.name" . }}
287-
{{- with .Values.snapshotPersistence.labels }}
287+
{{- with .Values.snapshotPersistence.additionalLabels }}
288288
{{- toYaml . | nindent 10 }}
289289
{{- end }}
290290
{{- with .Values.snapshotPersistence.annotations }}

charts/qdrant/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ persistence:
145145
accessModes: ["ReadWriteOnce"]
146146
size: 10Gi
147147
annotations: {}
148-
labels: {}
148+
additionalLabels: {}
149149
# storageVolumeName: qdrant-storage
150150
# storageSubPath: ""
151151
# storageClassName: local-path
@@ -159,7 +159,7 @@ snapshotPersistence:
159159
accessModes: ["ReadWriteOnce"]
160160
size: 10Gi
161161
annotations: {}
162-
labels: {}
162+
additionalLabels: {}
163163
# snapshotsVolumeName: qdrant-snapshots
164164
# snapshotsSubPath: ""
165165
# You can change the storageClassName to ensure snapshots are saved to cold storage.

test/qdrant_additional_labels_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,33 @@ func TestAdditionalLabelsAreSetOnIngress(t *testing.T) {
152152
require.Contains(t, ingress.Labels, "test")
153153
require.Equal(t, "ingressAdditionalLabels", ingress.Labels["test"])
154154
}
155+
156+
func TestAdditionalLabelsAreSetOnPvcs(t *testing.T) {
157+
t.Parallel()
158+
159+
helmChartPath, err := filepath.Abs("../charts/qdrant")
160+
releaseName := "qdrant"
161+
require.NoError(t, err)
162+
163+
namespaceName := "qdrant-" + strings.ToLower(random.UniqueId())
164+
logger.Log(t, "Namespace: %s\n", namespaceName)
165+
166+
options := &helm.Options{
167+
SetJsonValues: map[string]string{
168+
"persistence.additionalLabels": `{"test": "additionalPersistenceLabel"}`,
169+
"snapshotPersistence.enabled": `true`,
170+
"snapshotPersistence.additionalLabels": `{"test": "additionalSnapshotPersistenceLabel"}`,
171+
},
172+
KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName),
173+
}
174+
175+
output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/statefulset.yaml"})
176+
177+
var sts appsv1.StatefulSet
178+
helm.UnmarshalK8SYaml(t, output, &sts)
179+
180+
require.Contains(t, sts.Spec.VolumeClaimTemplates[0].Labels, "test")
181+
require.Equal(t, "additionalPersistenceLabel", sts.Spec.VolumeClaimTemplates[0].Labels["test"])
182+
require.Contains(t, sts.Spec.VolumeClaimTemplates[1].Labels, "test")
183+
require.Equal(t, "additionalSnapshotPersistenceLabel", sts.Spec.VolumeClaimTemplates[1].Labels["test"])
184+
}

0 commit comments

Comments
 (0)