@@ -447,14 +447,6 @@ func (d *SANEconomyStorageDriver) Create(
447
447
}
448
448
sizeBytes = GetVolumeSize (sizeBytes , storagePool .InternalAttributes ()[Size ])
449
449
450
- lunSize := strconv .FormatUint (sizeBytes , 10 )
451
-
452
- if _ , _ , checkVolumeSizeLimitsError := drivers .CheckVolumeSizeLimits (
453
- ctx , sizeBytes , d .Config .CommonStorageDriverConfig ,
454
- ); checkVolumeSizeLimitsError != nil {
455
- return checkVolumeSizeLimitsError
456
- }
457
-
458
450
// Ensure LUN name isn't too long
459
451
if len (name ) > maxLunNameLength {
460
452
return fmt .Errorf ("volume %s name exceeds the limit of %d characters" , name , maxLunNameLength )
@@ -482,6 +474,19 @@ func (d *SANEconomyStorageDriver) Create(
482
474
luksEncryption = storagePool .InternalAttributes ()[LUKSEncryption ]
483
475
)
484
476
477
+ // Add a constant overhead for LUKS volumes to account for LUKS metadata. This overhead is
478
+ // part of the LUN but is not reported to the orchestrator.
479
+ reportedSize := sizeBytes
480
+ sizeBytes = incrementWithLUKSMetadataIfLUKSEnabled (ctx , sizeBytes , luksEncryption )
481
+
482
+ lunSize := strconv .FormatUint (sizeBytes , 10 )
483
+
484
+ if _ , _ , checkVolumeSizeLimitsError := drivers .CheckVolumeSizeLimits (
485
+ ctx , sizeBytes , d .Config .CommonStorageDriverConfig ,
486
+ ); checkVolumeSizeLimitsError != nil {
487
+ return checkVolumeSizeLimitsError
488
+ }
489
+
485
490
snapshotReserveInt , err := GetSnapshotReserve (snapshotPolicy , snapshotReserve )
486
491
if err != nil {
487
492
return fmt .Errorf ("invalid value for snapshotReserve: %v" , err )
@@ -510,7 +515,7 @@ func (d *SANEconomyStorageDriver) Create(
510
515
}
511
516
512
517
// Update config to reflect values used to create volume
513
- volConfig .Size = strconv .FormatUint (sizeBytes , 10 )
518
+ volConfig .Size = strconv .FormatUint (reportedSize , 10 )
514
519
volConfig .SpaceReserve = spaceReserve
515
520
volConfig .SnapshotPolicy = snapshotPolicy
516
521
volConfig .SnapshotReserve = snapshotReserve
@@ -646,6 +651,8 @@ func (d *SANEconomyStorageDriver) Create(
646
651
Logc (ctx ).WithField ("error" , err ).Error ("Failed to determine LUN size" )
647
652
return err
648
653
}
654
+ // Remove LUKS metadata size from actual size of LUN
655
+ actualSize = decrementWithLUKSMetadataIfLUKSEnabled (ctx , actualSize , luksEncryption )
649
656
volConfig .Size = strconv .FormatUint (actualSize , 10 )
650
657
651
658
// Save the fstype in a LUN attribute so we know what to do in Attach
@@ -883,6 +890,14 @@ func (d *SANEconomyStorageDriver) Import(
883
890
}
884
891
volConfig .Size = extantLUN .Size
885
892
893
+ if utils .ParseBool (volConfig .LUKSEncryption ) {
894
+ newSize , err := subtractUintFromSizeString (volConfig .Size , utils .LUKSMetadataSize )
895
+ if err != nil {
896
+ return err
897
+ }
898
+ volConfig .Size = newSize
899
+ }
900
+
886
901
if volConfig .ImportNotManaged {
887
902
// Volume/LUN import is not managed by Trident
888
903
if ! strings .HasPrefix (flexvol .Name , d .FlexvolNamePrefix ()) {
@@ -2152,6 +2167,10 @@ func (d *SANEconomyStorageDriver) Resize(ctx context.Context, volConfig *storage
2152
2167
Logd (ctx , d .Name (), d .Config .DebugTraceFlags ["method" ]).WithFields (fields ).Trace (">>>> Resize" )
2153
2168
defer Logd (ctx , d .Name (), d .Config .DebugTraceFlags ["method" ]).WithFields (fields ).Trace ("<<<< Resize" )
2154
2169
2170
+ // Add a constant overhead for LUKS volumes to account for LUKS metadata. This overhead is
2171
+ // part of the LUN but is not reported to the orchestrator.
2172
+ sizeBytes = incrementWithLUKSMetadataIfLUKSEnabled (ctx , sizeBytes , volConfig .LUKSEncryption )
2173
+
2155
2174
// Generic user-facing message
2156
2175
resizeError := errors .New ("storage driver failed to resize the volume" )
2157
2176
@@ -2251,6 +2270,8 @@ func (d *SANEconomyStorageDriver) Resize(ctx context.Context, volConfig *storage
2251
2270
Logc (ctx ).WithField ("error" , err ).Error ("LUN resize failed." )
2252
2271
return fmt .Errorf ("volume resize failed" )
2253
2272
}
2273
+ // LUKS metadata is not reported to orchestrator
2274
+ returnSize = decrementWithLUKSMetadataIfLUKSEnabled (ctx , returnSize , volConfig .LUKSEncryption )
2254
2275
2255
2276
volConfig .Size = strconv .FormatUint (returnSize , 10 )
2256
2277
0 commit comments