@@ -41,11 +41,6 @@ const (
4141 fuseMemoryAllocatableFactorKey = "fuseMemoryAllocatableFactor"
4242 fuseEphemeralStorageAllocatableFactorKey = "fuseEphemeralStorageAllocatableFactor"
4343
44- // Default values for StorageClass param keys.
45- fuseFileCacheMediumPriorityDefaultVal = "gpu:ram|lssd,tpu:ram,general_purpose:ram|lssd"
46- fuseMemoryAllocatableFactorDefaultVal = "0.7"
47- fuseEphemeralStorageAllocatableFactorDefaultVal = "0.85"
48-
4944 // Node allocatable resource keys.
5045 nvidiaGpuResourceName = corev1 .ResourceName ("nvidia.com/gpu" )
5146 googleTpuResourceName = corev1 .ResourceName ("google.com/tpu" )
@@ -90,7 +85,6 @@ type ProfileConfig struct {
9085type pvDetails struct {
9186 numObjects int64 // The number of objects reported by the PV.
9287 totalSizeBytes int64 // The total size in bytes reported by the PV.
93- locationType string // The location type of the bucket.
9488 name string // The name of the PersistentVolume.
9589}
9690
@@ -293,14 +287,12 @@ type GCSFuseCSIRecommendationLog struct {
293287 InputSignals struct {
294288 BucketTotalObjects int64 `json:"bucketTotalObjects"`
295289 BucketTotalDataSizeBytes int64 `json:"bucketTotalDataSizeBytes"`
296- BucketLocationType string `json:"bucketLocationType"`
297290 RequiredFileCacheBytes int64 `json:"requiredFileCacheBytes"`
298291 RequiredMetadataStatCacheBytes int64 `json:"requiredMetadataStatCacheBytes"`
299292 RequiredMetadataTypeCacheBytes int64 `json:"requiredMetadataTypeCacheBytes"`
300293 NodeType string `json:"nodeType"`
301294 NodeAllocatableMemoryBytes int64 `json:"nodeAllocatableMemoryBytes"`
302295 NodeAllocatableEphemeralStorageBytes int64 `json:"nodeAllocatableEphemeralStorageBytes"`
303- NodeHasEphemeralStorageLSSD bool `json:"nodeHasEphemeralStorageLSSD"`
304296 SidecarLimitMemoryBytes int64 `json:"sidecarLimitMemoryBytes"`
305297 SidecarLimitEphemeralStorageBytes int64 `json:"sidecarLimitEphemeralStorageBytes"`
306298 FuseBudgetMemoryBytes int64 `json:"fuseBudgetMemoryBytes"`
@@ -357,13 +349,11 @@ func logRecommendation(config *ProfileConfig, recommendation *recommendation, re
357349 // Bucket signals
358350 logEntry .InputSignals .BucketTotalObjects = config .pvDetails .numObjects
359351 logEntry .InputSignals .BucketTotalDataSizeBytes = config .pvDetails .totalSizeBytes
360- logEntry .InputSignals .BucketLocationType = config .pvDetails .locationType
361352
362353 // Node signals
363354 logEntry .InputSignals .NodeType = config .nodeDetails .nodeType
364355 logEntry .InputSignals .NodeAllocatableMemoryBytes = config .nodeDetails .nodeAllocatables .memoryBytes
365356 logEntry .InputSignals .NodeAllocatableEphemeralStorageBytes = config .nodeDetails .nodeAllocatables .ephemeralStorageBytes
366- logEntry .InputSignals .NodeHasEphemeralStorageLSSD = config .nodeDetails .hasLocalSSDEphemeralStorageAnnotation
367357
368358 // Pod signals
369359 logEntry .InputSignals .SidecarLimitMemoryBytes = config .podDetails .sidecarLimits .memoryBytes
@@ -426,20 +416,21 @@ func (config *ProfileConfig) MergeRecommendedMountOptionsOnMissingKeys(userMount
426416
427417 cacheOptions := []string {}
428418
429- // Map the recommended cache sizes and medium recommendations to mount options.
430- // The mount options must be passed, even if they are set to zero, in order to override
431- // GCSFuse's --profile flag.
432- for moKey , bytes := range map [string ]int64 {
433- metadataStatCacheMaxSizeMiBMountOptionKey : recommendation .metadataStatCacheBytes ,
434- metadataTypeCacheMaxSizeMiBMountOptionKey : recommendation .metadataTypeCacheBytes ,
435- fileCacheSizeMiBMountOptionKey : recommendation .fileCacheBytes ,
436- } {
437- cacheOptions = append (cacheOptions , fmt .Sprintf ("%s:%d" , moKey , bytesToMiB (bytes )))
419+ // Map the recommended metadata stat cache size to equivalent mount option.
420+ if recommendation .metadataStatCacheBytes > 0 {
421+ cacheOptions = append (cacheOptions , fmt .Sprintf ("%s:%d" , metadataStatCacheMaxSizeMiBMountOptionKey , bytesToMiB (recommendation .metadataStatCacheBytes )))
422+ }
423+
424+ // Map the recommended metadata type cache size to equivalent mount option.
425+ if recommendation .metadataTypeCacheBytes > 0 {
426+ cacheOptions = append (cacheOptions , fmt .Sprintf ("%s:%d" , metadataTypeCacheMaxSizeMiBMountOptionKey , bytesToMiB (recommendation .metadataTypeCacheBytes )))
438427 }
439428
440- // Only pass the file cache medium if file cache is enabled .
429+ // Map the recommended file cache size & medium to equivalent mount options .
441430 if recommendation .fileCacheBytes > 0 && recommendation .fileCacheMedium != "" {
431+ cacheOptions = append (cacheOptions , fmt .Sprintf ("%s:%d" , fileCacheSizeMiBMountOptionKey , bytesToMiB (recommendation .fileCacheBytes )))
442432 // Note: File cache medium *must* be delimeted with an "=" sign, since it's an internal CSI flag.
433+ // TODO(urielguzman): Add a sidecar version check in the driver before passing this flag down to the sidecar mounter.
443434 cacheOptions = append (cacheOptions , fmt .Sprintf ("%s=%s" , util .FileCacheMediumConst , recommendation .fileCacheMedium ))
444435 }
445436
@@ -454,15 +445,10 @@ func (config *ProfileConfig) MergeRecommendedMountOptionsOnMissingKeys(userMount
454445// buildCacheRequirements constructs a cacheRequirements struct based on the provided pvDetails.
455446// It calculates the ideal sizes for metadata stat, metadata type, and file caches.
456447func buildCacheRequirements (pvDetails * pvDetails ) * cacheRequirements {
457- requiredFileCacheBytes := pvDetails .totalSizeBytes
458- if isZonalBucket (pvDetails .locationType ) {
459- klog .Infof ("Bucket location type is %q, file cache not required. Disabling file cache." , pvDetails .locationType )
460- requiredFileCacheBytes = 0
461- }
462448 return & cacheRequirements {
463449 metadataStatCacheBytes : pvDetails .numObjects * metadataStatCacheBytesPerObject ,
464450 metadataTypeCacheBytes : pvDetails .numObjects * metadataTypeCacheBytesPerObject ,
465- fileCacheBytes : requiredFileCacheBytes ,
451+ fileCacheBytes : pvDetails . totalSizeBytes ,
466452 }
467453}
468454
@@ -610,11 +596,13 @@ func recommendMetadataCacheSize(config *ProfileConfig, required, memoryBudget in
610596}
611597
612598// parseFloatParameterNonNegative extracts a parameter by key from the params map,
613- // parses it as a float64, and returns an error if the value
614- // is not a valid float, or the value is negative. If the value is not found, it defaults
615- // to an internal value.
616- func parseFloatParameterNonNegative (pv * corev1.PersistentVolume , sc * storagev1.StorageClass , key , defaultVal string ) (float64 , error ) {
617- stringVal := profilesutil .AttributeWithSCFallback (pv , sc , key , defaultVal )
599+ // parses it as a float64, and returns an error if the key is missing, the value
600+ // is not a valid float, or the value is negative.
601+ func parseFloatParameterNonNegative (pv * corev1.PersistentVolume , sc * storagev1.StorageClass , key string ) (float64 , error ) {
602+ stringVal , ok := profilesutil .AttributeWithSCFallback (pv , sc , key )
603+ if ! ok {
604+ return 0 , fmt .Errorf ("missing %q" , key )
605+ }
618606 floatVal , err := strconv .ParseFloat (stringVal , 64 )
619607 if err != nil {
620608 return 0 , fmt .Errorf ("failed to parse %q: %w" , key , err )
@@ -712,14 +700,10 @@ func buildPVDetails(
712700 return nil , fmt .Errorf ("invalid annotation format on PV %q: %s" , pv .Name , errorMsg )
713701 }
714702
715- // Parse the location type.
716- locationType := pvAnnotations [profilesutil .AnnotationLocationType ]
717-
718703 return & pvDetails {
719704 name : pv .Name ,
720705 numObjects : numObjects ,
721706 totalSizeBytes : totalSizeBytes ,
722- locationType : locationType ,
723707 }, nil
724708}
725709
@@ -808,20 +792,23 @@ func buildSCDetails(pv *corev1.PersistentVolume, sc *v1.StorageClass, volumeAttr
808792 }
809793
810794 // Get the file cache medium priority from the StorageClass parameters (or PV override).
811- fileCacheMediumPriorityStr := profilesutil .AttributeWithSCFallback (pv , sc , fuseFileCacheMediumPriorityKey , fuseFileCacheMediumPriorityDefaultVal )
795+ fileCacheMediumPriorityStr , ok := profilesutil .AttributeWithSCFallback (pv , sc , fuseFileCacheMediumPriorityKey )
796+ if ! ok {
797+ return nil , fmt .Errorf ("missing fuseFileCacheMediumPriority in StorageClass %q" , sc .Name )
798+ }
812799 fileCacheMediumPriority , err := parseFileCacheMediumPriority (fileCacheMediumPriorityStr )
813800 if err != nil {
814801 return nil , fmt .Errorf ("failed to parse fuseFileCacheMediumPriority in StorageClass %q: %v" , sc .Name , err )
815802 }
816803
817804 // Get the fuse memory allocatable factor from the StorageClass parameters (or PV override).
818- fuseMemoryAllocatableFactor , err := parseFloatParameterNonNegative (pv , sc , fuseMemoryAllocatableFactorKey , fuseMemoryAllocatableFactorDefaultVal )
805+ fuseMemoryAllocatableFactor , err := parseFloatParameterNonNegative (pv , sc , fuseMemoryAllocatableFactorKey )
819806 if err != nil {
820807 return nil , fmt .Errorf ("failed to parse fuse memory allocatable factor param in StorageClass %q: %v" , sc .Name , err )
821808 }
822809
823810 // Get the fuse ephemeral storage allocatable factor from the StorageClass parameters.
824- fuseEphemeralStorageAllocatableFactor , err := parseFloatParameterNonNegative (pv , sc , fuseEphemeralStorageAllocatableFactorKey , fuseEphemeralStorageAllocatableFactorDefaultVal )
811+ fuseEphemeralStorageAllocatableFactor , err := parseFloatParameterNonNegative (pv , sc , fuseEphemeralStorageAllocatableFactorKey )
825812 if err != nil {
826813 return nil , fmt .Errorf ("failed to parse fuse ephemeral storage allocatable factor param in StorageClass %q: %v" , sc .Name , err )
827814 }
0 commit comments