diff --git a/CHANGELOG.md b/CHANGELOG.md index e361ce20..9271b878 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/apis/cassandra/v1beta1/cassandradatacenter_types.go b/apis/cassandra/v1beta1/cassandradatacenter_types.go index e2d17732..ff8d3d08 100644 --- a/apis/cassandra/v1beta1/cassandradatacenter_types.go +++ b/apis/cassandra/v1beta1/cassandradatacenter_types.go @@ -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 { diff --git a/apis/cassandra/v1beta1/zz_generated.deepcopy.go b/apis/cassandra/v1beta1/zz_generated.deepcopy.go index 63c077c8..ad4af351 100644 --- a/apis/cassandra/v1beta1/zz_generated.deepcopy.go +++ b/apis/cassandra/v1beta1/zz_generated.deepcopy.go @@ -357,6 +357,11 @@ func (in *CassandraDatacenterSpec) DeepCopyInto(out *CassandraDatacenterSpec) { *out = new(CDCConfiguration) (*in).DeepCopyInto(*out) } + if in.MinReadySeconds != nil { + in, out := &in.MinReadySeconds, &out.MinReadySeconds + *out = new(int32) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CassandraDatacenterSpec. diff --git a/config/crd/bases/cassandra.datastax.com_cassandradatacenters.yaml b/config/crd/bases/cassandra.datastax.com_cassandradatacenters.yaml index b3d4eb5c..75f81e9e 100644 --- a/config/crd/bases/cassandra.datastax.com_cassandradatacenters.yaml +++ b/config/crd/bases/cassandra.datastax.com_cassandradatacenters.yaml @@ -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: diff --git a/pkg/reconciliation/construct_statefulset.go b/pkg/reconciliation/construct_statefulset.go index e48f3ce6..e73e3392 100644 --- a/pkg/reconciliation/construct_statefulset.go +++ b/pkg/reconciliation/construct_statefulset.go @@ -145,6 +145,7 @@ func newStatefulSetForCassandraDatacenter( PodManagementPolicy: appsv1.ParallelPodManagement, Template: *template, VolumeClaimTemplates: volumeClaimTemplates, + MinReadySeconds: 5, }, } @@ -152,6 +153,10 @@ func newStatefulSetForCassandraDatacenter( 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)