Skip to content

Commit

Permalink
Add Spec.MindReadySeconds to allow setting a non-default value for Mi…
Browse files Browse the repository at this point in the history
…nReadySeconds in StatefulSets. Set the default MinReadySeconds to 5 in StatefulSets to prevent sudden double restarts from statefulset controller.
  • Loading branch information
burmanm committed May 2, 2024
1 parent dda9d76 commit 4bf7fbc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Changelog for Cass Operator, new PRs should update the `main / unreleased` secti
* [CHANGE] [#618](https://github.com/k8ssandra/cass-operator/issues/618) Update dependencies to support controller-runtime 0.17.2, modify required parts.
* [ENHANCEMENT] [#628](https://github.com/k8ssandra/cass-operator/issues/628) Replace pod task can replace any node, including those that have crashed
* [ENHANCEMENT] [#532](https://github.com/k8ssandra/cass-operator/issues/532) Instead of rejecting updates/creates with deprecated fields, return kubectl warnings.
* [ENHANCEMENT] [#648](https://github.com/k8ssandra/cass-operator/issues/648) Add a default (5 seconds) MinReadySeconds to the StatefulSets and make that value configurable in the Spec

## v1.19.1

Expand Down
4 changes: 4 additions & 0 deletions apis/cassandra/v1beta1/cassandradatacenter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ type CassandraDatacenterSpec struct {
// Use cautiously.
// +optional
DatacenterName string `json:"datacenterName,omitempty"`

// MinReadySeconds sets the minimum number of seconds for which a newly created pod should be ready without any of its containers crashing, for it to be considered available. Defaults to 5 seconds and is set in the StatefulSet spec.
// Setting to 0 might cause multiple Cassandra pods to restart at the same time despite PodDisruptionBudget settings.
MinReadySeconds *int32 `json:"minReadySeconds,omitempty"`
}

type NetworkingConfig struct {
Expand Down
5 changes: 5 additions & 0 deletions apis/cassandra/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ spec:
- serverSecretName
type: object
type: object
minReadySeconds:
description: |-
MinReadySeconds sets the minimum number of seconds for which a newly created pod should be ready without any of its containers crashing, for it to be considered available. Defaults to 5 seconds and is set in the StatefulSet spec.
Setting to 0 might cause multiple Cassandra pods to restart at the same time despite PodDisruptionBudget settings.
format: int32
type: integer
networking:
properties:
hostNetwork:
Expand Down
5 changes: 5 additions & 0 deletions pkg/reconciliation/construct_statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,18 @@ func newStatefulSetForCassandraDatacenter(
PodManagementPolicy: appsv1.ParallelPodManagement,
Template: *template,
VolumeClaimTemplates: volumeClaimTemplates,
MinReadySeconds: 5,
},
}

if sts != nil && sts.Spec.ServiceName != "" && sts.Spec.ServiceName != result.Spec.ServiceName {
result.Spec.ServiceName = sts.Spec.ServiceName
}

if dc.Spec.MinReadySeconds != nil {
result.Spec.MinReadySeconds = *dc.Spec.MinReadySeconds
}

// add a hash here to facilitate checking if updates are needed
utils.AddHashAnnotation(result)

Expand Down

0 comments on commit 4bf7fbc

Please sign in to comment.