Skip to content

Create podmonitor#48

Merged
iasthc merged 2 commits intomainfrom
fix/create_podmonitor
Mar 23, 2026
Merged

Create podmonitor#48
iasthc merged 2 commits intomainfrom
fix/create_podmonitor

Conversation

@george-wu20250203
Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 refines the creation and configuration of PodMonitor resources within the model service. It improves the robustness of PodMonitor definition by ensuring default values are correctly applied and modifies the enablement logic to default to active monitoring. Additionally, it corrects specific labels applied to these monitoring resources.

Highlights

  • PodMonitor Defaulting Logic: The BuildPodMonitor function now correctly initializes default values for portName, path, and interval for PodMonitor resources, ensuring robustness when monitoring specifications are not fully defined in the ModelService spec.
  • PodMonitor Enablement Behavior: The EnsurePodMonitors function's logic for enabling PodMonitor creation has been updated to default to enabled: true if monitoring specifications are absent, only disabling it when explicitly set to false in the ModelService spec.
  • Label Correction for PodMonitors: The LabelInferenceServer is now explicitly removed from decodeLabels and prefillLabels when building PodMonitor resources, addressing a potential labeling inconsistency.
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.

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
Copy Markdown

@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 significant improvements to the PodMonitor creation logic. A critical bug related to nil pointer dereference when ms.Spec.Monitoring is not defined has been fixed in BuildPodMonitor, enhancing the robustness of the controller. Additionally, the default enablement behavior for PodMonitors has been clarified and updated to be enabled by default unless explicitly disabled. The handling of labels for PodMonitor metadata has also been refined for better consistency across Kubernetes objects.

Comment on lines +33 to 48
portName := "http"
path := "/metrics"
interval := "30s"

portName := mon.PortName
if portName == "" {
portName = "http"
}
path := mon.Path
if path == "" {
path = "/metrics"
}
interval := mon.Interval
if interval == "" {
interval = "30s"
if ms.Spec.Monitoring != nil && ms.Spec.Monitoring.PodMonitor != nil {
mon := ms.Spec.Monitoring.PodMonitor
if mon.PortName != "" {
portName = mon.PortName
}
if mon.Path != "" {
path = mon.Path
}
if mon.Interval != "" {
interval = mon.Interval
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The refactored logic correctly initializes default values for portName, path, and interval before attempting to access ms.Spec.Monitoring.PodMonitor. This change effectively prevents a potential nil pointer dereference that could occur if ms.Spec.Monitoring was nil, which is a critical correctness improvement.


decodeSelectorLabels := SelectorLabelsForRole(ms.Name, ComponentDecode, RoleDecode)
decodeLabels := LabelsForRole(ms.Name, ComponentDecode, version)
delete(decodeLabels, LabelInferenceServer)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Removing LabelInferenceServer from the decodeLabels before passing them as metadataLabels to the PodMonitor is a good refinement. This label is typically associated with the Deployment resource itself, and its exclusion from the PodMonitor's metadata ensures a more accurate and consistent labeling scheme for monitoring resources.

if ms.Spec.Prefill != nil {
prefillSelectorLabels := SelectorLabelsForRole(ms.Name, ComponentPrefill, RolePrefill)
prefillLabels := LabelsForRole(ms.Name, ComponentPrefill, version)
delete(prefillLabels, LabelInferenceServer)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similarly, removing LabelInferenceServer from the prefillLabels for the prefill PodMonitor's metadata improves label consistency. This ensures that the metadata labels on the PodMonitor accurately reflect its purpose without including labels primarily meant for the associated Deployment.

@iasthc iasthc merged commit f3a2e31 into main Mar 23, 2026
10 checks passed
@iasthc iasthc deleted the fix/create_podmonitor branch March 23, 2026 14:03
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 0% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/modelservice/podmonitor.go 0.00% 11 Missing ⚠️
internal/modelservice/reconcile.go 0.00% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

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