From c9cb34d83266408469ebeef406549996fa0b459c 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/container.go | 5 ----- pkg/collector/volumeclaim.go | 20 ++------------------ pkg/collector/volumeclaim_test.go | 25 ------------------------- 3 files changed, 2 insertions(+), 48 deletions(-) diff --git a/pkg/collector/container.go b/pkg/collector/container.go index 0428243088..6db2e3aed1 100644 --- a/pkg/collector/container.go +++ b/pkg/collector/container.go @@ -76,11 +76,6 @@ func Container(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelem if len(otelcol.Spec.VolumeMounts) > 0 { volumeMounts = append(volumeMounts, otelcol.Spec.VolumeMounts...) - } else if otelcol.Spec.Mode == "statefulset" { - volumeMounts = append(volumeMounts, corev1.VolumeMount{ - Name: "default-volume", - MountPath: "/usr/share/default-volume", - }) } var envVars = otelcol.Spec.Env 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{