Skip to content

fix: use non-deprecated node instance type label#132

Merged
slin1237 merged 1 commit into
ome-projects:mainfrom
abatilo:fix/use-non-deprecated-node-instance-label
Jul 5, 2025
Merged

fix: use non-deprecated node instance type label#132
slin1237 merged 1 commit into
ome-projects:mainfrom
abatilo:fix/use-non-deprecated-node-instance-label

Conversation

@abatilo
Copy link
Copy Markdown
Contributor

@abatilo abatilo commented Jul 5, 2025

Replace deprecated beta.kubernetes.io/instance-type label with the GA
node.kubernetes.io/instance-type label for node instance type detection.

The code now tries the newer label first using the ok value from map
lookup and falls back to the deprecated beta label for backward
compatibility. This ensures the code works with both old and new
Kubernetes versions while preferring the non-deprecated label when
available.

The deprecated label constant has been moved to pkg/constants for
better maintainability.

Copy link
Copy Markdown
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 @abatilo, 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 addresses the deprecation of a Kubernetes node label by migrating to its General Availability (GA) counterpart. The change ensures the application remains current with Kubernetes best practices while maintaining backward compatibility for environments that might still rely on the older label. The primary impact is an update to how node instance types are identified within the model agent's scout component.

Highlights

  • Deprecated Label Migration: Replaced the deprecated beta.kubernetes.io/instance-type Kubernetes node label with the GA node.kubernetes.io/instance-type label for identifying node instance types.
  • Backward Compatibility: Implemented robust fallback logic to ensure compatibility with older Kubernetes clusters that may still be using the deprecated beta.kubernetes.io/instance-type label if the newer GA label is not present.
  • Model Agent Update: Updated the model agent scout component to utilize this new label retrieval strategy, ensuring it correctly identifies node shapes across various Kubernetes versions.
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 is currently in preview and 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 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
Copy Markdown
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 migrates from the deprecated beta.kubernetes.io/instance-type label to the GA node.kubernetes.io/instance-type label, with fallback logic for backward compatibility. The review suggests refining the fallback logic and using a constant for the deprecated label.

Comment thread pkg/modelagent/scout.go Outdated
Comment on lines +62 to +64
instanceType := nodeInfo.Labels[constants.NodeInstanceShapeLabel]
if instanceType == "" {
instanceType = nodeInfo.Labels["beta.kubernetes.io/instance-type"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The current fallback logic uses an empty string check, which can lead to unintended behavior if the new label is intentionally set to an empty string. It's better to use the ok value from the map lookup to check if the label exists before falling back to the deprecated label. Also, the deprecated label key should be defined as a constant in pkg/constants for better maintainability.

Suggested change
instanceType := nodeInfo.Labels[constants.NodeInstanceShapeLabel]
if instanceType == "" {
instanceType = nodeInfo.Labels["beta.kubernetes.io/instance-type"]
instanceType, ok := nodeInfo.Labels[constants.NodeInstanceShapeLabel]
if !ok {
instanceType = nodeInfo.Labels[constants.NodeInstanceShapeLabelDeprecated]
}

@abatilo abatilo force-pushed the fix/use-non-deprecated-node-instance-label branch from ea0836a to f2258f4 Compare July 5, 2025 00:59
@abatilo abatilo changed the title fix: migrate from deprecated beta.kubernetes.io/instance-type label fix: use non-deprecated node instance type label Jul 5, 2025
Replace deprecated beta.kubernetes.io/instance-type label with the GA
node.kubernetes.io/instance-type label for node instance type detection.

The code now tries the newer label first using the ok value from map
lookup and falls back to the deprecated beta label for backward
compatibility. This ensures the code works with both old and new
Kubernetes versions while preferring the non-deprecated label when
available.

The deprecated label constant has been moved to pkg/constants for
better maintainability.
@abatilo abatilo force-pushed the fix/use-non-deprecated-node-instance-label branch from f2258f4 to ce28313 Compare July 5, 2025 01:09
@slin1237 slin1237 merged commit 078b8de into ome-projects:main Jul 5, 2025
23 checks passed
slin1237 pushed a commit that referenced this pull request Dec 22, 2025
Replace deprecated beta.kubernetes.io/instance-type label with the GA
node.kubernetes.io/instance-type label for node instance type detection.

The code now tries the newer label first using the ok value from map
lookup and falls back to the deprecated beta label for backward
compatibility. This ensures the code works with both old and new
Kubernetes versions while preferring the non-deprecated label when
available.

The deprecated label constant has been moved to pkg/constants for
better maintainability.
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