Skip to content

Missing metav1 registration for CNPG scheme group version #942

Closed

Description

@NiccoloFei

After the controller-runtime v0.24.0 upgrade (58f4fed), the following error is being continuously logged on every WAL archive:

{
  "level": "error",
  "ts": "2026-06-05T13:34:33.255699964Z",
  "msg": "Retention policy enforcement failed",
  "logging_pod": "cluster-example-1",
  "error": "v1.GetOptions is not suitable for converting to \"postgresql.cnpg.io/v1\" in scheme \"pkg/runtime/scheme.go:111\"",
  "stacktrace": "github.com/cloudnative-pg/machinery/pkg/log.(*logger).Error\n\t/go/pkg/mod/github.com/cloudnative-pg/[email protected]/pkg/log/log.go:128\ngithub.com/cloudnative-pg/plugin-barman-cloud/internal/cnpgi/instance.(*CatalogMaintenanceRunnable).Start\n\t/workspace/internal/cnpgi/instance/retention.go:66\nsigs.k8s.io/controller-runtime/pkg/manager.(*runnableGroup).reconcile.func1\n\t/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/manager/runnable_group.go:260"
}

Activity

  1. dosubot commented on Jun 5, 2026

    @dosubot

    The root cause is a missing metav1.AddToGroupVersion() call for the CNPG types (postgresql.cnpg.io/v1) after the controller-runtime v0.24.0 upgrade.

    During the migration (PR #880), the Barman Cloud API registration (barmancloud.cnpg.io/v1) was correctly updated to include metav1.AddToGroupVersion(scheme, GroupVersion) [1], but the CNPG types registration was not. This causes the scheme to not recognize v1.GetOptions as compatible with the postgresql.cnpg.io/v1 group when the retention policy enforcement performs Client.Get() operations [2].

    The fix would be to add metav1.AddToGroupVersion in both locations where CNPG types are registered:

    internal/scheme/cnpg.go [3]:

    scheme.AddKnownTypes(cnpgGroupVersion,
        &cnpgv1.Cluster{},
        &cnpgv1.ClusterList{},
        &cnpgv1.Backup{},
        &cnpgv1.BackupList{},
        &cnpgv1.ScheduledBackup{},
        &cnpgv1.ScheduledBackupList{},
    )
    metav1.AddToGroupVersion(scheme, cnpgGroupVersion) // missing

    internal/cnpgi/common/scheme.go [4]:

    result.AddKnownTypes(cnpgGroupVersion,
        &cnpgv1.Cluster{},
        &cnpgv1.ClusterList{},
        &cnpgv1.Backup{},
        &cnpgv1.BackupList{},
        &cnpgv1.ScheduledBackup{},
        &cnpgv1.ScheduledBackupList{},
    )
    metav1.AddToGroupVersion(result, cnpgGroupVersion) // missing

    This matches the pattern already used for the Barman Cloud API group registration.

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about plugin-barman-cloud Share Dosu with your team

  2. added a commit that references this issue on Jun 8, 2026
    bb7845d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions