Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (s *persistentVolumeClaimSyncer) translateSelector(ctx *synccontext.SyncCon

// translate storage class if we manage those in vcluster
if s.storageClassesEnabled && storageClassName != "" {
translated := translate.Default.HostNameCluster(storageClassName)
translated := mappings.VirtualToHostName(ctx, storageClassName, "", mappings.StorageClasses())
delete(vPvc.Annotations, deprecatedStorageClassAnnotation)
vPvc.Spec.StorageClassName = &translated
}
Expand All @@ -67,20 +67,20 @@ func (s *persistentVolumeClaimSyncer) translateSelector(ctx *synccontext.SyncCon
vPvc.Spec.Selector = translate.HostLabelSelector(vPvc.Spec.Selector)
}
if vPvc.Spec.VolumeName != "" {
vPvc.Spec.VolumeName = translate.Default.HostNameCluster(vPvc.Spec.VolumeName)
vPvc.Spec.VolumeName = mappings.VirtualToHostName(ctx, vPvc.Spec.VolumeName, "", mappings.PersistentVolumes())
}
// check if the storage class exists in the physical cluster
if !s.storageClassesEnabled && storageClassName != "" {
// Should the PVC be dynamically provisioned or not?
if vPvc.Spec.Selector == nil && vPvc.Spec.VolumeName == "" {
err := ctx.HostClient.Get(ctx, types.NamespacedName{Name: storageClassName}, &storagev1.StorageClass{})
if err != nil && kerrors.IsNotFound(err) {
translated := translate.Default.HostNameCluster(storageClassName)
translated := mappings.VirtualToHostName(ctx, storageClassName, "", mappings.StorageClasses())
delete(vPvc.Annotations, deprecatedStorageClassAnnotation)
vPvc.Spec.StorageClassName = &translated
}
} else {
translated := translate.Default.HostNameCluster(storageClassName)
translated := mappings.VirtualToHostName(ctx, storageClassName, "", mappings.StorageClasses())
delete(vPvc.Annotations, deprecatedStorageClassAnnotation)
vPvc.Spec.StorageClassName = &translated
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/resources/persistentvolumes/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (s *persistentVolumeSyncer) Sync(ctx *synccontext.SyncContext, event *syncc
// update host object
if event.Virtual.Annotations[constants.HostClusterPersistentVolumeAnnotation] == "" {
// TODO: translate the storage secrets
event.Host.Spec.StorageClassName = translate.Default.HostNameCluster(event.Virtual.Spec.StorageClassName)
event.Host.Spec.StorageClassName = mappings.VirtualToHostName(ctx, event.Virtual.Spec.StorageClassName, "", mappings.StorageClasses())
}

// bi-directional sync of annotations and labels
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/resources/persistentvolumes/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (s *persistentVolumeSyncer) translate(ctx *synccontext.SyncContext, vPv *co

// TODO: translate the storage secrets
if pPV.Spec.StorageClassName != "" {
pPV.Spec.StorageClassName = translate.Default.HostNameCluster(vPv.Spec.StorageClassName)
pPV.Spec.StorageClassName = mappings.VirtualToHostName(ctx, vPv.Spec.StorageClassName, "", mappings.StorageClasses())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Align PV storageClass mapping with Sync reconcile logic

With sync.toHost.storageClasses.enabled=false, this new call resolves through the StorageClass mirror mapper and keeps the original class name, but persistentvolumes/syncer.go still forces translate.Default.HostNameCluster(...) in Sync (event.Host.Spec.StorageClassName at lines 249-251). That makes the create path and steady-state reconcile path disagree for the same PV, and after this commit PVC translation now also keeps the unmodified class, so host PV/PVC storage class names can diverge and prevent binding (or cause repeated reconcile attempts if the field update is rejected).

Useful? React with 👍 / 👎.

}
return pPV, nil
}
Expand Down