Skip to content

Commit

Permalink
Remove default claims - fixes #1281
Browse files Browse the repository at this point in the history
  • Loading branch information
ekarlso committed Nov 27, 2022
1 parent 30561f0 commit c16b69f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
20 changes: 2 additions & 18 deletions pkg/collector/volumeclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}
25 changes: 0 additions & 25 deletions pkg/collector/volumeclaim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit c16b69f

Please sign in to comment.