Skip to content

Commit 0bce98a

Browse files
committed
Correct admin secret volumes
rabbitmq-admin is the temporary volume for the initContainer, and contains the actual secret data. rabbitmq-confd is the empty volume that is populated by the initContainer from rabbitmq-admin.
1 parent c39b820 commit 0bce98a

File tree

3 files changed

+46
-28
lines changed

3 files changed

+46
-28
lines changed

Diff for: controllers/rabbitmqcluster_controller_test.go

+16-10
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,21 @@ var _ = Describe("RabbitmqclusterController", func() {
12061206

12071207
Expect(sts.Spec.Template.Spec.HostNetwork).To(BeFalse())
12081208
Expect(sts.Spec.Template.Spec.Volumes).To(ConsistOf(
1209+
corev1.Volume{
1210+
Name: "rabbitmq-admin",
1211+
VolumeSource: corev1.VolumeSource{
1212+
Secret: &corev1.SecretVolumeSource{
1213+
DefaultMode: &defaultMode,
1214+
SecretName: "rabbitmq-sts-override-rabbitmq-admin",
1215+
Items: []corev1.KeyToPath{
1216+
{
1217+
Key: "default_user.conf",
1218+
Path: "default_user.conf",
1219+
},
1220+
},
1221+
},
1222+
},
1223+
},
12091224
corev1.Volume{
12101225
Name: "additional-config",
12111226
VolumeSource: corev1.VolumeSource{
@@ -1220,16 +1235,7 @@ var _ = Describe("RabbitmqclusterController", func() {
12201235
corev1.Volume{
12211236
Name: "rabbitmq-confd",
12221237
VolumeSource: corev1.VolumeSource{
1223-
Secret: &corev1.SecretVolumeSource{
1224-
DefaultMode: &defaultMode,
1225-
SecretName: "rabbitmq-sts-override-rabbitmq-admin",
1226-
Items: []corev1.KeyToPath{
1227-
{
1228-
Key: "default_user.conf",
1229-
Path: "default_user.conf",
1230-
},
1231-
},
1232-
},
1238+
EmptyDir: &corev1.EmptyDirVolumeSource{},
12331239
},
12341240
},
12351241
corev1.Volume{

Diff for: internal/resource/statefulset.go

+15-9
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,20 @@ func (builder *StatefulSetBuilder) podTemplateSpec(annotations, labels map[strin
258258
terminationGracePeriod := defaultGracePeriodTimeoutSeconds
259259

260260
volumes := []corev1.Volume{
261+
{
262+
Name: "rabbitmq-admin",
263+
VolumeSource: corev1.VolumeSource{
264+
Secret: &corev1.SecretVolumeSource{
265+
SecretName: builder.Instance.ChildResourceName(AdminSecretName),
266+
Items: []corev1.KeyToPath{
267+
{
268+
Key: "default_user.conf",
269+
Path: "default_user.conf",
270+
},
271+
},
272+
},
273+
},
274+
},
261275
{
262276
Name: "server-conf",
263277
VolumeSource: corev1.VolumeSource{
@@ -287,15 +301,7 @@ func (builder *StatefulSetBuilder) podTemplateSpec(annotations, labels map[strin
287301
{
288302
Name: "rabbitmq-confd",
289303
VolumeSource: corev1.VolumeSource{
290-
Secret: &corev1.SecretVolumeSource{
291-
SecretName: builder.Instance.ChildResourceName(AdminSecretName),
292-
Items: []corev1.KeyToPath{
293-
{
294-
Key: "default_user.conf",
295-
Path: "default_user.conf",
296-
},
297-
},
298-
},
304+
EmptyDir: &corev1.EmptyDirVolumeSource{},
299305
},
300306
},
301307
{

Diff for: internal/resource/statefulset_test.go

+15-9
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,20 @@ var _ = Describe("StatefulSet", func() {
815815
Expect(stsBuilder.Update(statefulSet)).To(Succeed())
816816

817817
Expect(statefulSet.Spec.Template.Spec.Volumes).To(ConsistOf(
818+
corev1.Volume{
819+
Name: "rabbitmq-admin",
820+
VolumeSource: corev1.VolumeSource{
821+
Secret: &corev1.SecretVolumeSource{
822+
SecretName: instance.ChildResourceName("admin"),
823+
Items: []corev1.KeyToPath{
824+
{
825+
Key: "default_user.conf",
826+
Path: "default_user.conf",
827+
},
828+
},
829+
},
830+
},
831+
},
818832
corev1.Volume{
819833
Name: "server-conf",
820834
VolumeSource: corev1.VolumeSource{
@@ -844,15 +858,7 @@ var _ = Describe("StatefulSet", func() {
844858
corev1.Volume{
845859
Name: "rabbitmq-confd",
846860
VolumeSource: corev1.VolumeSource{
847-
Secret: &corev1.SecretVolumeSource{
848-
SecretName: instance.ChildResourceName("admin"),
849-
Items: []corev1.KeyToPath{
850-
{
851-
Key: "default_user.conf",
852-
Path: "default_user.conf",
853-
},
854-
},
855-
},
861+
EmptyDir: &corev1.EmptyDirVolumeSource{},
856862
},
857863
},
858864
corev1.Volume{

0 commit comments

Comments
 (0)