Skip to content

Commit 414cd53

Browse files
authored
Allow to specify the minimum uptime seconds (#582)
* Allow to specify the minimum uptime seconds * Set the default also in code
1 parent d34d327 commit 414cd53

File tree

8 files changed

+20
-7
lines changed

8 files changed

+20
-7
lines changed

api/v1beta1/foundationdbcluster_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ type FoundationDBClusterSpec struct {
269269
// This means that you end up with ProcessCounts["storage"] * StorageServersPerPod
270270
// storage processes
271271
StorageServersPerPod int `json:"storageServersPerPod,omitempty"`
272+
273+
// MinimumUptimeSecondsForBounce defines the minimum time, in seconds, that the
274+
// processes in the cluster must have been up for before the operator can
275+
// execute a bounce.
276+
// +kubebuilder:validation:Minimum=1
277+
// +kubebuilder:default:=600
278+
MinimumUptimeSecondsForBounce int `json:"minimumUptimeSecondsForBounce,omitempty"`
272279
}
273280

274281
// FoundationDBClusterStatus defines the observed state of FoundationDBCluster

config/crd/bases/apps.foundationdb.org_foundationdbclusters.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,10 @@ spec:
14371437
type: object
14381438
type: array
14391439
type: object
1440+
minimumUptimeSecondsForBounce:
1441+
default: 600
1442+
minimum: 1
1443+
type: integer
14401444
nextInstanceID:
14411445
type: integer
14421446
pendingRemovals:

controllers/bounce_processes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (b BounceProcesses) Reconcile(r *FoundationDBClusterReconciler, context ctx
105105
return false, ReconciliationNotReadyError{message: "Kills are disabled"}
106106
}
107107

108-
if minimumUptime < MinimumUptimeSecondsForBounce {
108+
if minimumUptime < float64(cluster.Spec.MinimumUptimeSecondsForBounce) {
109109
r.Recorder.Event(cluster, corev1.EventTypeNormal, "NeedsBounce",
110110
fmt.Sprintf("Spec require a bounce of some processes, but the cluster has only been up for %f seconds", minimumUptime))
111111
cluster.Status.Generations.NeedsBounce = cluster.ObjectMeta.Generation

controllers/cluster_controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ func (r *FoundationDBClusterReconciler) Reconcile(ctx context.Context, request c
160160

161161
for _, subReconciler := range subReconcilers {
162162
cluster.Spec = *(normalizedSpec.DeepCopy())
163-
164163
canContinue, err := subReconciler.Reconcile(r, ctx, cluster)
165164
if !canContinue || err != nil {
166165
log.Info("Reconciliation terminated early", "namespace", cluster.Namespace, "name", cluster.Name, "lastAction", fmt.Sprintf("%T", subReconciler))

controllers/controllers.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ const (
4545
// deployments to a cluster.
4646
BackupDeploymentLabel = "foundationdb.org/backup-for"
4747

48-
// MinimumUptimeSecondsForBounce defines the minimum time, in seconds, that the
49-
// processes in the cluster must have been up for before the operator can
50-
// execute a bounce.
51-
MinimumUptimeSecondsForBounce = 600
52-
5348
// PublicIPSourceAnnotation is an annotation key that specifies where a pod
5449
// gets its public IP from.
5550
PublicIPSourceAnnotation = "foundationdb.org/public-ip-source"

controllers/pod_models.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,12 @@ func NormalizeClusterSpec(spec *fdbtypes.FoundationDBClusterSpec, options Deprec
12471247
template.Spec.InitContainers = customizeContainerFromList(template.Spec.InitContainers, "foundationdb-kubernetes-init", sidecarUpdater)
12481248
template.Spec.Containers = customizeContainerFromList(template.Spec.Containers, "foundationdb-kubernetes-sidecar", sidecarUpdater)
12491249
})
1250+
1251+
// Setting the default since the CRD default enforces the default in the runtime
1252+
if spec.MinimumUptimeSecondsForBounce == 0 {
1253+
spec.MinimumUptimeSecondsForBounce = 600
1254+
}
1255+
12501256
return nil
12511257
}
12521258

controllers/suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ func createDefaultCluster() *fdbtypes.FoundationDBCluster {
166166
FailureDetectionTimeSeconds: &failureDetectionWindow,
167167
},
168168
},
169+
MinimumUptimeSecondsForBounce: 1,
169170
},
170171
Status: fdbtypes.FoundationDBClusterStatus{
171172
RequiredAddresses: fdbtypes.RequiredAddressSet{

docs/cluster_spec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ FoundationDBClusterSpec defines the desired state of a cluster.
273273
| customParameters | CustomParameters defines additional parameters to pass to the fdbserver processes. **Deprecated: use the Processes field instead.** | []string | false |
274274
| pendingRemovals | PendingRemovals defines the processes that are pending removal. This maps the name of a pod to its IP address. If a value is left blank, the controller will provide the pod's current IP. **Deprecated: To indicate that a process should be removed, use the InstancesToRemove field. To get information about pending removals, use the PendingRemovals field in the status.** | map[string]string | false |
275275
| storageServersPerPod | StorageServersPerPod defines how many Storage Servers should run in a single Instance (Pod). This number defines the number of processes running in one Pod whereas the ProcessCounts defines the number of Pods created. This means that you end up with ProcessCounts[\"storage\"] * StorageServersPerPod storage processes | int | false |
276+
| minimumUptimeSecondsForBounce | MinimumUptimeSecondsForBounce defines the minimum time, in seconds, that the processes in the cluster must have been up for before the operator can execute a bounce. | int | false |
276277

277278
[Back to TOC](#table-of-contents)
278279

0 commit comments

Comments
 (0)