Skip to content

feat(cluster): expose shutdown and failover timing knobs - #972

Open
wittfabian wants to merge 1 commit into
cloudnative-pg:mainfrom
wittfabian:dev/892
Open

feat(cluster): expose shutdown and failover timing knobs#972
wittfabian wants to merge 1 commit into
cloudnative-pg:mainfrom
wittfabian:dev/892

Conversation

@wittfabian

Copy link
Copy Markdown

What

Expose four CNPG Cluster spec fields as chart values, completing the shutdown/failover timing family that cluster.stopDelay (#941) started:

values key maps to default
cluster.smartShutdownTimeout spec.smartShutdownTimeout 180
cluster.switchoverDelay spec.switchoverDelay 3600
cluster.startDelay spec.startDelay 3600
cluster.failoverDelay spec.failoverDelay 0

The template never rendered these, so setting them in values.yaml was silently dropped and they stayed pinned to the operator defaults.

Why

On a brief API-server connectivity loss on the node hosting the primary, CNPG fails the primary over. With the default smartShutdownTimeout: 180, the old primary spends up to 180s in smart shutdown waiting for idle client connections to drain before the standby can be promoted — turning a ~1 minute network blip into a multi-minute read-write outage. Lowering smartShutdownTimeout (and raising failoverDelay to ride out very short partitions) is the intended CNPG knob, but with the chart not exposing it the only workaround is an out-of-band kubectl patch on the Cluster CR.

This closes the open request in #892 (failoverDelay) and also covers the remaining fields from #523 (smartShutdownTimeout, startDelay, switchoverDelay).

How

Same wire-up as #941:

  • templates/cluster.yaml: {{- with }} blocks, so a field is only rendered when set (failoverDelay: 0 = operator default therefore stays unset).
  • values.yaml: documented keys at their operator defaults.
  • values.schema.json: regenerated with helm-schema v0.23.4.
  • README.md: regenerated with helm-docs v1.14.2.

Verified with helm lint (0 failures) and helm template: fields render when set; failoverDelay: 0 is correctly not emitted.

Closes #892


Disclosure (per the project AI policy): this change was drafted with AI assistance — see the Assisted-by: commit trailer. I have reviewed and understand every line and take responsibility for it.

Expose cluster.smartShutdownTimeout, cluster.switchoverDelay,
cluster.startDelay and cluster.failoverDelay, mapping to the matching
CNPG Cluster spec fields. This completes the shutdown/failover timing
family started by cluster.stopDelay (cloudnative-pg#941): the template never rendered
these four, so setting them in values.yaml was silently dropped and they
stayed pinned to the operator defaults.

Motivating case: on a brief API-server connectivity loss on the node
running the primary, CNPG fails the primary over. With the default
smartShutdownTimeout of 180s the old primary waits for idle client
connections to drain before the standby can be promoted, turning a
~1 minute blip into a multi-minute read-write outage. Lowering
smartShutdownTimeout (and raising failoverDelay to ride out very short
partitions) is the intended knob, but until now it required patching the
CR out of band. Also covers the remaining fields requested in cloudnative-pg#523.

Same wire-up as cloudnative-pg#941: values.yaml plus template block, values.schema.json
regenerated with helm-schema, README regenerated with helm-docs. Verified
with helm lint and helm template; failoverDelay defaults to 0 and is only
rendered when set.

Closes cloudnative-pg#892

Signed-off-by: Fabian Witt <fabian.witt@t-online.de>
Assisted-by: Claude Opus 4.8
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. chart( cluster ) Related to the cluster chart labels Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chart( cluster ) Related to the cluster chart size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Cluster chart] Add support for failoverDelay

1 participant