From 99f4e932c5a02cf85566214e99925dd7e286f72b Mon Sep 17 00:00:00 2001 From: loft-bot <73976634+loft-bot@users.noreply.github.com> Date: Wed, 15 Jan 2025 08:47:25 -0500 Subject: [PATCH] fix: storage class sync error (#2402) (#2403) (cherry picked from commit 89f43eba5df25c38be448a6a30c32f423700b97f) Co-authored-by: Fabian Kramm --- pkg/controllers/resources/persistentvolumeclaims/syncer.go | 3 +-- pkg/controllers/resources/persistentvolumes/translate.go | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/controllers/resources/persistentvolumeclaims/syncer.go b/pkg/controllers/resources/persistentvolumeclaims/syncer.go index 5e3f21e2b4..31aa30225f 100644 --- a/pkg/controllers/resources/persistentvolumeclaims/syncer.go +++ b/pkg/controllers/resources/persistentvolumeclaims/syncer.go @@ -43,14 +43,13 @@ func New(ctx *synccontext.RegisterContext) (syncertypes.Object, error) { return nil, err } - storageClassesEnabled := ctx.Config.Sync.ToHost.StorageClasses.Enabled return &persistentVolumeClaimSyncer{ GenericTranslator: translator.NewGenericTranslator(ctx, "persistent-volume-claim", &corev1.PersistentVolumeClaim{}, mapper), Importer: pro.NewImporter(mapper), excludedAnnotations: []string{bindCompletedAnnotation, boundByControllerAnnotation, storageProvisionerAnnotation}, - storageClassesEnabled: storageClassesEnabled, + storageClassesEnabled: ctx.Config.Sync.ToHost.StorageClasses.Enabled, schedulerEnabled: ctx.Config.ControlPlane.Advanced.VirtualScheduler.Enabled, useFakePersistentVolumes: !ctx.Config.Sync.ToHost.PersistentVolumes.Enabled, }, nil diff --git a/pkg/controllers/resources/persistentvolumes/translate.go b/pkg/controllers/resources/persistentvolumes/translate.go index 68424ed7bc..675f45bb70 100644 --- a/pkg/controllers/resources/persistentvolumes/translate.go +++ b/pkg/controllers/resources/persistentvolumes/translate.go @@ -16,7 +16,9 @@ func (s *persistentVolumeSyncer) translate(ctx *synccontext.SyncContext, vPv *co pPV.Spec.ClaimRef = nil // TODO: translate the storage secrets - pPV.Spec.StorageClassName = mappings.VirtualToHostName(ctx, vPv.Spec.StorageClassName, "", mappings.StorageClasses()) + if pPV.Spec.StorageClassName != "" { + pPV.Spec.StorageClassName = translate.Default.HostNameCluster(vPv.Spec.StorageClassName) + } return pPV, nil }