@@ -136,6 +136,7 @@ const (
136
136
VMServiceExtensionServiceName = "vmware-system-vmop-webhook-service"
137
137
scParamStoragePolicyID = "storagePolicyID"
138
138
StorageQuotaPeriodicSyncInstanceName = "storage-quota-periodic-sync"
139
+ FileVolumePrefix = "file:"
139
140
)
140
141
141
142
// newInformer returns uninitialized metadataSyncInformer.
@@ -3901,7 +3902,15 @@ func storagePolicyUsageCRSync(ctx context.Context, metadataSyncer *metadataSyncI
3901
3902
for _ , pv := range volumes {
3902
3903
// Verify the StorageClass, StoragePolicyId match with the storagePolicyUsage spec
3903
3904
// using the cnsVolumeInfo CR for the volume
3904
- if cnsVolumeInfo , ok := cnsVolumeInfoMap [pv .Spec .CSI .VolumeHandle ]; ok {
3905
+ volumeHandle := pv .Spec .CSI .VolumeHandle
3906
+ // For file volumes replace prefix "file:" with "file-", since CnsVolumeInfo CR
3907
+ // is created as "file-<uuid>". For example, see below.
3908
+ // cnsvolumeinfo name: file-e6a32a53-2783-42cd-a854-4df28582f04c
3909
+ // pv.Spec.volumeHandle: file:e6a32a53-2783-42cd-a854-4df28582f04c
3910
+ if strings .HasPrefix (pv .Spec .CSI .VolumeHandle , FileVolumePrefix ) {
3911
+ volumeHandle = strings .Replace (pv .Spec .CSI .VolumeHandle , ":" , "-" , 1 )
3912
+ }
3913
+ if cnsVolumeInfo , ok := cnsVolumeInfoMap [volumeHandle ]; ok {
3905
3914
if cnsVolumeInfo .Spec .StorageClassName == storagePolicyUsage .Spec .StorageClassName &&
3906
3915
cnsVolumeInfo .Spec .StoragePolicyID == storagePolicyUsage .Spec .StoragePolicyId &&
3907
3916
cnsVolumeInfo .Spec .Namespace == storagePolicyUsage .Namespace {
0 commit comments