diff --git a/internal/vector/aggregator/deployment.go b/internal/vector/aggregator/deployment.go index d869bd7..2fdb5da 100644 --- a/internal/vector/aggregator/deployment.go +++ b/internal/vector/aggregator/deployment.go @@ -197,26 +197,12 @@ func (ctrl *Controller) generateVectorAggregatorVolume() []corev1.Volume { Name: "config", VolumeSource: configVolumeSource, }, - { - Name: "procfs", - VolumeSource: corev1.VolumeSource{ - HostPath: &corev1.HostPathVolumeSource{ - Path: "/proc", - }, - }, - }, - { - Name: "sysfs", - VolumeSource: corev1.VolumeSource{ - HostPath: &corev1.HostPathVolumeSource{ - Path: "/sys", - }, - }, - }, } // In persistent mode the data volume comes from the StatefulSet volume claim // template, so only add the hostPath data volume for the Deployment path. + // Keep it right after "config": reordering the volume list changes the pod + // template and rolls every non-persistent aggregator on operator upgrade. if !ctrl.persistenceEnabled() { requiredVolumes = append(requiredVolumes, corev1.Volume{ Name: dataVolumeName, @@ -228,6 +214,25 @@ func (ctrl *Controller) generateVectorAggregatorVolume() []corev1.Volume { }) } + requiredVolumes = append(requiredVolumes, + corev1.Volume{ + Name: "procfs", + VolumeSource: corev1.VolumeSource{ + HostPath: &corev1.HostPathVolumeSource{ + Path: "/proc", + }, + }, + }, + corev1.Volume{ + Name: "sysfs", + VolumeSource: corev1.VolumeSource{ + HostPath: &corev1.HostPathVolumeSource{ + Path: "/sys", + }, + }, + }, + ) + // Only add volumes that don't already exist for _, reqVol := range requiredVolumes { if !existingVolumes[reqVol.Name] { diff --git a/internal/vector/aggregator/deployment_test.go b/internal/vector/aggregator/deployment_test.go new file mode 100644 index 0000000..9c6ac67 --- /dev/null +++ b/internal/vector/aggregator/deployment_test.go @@ -0,0 +1,25 @@ +package aggregator + +import ( + "testing" + + . "github.com/onsi/gomega" + + vectorv1alpha1 "github.com/kaasops/vector-operator/api/v1alpha1" +) + +func TestGenerateVolumesKeepsPreUpgradeOrderWhenNotPersistent(t *testing.T) { + g := NewWithT(t) + + ctrl := createTestController("test", "default", &vectorv1alpha1.VectorAggregatorCommon{}, false) + + volumes := ctrl.generateVectorAggregatorVolume() + + names := make([]string, 0, len(volumes)) + for _, v := range volumes { + names = append(names, v.Name) + } + // The exact order v0.4.1 generated: a reordered (even if semantically equal) + // pod template rolls every aggregator Deployment on operator upgrade. + g.Expect(names).To(Equal([]string{"config", "data", "procfs", "sysfs"})) +}