fix: use non-deprecated node instance type label#132
Conversation
There was a problem hiding this comment.
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-typeKubernetes node label with the GAnode.kubernetes.io/instance-typelabel 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-typelabel if the newer GA label is not present. - Model Agent Update: Updated the
model agent scoutcomponent 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
-
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. ↩
There was a problem hiding this comment.
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.
| instanceType := nodeInfo.Labels[constants.NodeInstanceShapeLabel] | ||
| if instanceType == "" { | ||
| instanceType = nodeInfo.Labels["beta.kubernetes.io/instance-type"] |
There was a problem hiding this comment.
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.
| 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] | |
| } |
ea0836a to
f2258f4
Compare
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.
f2258f4 to
ce28313
Compare
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.
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.