Skip to content

Commit ba81e8e

Browse files
committed
Set podManagementPolicy to parallel
- use cluster_formation.randomized_startup_delay_range to avoid race condition between nodes during initial cluster formation - this change solves the problem of failing to restart the cluster when all pods are deleted and recreated at once; with podManagementPolicy set to 'OrderedReady', pod 0 is also the first one getting recreated, but it may not be the last node to shut down.
1 parent 23ef25c commit ba81e8e

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

internal/resource/configmap.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ cluster_formation.k8s.host = kubernetes.default
3434
cluster_formation.k8s.address_type = hostname
3535
cluster_partition_handling = pause_minority
3636
queue_master_locator = min-masters
37-
disk_free_limit.absolute = 2GB`
37+
disk_free_limit.absolute = 2GB
38+
cluster_formation.randomized_startup_delay_range.min = 5
39+
cluster_formation.randomized_startup_delay_range.max = 30`
3840

3941
defaultTLSConf = `
4042
ssl_options.certfile = /etc/rabbitmq-tls/tls.crt

internal/resource/configmap_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ cluster_formation.k8s.address_type = hostname
3333
cluster_partition_handling = pause_minority
3434
queue_master_locator = min-masters
3535
disk_free_limit.absolute = 2GB
36+
cluster_formation.randomized_startup_delay_range.min = 5
37+
cluster_formation.randomized_startup_delay_range.max = 30
3638
cluster_name = ` + instanceName)
3739
}
3840

internal/resource/statefulset.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func (builder *StatefulSetBuilder) Build() (client.Object, error) {
6767
MatchLabels: metadata.LabelSelector(builder.Instance.Name),
6868
},
6969
VolumeClaimTemplates: pvc,
70+
PodManagementPolicy: appsv1.ParallelPodManagement,
7071
},
7172
}
7273

internal/resource/statefulset_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ var _ = Describe("StatefulSet", func() {
6565

6666
Expect(statefulSet.Spec.ServiceName).To(Equal(instance.ChildResourceName("nodes")))
6767
})
68+
6869
It("adds the correct label selector", func() {
6970
obj, err := stsBuilder.Build()
7071
Expect(err).NotTo(HaveOccurred())
@@ -74,7 +75,15 @@ var _ = Describe("StatefulSet", func() {
7475
Expect(labels["app.kubernetes.io/name"]).To(Equal(instance.Name))
7576
})
7677

77-
It("references the storageclassname when specified", func() {
78+
It("sets pod management policy to 'Parallel' ", func() {
79+
obj, err := stsBuilder.Build()
80+
Expect(err).NotTo(HaveOccurred())
81+
statefulSet := obj.(*appsv1.StatefulSet)
82+
83+
Expect(statefulSet.Spec.PodManagementPolicy).To(Equal(appsv1.ParallelPodManagement))
84+
})
85+
86+
It("references the storage class name when specified", func() {
7887
storageClassName := "my-storage-class"
7988
builder.Instance.Spec.Persistence.StorageClassName = &storageClassName
8089

0 commit comments

Comments
 (0)