[Bug]: enablePDB=false deletes independently managed PDBs with matching names

オープン 初心者向け
#11,600 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@WoahitsJoe がすでに取り組んでいます。

2026年10月1日 から。

  • #11601 @WoahitsJoe による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go, kubernetes, postgresql

調査の方向性

internal/controller/cluster_create.go の deletePodDisruptionBudgetIfExists から始め、PDB ビルダーがどのように controller の所有権を設定しているかを確認します。提供された Cluster マニフェストと PDB マニフェストで動作を再現し、クリーンアップによって CNPG が管理する budget は削除され、同じ名前を持つ独立して管理された PDB はそのまま残ることを検証します。

索引モデルが issue の本文から書いたものです。

説明

Is there an existing issue already for this bug?
  • I searched for an existing report and did not find one covering this deletion behavior.
Troubleshooting and supported releases
  • I read the troubleshooting and supported-release guidance.
Version

1.30.1. The same deletion path is present on main at 9c8de1b9e1af2b71f74a808c543c7be988d27baf.

Kubernetes version and environment

Kubernetes 1.35.6 on Google GKE. The operator is installed through Helm.

What happened?

With spec.enablePDB: false, the operator deletes an independently managed PDB whose name matches the Cluster name. The custom PDB has no owner references. Argo CD recreates it, then CNPG deletes it again, producing reconciliation churn and gaps in disruption-budget coverage.

The cleanup also targets <cluster-name>-primary. Neither deletion checks whether the PDB is controlled by the Cluster.

Expected: disabling CNPG's built-in PDBs removes its own budgets and leaves independently managed budgets intact.

Minimal reproduction

On a cluster with CNPG installed, apply these resources and observe the PDB and Cluster events:

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: pdb-example
spec:
  instances: 2
  enablePDB: false
  storage:
    size: 1Gi
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: pdb-example
spec:
  maxUnavailable: 1
  selector:
    matchLabels:
      cnpg.io/cluster: pdb-example
      cnpg.io/podRole: instance

The manifests above use an example name. In the affected deployment, the custom PDB's metadata.ownerReferences is absent, but the Cluster receives DeletingPodDisruptionBudget events naming that PDB.

Relevant code

deletePodDisruptionBudgetIfExists gets the PDB by name and deletes it without checking ownership. CNPG's PDB builders already set a controller owner reference to the Cluster.

A small possible fix is to check metav1.IsControlledBy(&targetPdb, cluster) before deleting. This would preserve the existing cleanup for CNPG-owned budgets without introducing another annotation or API setting.

The current workaround is to give the custom PDB a different name.

Contribution

I'd like to work on this. Please confirm whether checking the existing controller owner reference is the preferred approach and assign the issue if appropriate.

This report and proposed approach were prepared with OpenAI Codex assistance and reviewed against the affected deployment and upstream source.

Code of Conduct
  • I agree to follow this project's Code of Conduct.
主要言語
Go
スター
9.7k
フォーク
826
平均マージ
2日 1時間
マージ済み PR(30日)
122

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cloudnative-pg/cloudnative-pg のほかの issue

cloudnative-pg/cloudnative-pg の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。