Repository navigation
Description
Is there an existing issue already for this bug?
- I have searched for an existing issue, and could not find anything. I believe this is a new bug.
I have read the troubleshooting guide
- I have read the troubleshooting guide and I think this is a new bug.
I am running a supported version of CloudNativePG
- I have read the troubleshooting guide and I think this is a new bug.
Contact Details
No response
Version
1.26 (latest patch)
What version of Kubernetes are you using?
1.30
What is your Kubernetes environment?
Self-managed: kind (evaluation)
How did you install the operator?
YAML manifest
What happened?
I am getting the same issue as in #8024 ..
I.e. the following message after an apply of the below manifest. The Cluster "..." is invalid: spec.bootstrap: Invalid value: "": Too many bootstrap types specified.
As I am not sure that this is the same issue, I chose to open a different one.
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
annotations:
cnpg.io/skipEmptyWalArchiveCheck: enabled
name: ...
namespace: ...
spec:
bootstrap:
recovery:
source: self
externalClusters:
- name: self
plugin:
name: barman-cloud.cloudnative-pg.io
parameters:
barmanObjectName: pg-backup-object-store
serverName: to-be-replaced
instances: 1
monitoring:
enablePodMonitor: true
plugins:
- isWALArchiver: true
name: barman-cloud.cloudnative-pg.io
parameters:
barmanObjectName: pg-backup-object-store
serverName: to-be-replaced
storage:
size: 500MiThe cluster already exits. I am only adding the bootstrap: section here.
Is this maybe a matter of how the initdb /bootstrap section is handled if not set explicitly at first?
Ive got a different pg-cluster within the same cluster, where the same approach worked like a charm.
If there is a typo that my 2 hours of staring at this manifest did not reveal, please feel free to close this.
Thank you in advance.
Cluster resource
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
annotations:
cnpg.io/skipEmptyWalArchiveCheck: enabled
name: ...
namespace: ...
spec:
bootstrap:
recovery:
source: self
externalClusters:
- name: self
plugin:
name: barman-cloud.cloudnative-pg.io
parameters:
barmanObjectName: pg-backup-object-store
serverName: to-be-replaced
instances: 1
monitoring:
enablePodMonitor: true
plugins:
- isWALArchiver: true
name: barman-cloud.cloudnative-pg.io
parameters:
barmanObjectName: pg-backup-object-store
serverName: to-be-replaced
storage:
size: 500MiRelevant log output
The Cluster "api-pg" is invalid: spec.bootstrap: Invalid value: "": Too many bootstrap types specifiedCode of Conduct
- I agree to follow this project's Code of Conduct
Activity
dosubot commentedon Jul 25, 2025
Hi @MRocholl! I'm Dosu and I’m helping the cloudnative-pg team.
This error happens because the
bootstrapsection in a CloudNativePG Cluster resource is only meant to be set at creation time. Once the cluster is initialized, adding or modifying thebootstrapsection is not supported and will trigger a validation error like "Too many bootstrap types specified"—even if you only specify one method. This is enforced by both the CRD and the operator's validation logic, and is documented as intentional behavior to prevent conflicting bootstrap operations on an already-initialized cluster. There are no typos in your manifest; the issue is due to this immutability constraint, not user error. For more details, see the CloudNativePG documentation on bootstrap and the discussion in issue #8024.To reply, just mention @dosu.
Docs are dead. Just use Dosu.
MRocholl commentedon Jul 25, 2025
This: Is this maybe a matter of how the initdb /bootstrap section is handled if not set explicitly at first?
I just set initdb explicitly:
and then reapplied the original manifest. and it works.
Im gonna leave this open, as this seems like unclear behavior to me. @dosu Your answer does not address this behavior.
dosubot commentedon Jul 25, 2025
Yes, this is about how the bootstrap section is handled by default. If you don't set a bootstrap method at creation, CloudNativePG implicitly defaults to initdb with standard settings. This means the cluster is already considered to have been bootstrapped with initdb, even if you never wrote it explicitly in the manifest.
When you later add an explicit initdb block that matches the default, it doesn't create a conflict—you're just making the implicit default explicit, so the operator accepts it. But if you try to add a different bootstrap method (like recovery) after creation, the validation logic sees this as specifying more than one bootstrap method, which is not allowed and triggers the "too many bootstrap types specified" error. This behavior comes from the way the controller applies defaults and validates the manifest, not from an explicit immutability rule in the CRD or webhook.
You can see this logic in the code: if no bootstrap is set, it defaults to initdb; only one method is allowed at a time, and the validation counts non-nil methods to enforce this rule (source, source).
So, the effect you saw is a result of how defaulting and validation interact, not a documented or intentional feature—just an emergent property of the implementation.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
MRocholl commentedon Jul 25, 2025
@dosu That does not explain why the two different ways to define a cluster 1. rely on default inditdb and 2. specify an explict initdb
will NOT allow the cluster to be updated with a recovery section for (implicit initdb) 1 but will do so for (explicit initdb) 2.
dosubot commentedon Jul 25, 2025
This difference comes from how CloudNativePG applies defaults and validates updates. When you create a cluster without specifying
bootstrap, the operator internally defaults toinitdb—but this is not stored explicitly in the resource. If you later try to add a different bootstrap method (likerecovery), the validation logic sees both the implicit default and your new method, counts more than one, and blocks the change as "too many bootstrap types specified" (source, source).If you explicitly set
initdbin your manifest, then later switch torecovery, the webhook compares the old and new states (both with explicit bootstrap blocks) and may allow the change if it doesn't interpret it as a conflicting semantic change. This subtlety is a side effect of how the webhook applies defaults and compares the "old" and "new" objects during updates—not an intentional user-facing policy, but an artifact of the implementation. The key is that the operator always applies defaults before validating, so the presence or absence of explicit fields in your manifest can affect how updates are validated, even if the effective configuration is the same (source).To reply, just mention @dosu.
Docs are dead. Just use Dosu.
MRocholl commentedon Jul 25, 2025
@dosu from a user perspective this is unexpected behavior. I.e. Seems like a bug to me.
dosubot commentedon Jul 25, 2025
You're right—this is unexpected and confusing from a user perspective. The difference in behavior between implicit and explicit bootstrap handling isn't clearly documented and has tripped up others as well. It's not officially labeled a bug, but it's an emergent property of how CloudNativePG applies defaults and validates updates: when you don't specify a bootstrap method, the operator internally defaults to
initdb, but this isn't visible in your manifest. Later, if you try to add a different bootstrap method (likerecovery), the validation logic sees both the implicit default and your new method, and blocks the change as "too many bootstrap types specified"—even though you only see one in your YAML. This subtlety is a side effect of the defaulting and validation logic, not an intentional feature, and maintainers have acknowledged that similar defaulting behavior can be confusing and may not align with user expectations or documentation (example, example).There's no official documentation or release note that directly addresses this, so your feedback highlights a real gap in clarity.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
mnencia commentedon Jul 25, 2025
This issue is a duplicate of #8024, which was fixed in #8025. We have just released version 1.26.1, which includes this fix.
MRocholl commentedon Jul 25, 2025
@mnencia At a second look, I fail to see how this is a duplicate. The issue is not with multiple boostrap methods but a single one.
Please see the last message from dosu. #8025 does not address this as far as I can see.
mnencia commentedon Jul 25, 2025
When you created the cluster without specifying any bootstrap method, the operator's defaulting webhook automatically added
spec.bootstrap.initdb. This happens after kubectl stores your original manifest inkubectl.kubernetes.io/last-applied-configuration. Later, when you apply the updated manifest that introducesspec.bootstrap.recovery, kubectl apply merges the new manifest with the existing resource. Since the stored configuration doesn't contain theinitdbmethod, kubectl doesn't know it has to remove it, so it merges the applied object with the current one and ends up with two bootstrap methods.The validating webhook rejects that configuration because only one bootstrap method can be set at a time. That's why you see the "spec.bootstrap: Forbidden: Only one bootstrap method can be specified at a time" error (or "spec.bootstrap: Invalid value:" ": Too many bootstrap types specified" with the previous version).
To switch to
recovery,you must first remove the defaultedinitdbsection, either viakubectl editorkubectl patch. An alternative is to explicitly setbootstrap.initdbin the original manifest (even if left empty), then replace it withrecoveryin a subsequent apply. This ensureskubectl applysees the change and removes theinitdbsection, preventing the conflict.I'm going to close this issue as this is standard Kubernetes behavior when there is a defaulting webhook, and CNPG cannot change this.
MRocholl commentedon Jul 26, 2025
Thank you for clarifying the issue. That explains it!