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 14, 2024
1 parent b7d7678 commit 8a9f44d
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 @@ -11,6 +11,7 @@ Changelog for Cass Operator, new PRs should update the `main / unreleased` secti

## unreleased

* [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. Also, do not allow upgrade of StatefulSet even if it's out of date, if previous update hasn't yet finished.
* [BUGFIX] [#652](https://github.com/k8ssandra/cass-operator/issues/652) Update nodeStatuses info when a pod is recreated

## v1.20.0
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 8a9f44d

Please sign in to comment.