[Bug]: A failed plugin backup sets the deprecated `status.lastFailedBackup`, so `cnpg_collector_last_failed_backup_timestamp` stays newer than the last available backup

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

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

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

2026年11月18日 から。

評価

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

調査の方向性

まず pkg/management/postgres/webserver/plugin_backup.go と pkg/resources/status/backup.go を確認し、その後、APIリファレンスと monitoring.md にあるバックアッププラグインに関する記述を調べてください。FlagBackupAsFailed がプラグインのバックアップのステータスをどのように更新するかを確認し、その動作のユニットテストを探すか追加してください。プラグインのバックアップでは非推奨の失敗タイムスタンプが未設定のままであり、LastBackupSucceeded 条件は引き続き更新されることが完了の条件です。

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

説明

What happened?

With backups taken through the Barman Cloud plugin, a failed backup still writes
.status.lastFailedBackup in the Cluster, but a successful one does not write
.status.lastSuccessfulBackup. The API reference says both fields are
"not set for backup plugins".

After a single failed plugin backup, the deprecated metrics end up in a state
that looks like the last backup failed, even though every backup after it
succeeded:

# cluster-a (plugin backups every day, two failures on 2026-10-06/07, 15 successes since)
cnpg_collector_last_available_backup_timestamp             0
cnpg_collector_last_failed_backup_timestamp                1791345609   # 2026-10-07T04:00:09Z
barman_cloud_cloudnative_pg_io_last_available_backup_timestamp 1792641604   # 2026-10-22
$ kubectl get cluster cluster-a -o jsonpath='{.status.lastSuccessfulBackup} / {.status.lastFailedBackup}'
 / 2026-10-07T04:00:09Z

The LastBackupSucceeded condition is True, and the plugin metrics are correct.
Only the deprecated fields and metrics disagree.

Where
  • pkg/management/postgres/webserver/plugin_backup.go, markBackupAsFailed calls
    status.FlagBackupAsFailed(..., b.Cluster, failure).
  • pkg/resources/status/backup.go sets cluster.Status.LastFailedBackup for every method.
Proposal

Skip the lastFailedBackup update in FlagBackupAsFailed when the backup
method is plugin, and keep updating the LastBackupSucceeded condition. This
matches the API reference and the warning in monitoring.md. I have a small
patch with a unit test and can open a PR if this approach is fine.

(Alternative: keep the current behavior and change the API reference and
monitoring.md. That leaves a failure timestamp without the matching success
timestamp, so I'd prefer the code change.)

Version

1.30.0 (operator), plugin-barman-cloud 0.14.0. The same code is on main (2a54673).

I used an AI assistant (Claude) to read the code and draft this report; I
checked the numbers on my own cluster.

主要言語
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 を短くまとめたダイジェスト。