From c16b69f6eb7658d76ba38cec0c4c78265ed640e3 Mon Sep 17 00:00:00 2001 From: Endre Karlson Date: Sun, 27 Nov 2022 20:03:27 +0100 Subject: [PATCH] Remove default claims - fixes #1281 --- pkg/collector/volumeclaim.go | 20 ++------------------ pkg/collector/volumeclaim_test.go | 25 ------------------------- 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/pkg/collector/volumeclaim.go b/pkg/collector/volumeclaim.go index b35d830b0f..c249e5813c 100644 --- a/pkg/collector/volumeclaim.go +++ b/pkg/collector/volumeclaim.go @@ -17,8 +17,6 @@ package collector import ( corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/config" @@ -35,22 +33,8 @@ func VolumeClaimTemplates(cfg config.Config, otelcol v1alpha1.OpenTelemetryColle } // Add all user specified claims or use default. - if len(otelcol.Spec.VolumeClaimTemplates) > 0 { - volumeClaimTemplates = append(volumeClaimTemplates, - otelcol.Spec.VolumeClaimTemplates...) - } else { - volumeClaimTemplates = []corev1.PersistentVolumeClaim{{ - ObjectMeta: metav1.ObjectMeta{ - Name: "default-volume", - }, - Spec: corev1.PersistentVolumeClaimSpec{ - AccessModes: []corev1.PersistentVolumeAccessMode{"ReadWriteOnce"}, - Resources: corev1.ResourceRequirements{ - Requests: corev1.ResourceList{"storage": resource.MustParse("50Mi")}, - }, - }, - }} - } + volumeClaimTemplates = append(volumeClaimTemplates, + otelcol.Spec.VolumeClaimTemplates...) return volumeClaimTemplates } diff --git a/pkg/collector/volumeclaim_test.go b/pkg/collector/volumeclaim_test.go index 360ba906cc..7cf47c42b2 100644 --- a/pkg/collector/volumeclaim_test.go +++ b/pkg/collector/volumeclaim_test.go @@ -27,31 +27,6 @@ import ( . "github.com/open-telemetry/opentelemetry-operator/pkg/collector" ) -func TestVolumeClaimNewDefault(t *testing.T) { - // prepare - otelcol := v1alpha1.OpenTelemetryCollector{ - Spec: v1alpha1.OpenTelemetryCollectorSpec{ - Mode: "statefulset", - }, - } - cfg := config.New() - - // test - volumeClaims := VolumeClaimTemplates(cfg, otelcol) - - // verify - assert.Len(t, volumeClaims, 1) - - // check that it's the initial-volume - assert.Equal(t, "default-volume", volumeClaims[0].Name) - - // check the access mode is correct - assert.Equal(t, corev1.PersistentVolumeAccessMode("ReadWriteOnce"), volumeClaims[0].Spec.AccessModes[0]) - - //check the storage is correct - assert.Equal(t, resource.MustParse("50Mi"), volumeClaims[0].Spec.Resources.Requests["storage"]) -} - func TestVolumeClaimAllowsUserToAdd(t *testing.T) { // prepare otelcol := v1alpha1.OpenTelemetryCollector{