Wrong `ObjectStore` key logged when the backup object store can't be retrieved in the instance sidecar
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Review internal/cnpgi/instance/backup.go in Backup and internal/cnpgi/instance/metrics.go in Collect. Compare the key passed to GetBarmanObjectKey() with the key recorded in each error log, then verify both paths report the requested backup ObjectStore key when lookup fails.
Written by the indexing model from the issue text.
Description
Description
In the instance sidecar, two code paths fetch the cluster's backup ObjectStore with GetBarmanObjectKey(), but their error log reports GetRecoveryBarmanObjectKey():
internal/cnpgi/instance/backup.go (Backup):
var objectStore barmancloudv1.ObjectStore
if err := b.Client.Get(ctx, configuration.GetBarmanObjectKey(), &objectStore); err != nil {
contextLogger.Error(err, "while getting object store", "key", configuration.GetRecoveryBarmanObjectKey())
return nil, err
}
internal/cnpgi/instance/metrics.go (Collect) has the same lines.
So when the lookup fails, the key field names a different object from the one that was requested:
- on a cluster without a recovery source (the usual case),
RecoveryBarmanObjectNameis empty, sokeyhas an empty name; - on a cluster bootstrapped from an
ObjectStorethroughexternalClusters,keynames the recoveryObjectStore, which exists, pointing the reader at the wrong object.
Impact
Low, but confusing. The error message itself (for example objectstores.barmancloud.cnpg.io "s3-store" not found, or ... is forbidden) still has the right name, so the information is in the log line. But the structured key field contradicts it, and anything that filters or alerts on key gets the wrong value. Collect runs on every metrics scrape, so a missing or forbidden ObjectStore repeats the misleading line on every scrape.
This is the same kind of problem as #539/#504, which were about the operator pre-hook in reconciler.go. These two lines are on the instance side and weren't covered there.
History
The backup.go line dates from e4735a2 (#83, "separate recovery object store from replica source"). The metrics.go one was added in 33172b6 (#459) with the same lines. Open PR #1076 touches the surrounding code in backup.go but leaves this line as it is.
Proposed fix
Log configuration.GetBarmanObjectKey() in both places, the key that is actually passed to Get. I'm happy to send the PR.
How this was found
While working on #1140 on my fork, I ran an AI code review (Claude Code) over my change. It flagged the mismatched key in backup.go, even though my change didn't touch that line. I then searched the code base for the same pattern, which found the copy in metrics.go, and confirmed both on main by reading the code. I haven't triggered the failing lookup on a live cluster, so the error messages quoted above are examples, not captured output.
I used an AI assistant (Claude) to help find this and draft this issue, as the AI policy asks for disclosure.
- Dominant language
- Go
- Stars
- 196
- Forks
- 76
- Avg merge
- 4d 13h
- Merged PRs (30d)
- 19
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudnative-pg/plugin-barman-cloud
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
cloudnative-pg/plugin-barman-cloud#1117 · 1 reaction ·
Maintainers usually reply within 1 day
-
data.compression rejects zstd although barman-cloud-backup supports itPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
cloudnative-pg/plugin-barman-cloud#1104 · 4 reactions ·
Maintainers usually reply within 1 day
-
Add RBAC aggregation labels to ObjectStore editor/viewer ClusterRolesPossibly taken @stefanpeknik claimed this 19 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 82/100
cloudnative-pg/plugin-barman-cloud#1102 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
cloudnative-pg/plugin-barman-cloud#1143 ·
Maintainers usually reply within 1 day
-
Record the object store and server name of a backup in Backup.status.pluginMetadataPossibly taken @BoxBoxJason claimed this 2 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
cloudnative-pg/plugin-barman-cloud#1140 ·
Maintainers usually reply within 1 day
All issues in cloudnative-pg/plugin-barman-cloud
Similar issues
-
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
FootprintAI/Containarium#2338 ·
Maintainers usually reply within 1 day
-
[Bug]: core doesn't build standalone on dev since a17068054 (go-mp3 require dropped, go.sum pruned)Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
SagerNet/sing-openvpn#11 ·
-
priority: P3 type: devops
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
jiegui2025/hwspec#57 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
columnar-tech/dbc#513 ·
Maintainers usually reply within 1 day