Skip to content

Conversation

calvin0327
Copy link
Contributor

What type of PR is this?
/kind feature

What this PR does / why we need it:

we can very easy to apply serviceMonitor resource for device plugin and scheduler by --set scheduler.serviceMonitor.enabled=true and --set devicePlugin.serviceMonitor.enabled=true.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

@hami-robot
Copy link
Contributor

hami-robot bot commented Aug 4, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: calvin0327
Once this PR has been reviewed and has the lgtm label, please assign archlitchi for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions github-actions bot removed the kind/feature new function label Aug 4, 2025
@hami-robot hami-robot bot added the size/M label Aug 4, 2025
Copy link
Contributor

@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.

Summary of Changes

Hello @calvin0327, 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!

I've implemented a feature to simplify the integration of Prometheus monitoring with the Hami Helm chart. This pull request introduces dedicated ServiceMonitor resources for both the device plugin and scheduler components, making it straightforward to enable metric scraping through simple Helm value configurations. This change significantly improves the observability of these components within a Kubernetes environment.

Highlights

  • Device Plugin ServiceMonitor: I introduced a new Kubernetes ServiceMonitor resource template for the hami-device-plugin component. This allows Prometheus to automatically discover and scrape metrics from the device plugin, enhancing observability.
  • Scheduler ServiceMonitor: I added a new Kubernetes ServiceMonitor resource template for the hami-scheduler component. Similar to the device plugin, this enables Prometheus to scrape metrics from the scheduler, providing better insights into its operation.
  • Helm Chart Configuration Options: I updated the values.yaml file to include new serviceMonitor.enabled flags under both the scheduler and devicePlugin sections. These flags, defaulting to false, allow users to easily enable or disable the creation of these ServiceMonitor resources via Helm chart values, such as --set scheduler.serviceMonitor.enabled=true.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 or fill out our survey to provide feedback.

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.

Copy link
Contributor

@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 ServiceMonitor resources for the device plugin and scheduler, which is a great feature for observability. However, there are a few issues that need to be addressed. The primary issue is that the new resources are guarded by an incorrect and undefined value (.Values.enableGateway) instead of the newly introduced flags in values.yaml. Additionally, for better consistency and flexibility, the standard chart labels should be included in the ServiceMonitor metadata, and the bearerTokenSecret should be made configurable. Addressing these points will make the new feature robust and easy to use.

@wawa0210
Copy link
Member

wawa0210 commented Aug 4, 2025

/gemini review

Copy link
Contributor

@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 ServiceMonitor resources for both the scheduler and device-plugin components, which is a valuable addition for enabling Prometheus-based monitoring. The implementation is a good start, but I've identified several areas for improvement to align with Helm best practices. My feedback focuses on enhancing configurability by avoiding hardcoded values, ensuring resource consistency by including standard Helm labels, and improving the robustness of service discovery with more specific selectors. These changes will make the chart more flexible and easier to manage for users.

@calvin0327 calvin0327 force-pushed the enabled-servicemonitor branch from a44d2c1 to 3a410a1 Compare August 4, 2025 12:35
Copy link

codecov bot commented Aug 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 66.04% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wawa0210
Copy link
Member

wawa0210 commented Aug 5, 2025

/gemini review

Copy link
Contributor

@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 ServiceMonitor resources for the hami-vgpu scheduler and device-plugin. The changes are well-structured, but there are opportunities to improve flexibility and correctness by making the Prometheus release label and scrape interval configurable, correcting the metric relabeling logic for the device-plugin, and ensuring the device-plugin service exposes the monitorport.

@calvin0327 calvin0327 force-pushed the enabled-servicemonitor branch from 3a410a1 to 19022bb Compare August 5, 2025 03:49
@calvin0327
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@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 ServiceMonitor resources for the scheduler and device-plugin components, allowing for easier integration with Prometheus for monitoring. The implementation is straightforward, adding new templates and corresponding values.

My review has identified a few areas for improvement:

  • Critical: The ServiceMonitor selectors are likely incorrect as they don't include the standard chart labels, which will prevent them from discovering the target services.
  • High: The port names in the ServiceMonitor endpoints are hardcoded, creating a fragile dependency on the Service definitions.
  • Medium: The jobLabel is too generic, and there's a minor formatting issue with a missing newline at the end of a template file.

Addressing these points will significantly improve the robustness and correctness of this new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants