Skip to content

Conversation

uriel-guzman
Copy link
Collaborator

@uriel-guzman uriel-guzman commented Oct 16, 2025

What type of PR is this?
/kind feature

What this PR does / why we need it:
This PR implements an initial version of an intelligent recommender in recommender.go to automatically generate optimal GCS FUSE mount options. The primary goal is to enhance performance by dynamically configuring GCS FUSE cache settings based on available cluster resources and PersistentVolume characteristics.

The key components introduced are:

  • cacheRequirements: Defines ideal sizes for different cache types (metadata stat, metadata type, file cache) derived from PV details like object count and total size.
  • Resource Budget Calculation: Functions calculateFuseResourceBudget and calculateResourceBudgets determine the memory and ephemeral storage capacity available for GCS FUSE, considering node allocatables, StorageClass factors (fuseMemoryAllocatableFactor, fuseEphemeralStorageAllocatableFactor), and sidecar container limits.
  • Metadata Cache Recommendation: recommendMetadataCacheSize calculates recommended sizes for the metadata stat and type caches, ensuring they do not exceed the computed memory budget.
  • Mount Option Generation: RecommendMountOptionsorchestrates the process, calling recommendCacheConfigs to get cache size recommendations and then using addRecommendationToMountOptions to append the calculated metadata-cache:stat-cache-max-size-mb and metadata-cache:type-cache-max-size-mb options, returning a slice that expands upon the StorageClass's existing mount options.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

  • File cache size and medium calculation is not implemented in this PR. The next PR will calculate these mount options.

Does this PR introduce a user-facing change?:

NONE

@uriel-guzman uriel-guzman force-pushed the recommend-metadata-cache branch 2 times, most recently from 58f2745 to 2e9ad3a Compare October 16, 2025 01:47
@uriel-guzman
Copy link
Collaborator Author

/gemini review

@uriel-guzman uriel-guzman marked this pull request as ready for review October 16, 2025 01:56
}{
{
name: "Bytes greater than 0 - Should add formatted option",
initialOptions: []string{"opt1"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need a test case for what happens when mountOptionKey is already set to different value in initialOptions? Your current implementation appends, so we would have duplicate options in wantOptions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I can make the addRecommendationToMountOptions only append if the key doesn't exist. I was planning on doing this until we get to NodePublishVolume (at that point, the customer's PV / ephemeral storage mount options are merged with the output from RecommendMountOptions and deduplication occurs, making the customer's PV / ephemeral storage options take precedence over the recommendations), but it wouldn't hurt to also add the deduplication here too. In fact, we can re-use this function later so it would be a good idea.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed. Also added test case for this.

}
}

func TestAddRecommendationToMountOptions(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see all test cases use config file format for existing mount options. Should we also test cmd line flag mount option? https://cloud.google.com/storage/docs/cloud-storage-fuse/config-file#format-and-fields https://cloud.google.com/storage/docs/cloud-storage-fuse/cli-options#options

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just as a note: This formatting (key=val) is already validated in https://github.com/GoogleCloudPlatform/gcs-fuse-csi-driver/blob/main/pkg/profiles/recommender_test.go#L61, but I can add another test case to this test group to include a key=val format mount option (cmd line).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed, added test case for this.


// Calculate the recommended metadata cache sizes. The memoryBudget gets decreased after each recommendation.
recommendation.metadataStatCacheBytes, memoryBudget = recommendMetadataCacheSize(config, cacheRequirements.metadataStatCacheBytes, memoryBudget, "stat")
recommendation.metadataTypeCacheBytes, _ = recommendMetadataCacheSize(config, cacheRequirements.metadataTypeCacheBytes, memoryBudget, "type")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is memoryBudget ignored here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not used yet. It will be used in the next PR, where the memoryBudget is used to calculate if the file cache will fit or not in the remaining budget.

@uriel-guzman uriel-guzman force-pushed the recommend-metadata-cache branch from 2e9ad3a to 3e15c0e Compare October 17, 2025 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants