Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default claims - fixes #1281 #1282

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the users will have to define the volumes explicitly in the CR?

I don't think we have even documented this default volume so not sure somebody used it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need a volume you're need to declare one to have one yes. Basically if not you Will always end up having PVCs / vols required that in some circumstances is not needed by default

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