fix(scheme): register meta types for CNPG scheme group version (#943)
Some checks failed
release-please / release-please (push) Failing after 5s

After the controller-runtime v0.24.0 upgrade (58f4fed), the instance
sidecar logged "v1.GetOptions is not suitable for converting to
postgresql.cnpg.io/v1" on every WAL archive, which broke retention
policy enforcement.

Register the standard meta types with metav1.AddToGroupVersion after the
AddKnownTypes call in internal/cnpgi/common/scheme.go and
internal/scheme/cnpg.go.

Closes #942

Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
This commit is contained in:
Niccolò Fei 2026-06-08 11:08:15 +02:00 committed by GitHub
parent 3efe655ed5
commit bb7845dd62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View File

@ -25,6 +25,7 @@ import (
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1" cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
"github.com/cloudnative-pg/machinery/pkg/log" "github.com/cloudnative-pg/machinery/pkg/log"
"github.com/spf13/viper" "github.com/spf13/viper"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@ -58,6 +59,7 @@ func GenerateScheme(ctx context.Context) *runtime.Scheme {
&cnpgv1.Backup{}, &cnpgv1.BackupList{}, &cnpgv1.Backup{}, &cnpgv1.BackupList{},
&cnpgv1.ScheduledBackup{}, &cnpgv1.ScheduledBackupList{}, &cnpgv1.ScheduledBackup{}, &cnpgv1.ScheduledBackupList{},
) )
metav1.AddToGroupVersion(result, schemeGroupVersion)
schemeLog := log.FromContext(ctx) schemeLog := log.FromContext(ctx)
schemeLog.Info("CNPG types registration", "schemeGroupVersion", schemeGroupVersion) schemeLog.Info("CNPG types registration", "schemeGroupVersion", schemeGroupVersion)

View File

@ -25,6 +25,7 @@ import (
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1" cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
"github.com/cloudnative-pg/machinery/pkg/log" "github.com/cloudnative-pg/machinery/pkg/log"
"github.com/spf13/viper" "github.com/spf13/viper"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
) )
@ -49,6 +50,7 @@ func AddCNPGToScheme(ctx context.Context, s *runtime.Scheme) {
&cnpgv1.Backup{}, &cnpgv1.BackupList{}, &cnpgv1.Backup{}, &cnpgv1.BackupList{},
&cnpgv1.ScheduledBackup{}, &cnpgv1.ScheduledBackupList{}, &cnpgv1.ScheduledBackup{}, &cnpgv1.ScheduledBackupList{},
) )
metav1.AddToGroupVersion(s, schemeGroupVersion)
log.FromContext(ctx).Info("CNPG types registration", "schemeGroupVersion", schemeGroupVersion) log.FromContext(ctx).Info("CNPG types registration", "schemeGroupVersion", schemeGroupVersion)
} }