Skip to content

Conversation

@imeoer
Copy link
Collaborator

@imeoer imeoer commented Dec 19, 2025

This pull request introduces significant improvements to the metrics collection for mounted model volumes, refactors metric naming for clarity, and adds robust test coverage for the new metrics. The main changes are grouped below:

Metrics Collection Enhancements:

  • Added a new MountItemCollector in pkg/metrics/mount_collector.go to export detailed mount item metrics, including reference, type (pvc, inline, dynamic), volume name, and mount ID. This enables fine-grained tracking of mounted items.
  • The cache manager (pkg/service/cache.go) now collects and sets mount item metrics, distinguishing between PVC, inline, and dynamic models, and updates aggregate metrics accordingly. [1] [2]

Metric Naming and Registry Refactor:

  • Renamed metrics for clarity: NodeMountedStaticImagesNodeMountedPVCModels, NodeMountedDynamicImagesNodeMountedInlineModels, and added NodeMountedDynamicModels for dynamic mounts. Registry initialization updated to use new metric names and register the new mount item collector. [1] [2] [3]

Testing Improvements:

  • Added pkg/service/cache_test.go to verify that the cache manager correctly updates both aggregate and detailed mount item metrics, with checks for label accuracy and snapshot consistency.

Code Quality and Bug Fixes:

  • Fixed a typo: CacheSacnIntervalCacheScanInterval in both declaration and usage. [1] [2]
  • Updated the cache manager constructor and service initialization to require a StatusManager, ensuring correct status handling for mount metrics. [1] [2]

Dependency Updates:

  • Added github.com/prometheus/client_model and github.com/kylelemons/godebug to go.mod for metrics and testing support. [1] [2] [3]

@gemini-code-assist
Copy link

Summary of Changes

Hello @imeoer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the observability of mounted volumes by introducing a new Prometheus metric that provides detailed information about each mounted item. It refines the cache management logic to actively collect and export these granular metrics, distinguishing between static, dynamic, and inline volume types. The changes also include new tests to ensure the accuracy of the metric collection and updates the service initialization to accommodate the enhanced cache manager.

Highlights

  • Detailed Mount Item Metrics: Introduced a new Prometheus metric, mount_item, which provides a detailed snapshot of mounted items. This metric includes labels for reference, type (static, dynamic, inline), volume_name, and mount_id for granular observability.
  • Cache Manager Enhancements: The CacheManager has been updated to actively collect and export these new detailed mount item metrics. It now distinguishes between static, dynamic, and inline models, and updates a new NodeMountedInlineImages gauge.
  • Dependency Injection for Cache Manager: The CacheManager constructor now requires a StatusManager instance, improving its testability and dependency management. The service initialization has been updated to provide this dependency.
  • Comprehensive Testing: A new test, TestCacheManagerScanUpdatesMetrics, has been added to verify that the CacheManager correctly updates all relevant metrics, including the new mount item metric, for various volume types.
  • Dependency Updates: Added github.com/prometheus/client_model and github.com/kylelemons/godebug to go.mod to support the new metrics and testing capabilities.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@imeoer imeoer force-pushed the metrics-mount-collector branch from 31248fe to 1502b07 Compare December 19, 2025 08:52
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new Prometheus metric mount_item to provide detailed information about mounted items, which is a great enhancement for observability. The changes include a new custom collector, updates to the cache manager to gather this data, and new tests.

My review focuses on the correctness and maintainability of the new logic. I've found a critical issue in the detection of 'inline' models which would prevent them from being reported. I've also suggested an improvement to the new test case to make it more robust and maintainable. Overall, these are valuable additions with a few areas for refinement.

@imeoer imeoer force-pushed the metrics-mount-collector branch 6 times, most recently from 5770725 to 125ec14 Compare December 22, 2025 11:02
@imeoer imeoer marked this pull request as ready for review December 22, 2025 11:02
@imeoer imeoer force-pushed the metrics-mount-collector branch 2 times, most recently from 7346dab to e2906bb Compare December 23, 2025 07:54
Introduce a new Prometheus metric for tracking detailed information
about mounted items and refines the cache manager to export richer metrics.
It also adds corresponding tests to ensure correct metric collection.

The changes enhance observability of mounted volumes, distinguishing between
pvc, inline and dynamic models.

Additionally, it improves the cache size calculation method to avoid
double-counting file sizes from hardlinks.

Signed-off-by: imeoer <yansong.ys@antgroup.com>
@imeoer imeoer force-pushed the metrics-mount-collector branch from e2906bb to e8a85f7 Compare December 23, 2025 07:55
Copy link
Member

@gaius-qi gaius-qi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

@imeoer imeoer merged commit 1761a8c into modelpack:main Dec 23, 2025
9 checks passed
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.

3 participants