Description
The CatalogMaintenanceRunnable is registered unconditionally on every instance, including replica clusters that have no backup configuration (no barmanObjectName parameter).
On these clusters, cycle() calls NewFromCluster(), which sets BarmanObjectName to an empty string. Then GetBarmanObjectKey() returns a NamespacedName with Name: "", and the Client.Get() call on line 92 fails with "resource name may not be empty".
This logs an error every 5 minutes indefinitely.
How to reproduce
- Create a replica cluster with the barman-cloud plugin enabled but no
barmanObjectName in the plugin parameters (i.e., no backup configuration — only WAL restore from a source cluster).
- Observe the sidecar logs:
{"level":"error","msg":"Retention policy enforcement failed","error":"resource name may not be empty"}
Repeating every ~5 minutes.
Suggested fix
Add an early return in cycle() when BarmanObjectName is empty:
func (c *CatalogMaintenanceRunnable) cycle(ctx context.Context) (time.Duration, error) {
var cluster cnpgv1.Cluster
if err := c.Client.Get(ctx, c.ClusterKey, &cluster); err != nil {
return 0, err
}
configuration := config.NewFromCluster(&cluster)
if configuration.BarmanObjectName == "" {
return 0, nil
}
// ... rest of the function
}
Alternatively, don't register CatalogMaintenanceRunnable at all when there's no backup configuration. Note that the barman sidecar itself is still needed on replica clusters for WAL restore. Only the retention runnable is unnecessary.
However, not registering CatalogMaintenanceRunnable conditionally requires reading the cluster spec at sidecar startup to determine whether backup is configured, which adds complexity. The early return in cycle() is simpler and handles the case at runtime.
Description
The
CatalogMaintenanceRunnableis registered unconditionally on every instance, including replica clusters that have no backup configuration (nobarmanObjectNameparameter).On these clusters,
cycle()callsNewFromCluster(), which setsBarmanObjectNameto an empty string. ThenGetBarmanObjectKey()returns aNamespacedNamewithName: "", and theClient.Get()call on line 92 fails with"resource name may not be empty".This logs an error every 5 minutes indefinitely.
How to reproduce
barmanObjectNamein the plugin parameters (i.e., no backup configuration — only WAL restore from a source cluster).Suggested fix
Add an early return in
cycle()whenBarmanObjectNameis empty:Alternatively, don't register
CatalogMaintenanceRunnableat all when there's no backup configuration. Note that the barman sidecar itself is still needed on replica clusters for WAL restore. Only the retention runnable is unnecessary.However, not registering
CatalogMaintenanceRunnableconditionally requires reading the cluster spec at sidecar startup to determine whether backup is configured, which adds complexity. The early return incycle()is simpler and handles the case at runtime.