Skip to content

Commit

Permalink
Remove default PV claims - fixes open-telemetry#1281 (open-telemetry#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ekarlso authored and ihalaij1 committed Dec 8, 2022
1 parent e9e1b80 commit d483622
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 48 deletions.
5 changes: 0 additions & 5 deletions pkg/collector/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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 d483622

Please sign in to comment.