Skip to content

Commit

Permalink
Set podManagementPolicy to parallel
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
ChunyiLyu committed Feb 26, 2021
1 parent 23ef25c commit ba81e8e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/resource/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ cluster_formation.k8s.host = kubernetes.default
cluster_formation.k8s.address_type = hostname
cluster_partition_handling = pause_minority
queue_master_locator = min-masters
disk_free_limit.absolute = 2GB`
disk_free_limit.absolute = 2GB
cluster_formation.randomized_startup_delay_range.min = 5
cluster_formation.randomized_startup_delay_range.max = 30`

defaultTLSConf = `
ssl_options.certfile = /etc/rabbitmq-tls/tls.crt
Expand Down
2 changes: 2 additions & 0 deletions internal/resource/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ cluster_formation.k8s.address_type = hostname
cluster_partition_handling = pause_minority
queue_master_locator = min-masters
disk_free_limit.absolute = 2GB
cluster_formation.randomized_startup_delay_range.min = 5
cluster_formation.randomized_startup_delay_range.max = 30
cluster_name = ` + instanceName)
}

Expand Down
1 change: 1 addition & 0 deletions internal/resource/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func (builder *StatefulSetBuilder) Build() (client.Object, error) {
MatchLabels: metadata.LabelSelector(builder.Instance.Name),
},
VolumeClaimTemplates: pvc,
PodManagementPolicy: appsv1.ParallelPodManagement,
},
}

Expand Down
11 changes: 10 additions & 1 deletion internal/resource/statefulset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var _ = Describe("StatefulSet", func() {

Expect(statefulSet.Spec.ServiceName).To(Equal(instance.ChildResourceName("nodes")))
})

It("adds the correct label selector", func() {
obj, err := stsBuilder.Build()
Expect(err).NotTo(HaveOccurred())
Expand All @@ -74,7 +75,15 @@ var _ = Describe("StatefulSet", func() {
Expect(labels["app.kubernetes.io/name"]).To(Equal(instance.Name))
})

It("references the storageclassname when specified", func() {
It("sets pod management policy to 'Parallel' ", func() {
obj, err := stsBuilder.Build()
Expect(err).NotTo(HaveOccurred())
statefulSet := obj.(*appsv1.StatefulSet)

Expect(statefulSet.Spec.PodManagementPolicy).To(Equal(appsv1.ParallelPodManagement))
})

It("references the storage class name when specified", func() {
storageClassName := "my-storage-class"
builder.Instance.Spec.Persistence.StorageClassName = &storageClassName

Expand Down

0 comments on commit ba81e8e

Please sign in to comment.