-
Notifications
You must be signed in to change notification settings - Fork 51
test: Fix test-git-server node affinity errors on Autopilot #2033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Set empty nodeSelector and add resource requirements for Autopilot clusters to resolve optimize-utilization-scheduler scheduling failures. Example failure https://storage.googleapis.com/oss-prow-build-kpt-config-sync/logs/kpt-config-sync-autopilot-stable/2016983552020713472/build-log.txthttps://storage.googleapis.com/oss-prow-build-kpt-config-sync/logs/kpt-config-sync-autopilot-stable/2016983552020713472/build-log.txt
|
Skipping CI for Draft Pull Request. |
|
/test-all |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello @tiffanny29631, 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 persistent scheduling failures for the Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this 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 effectively addresses test failures on GKE Autopilot clusters by correctly configuring resource requirements and an empty nodeSelector for the test-git-server deployment. The changes are well-structured and the refactoring to accommodate the Autopilot-specific logic is clean. I have one suggestion to further improve the maintainability of the new code by reducing some duplication.
| // Set resource requests and limits for git-server container | ||
| podSpec.Containers[0].Resources = corev1.ResourceRequirements{ | ||
| Requests: corev1.ResourceList{ | ||
| corev1.ResourceCPU: resource.MustParse("100m"), | ||
| corev1.ResourceMemory: resource.MustParse("128Mi"), | ||
| }, | ||
| Limits: corev1.ResourceList{ | ||
| corev1.ResourceCPU: resource.MustParse("100m"), | ||
| corev1.ResourceMemory: resource.MustParse("128Mi"), | ||
| }, | ||
| } | ||
| // Set resource requests and limits for http-git-server container | ||
| podSpec.Containers[1].Resources = corev1.ResourceRequirements{ | ||
| Requests: corev1.ResourceList{ | ||
| corev1.ResourceCPU: resource.MustParse("50m"), | ||
| corev1.ResourceMemory: resource.MustParse("64Mi"), | ||
| }, | ||
| Limits: corev1.ResourceList{ | ||
| corev1.ResourceCPU: resource.MustParse("50m"), | ||
| corev1.ResourceMemory: resource.MustParse("64Mi"), | ||
| }, | ||
| } | ||
| // Explicitly set empty nodeSelector to ensure no node affinity/selector constraints | ||
| // This prevents Autopilot's optimize-utilization-scheduler from applying implicit constraints | ||
| // that could cause "didn't match Pod's node affinity/selector" errors | ||
| podSpec.NodeSelector = map[string]string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve readability and maintainability, you can reduce code duplication by creating a ResourceList variable and reusing it for both Requests and Limits, as is required for Autopilot workloads.
Additionally, consider defining the magic strings for CPU and memory as constants.
// Set resource requests and limits for git-server container
gitServerResources := corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("100m"),
corev1.ResourceMemory: resource.MustParse("128Mi"),
}
podSpec.Containers[0].Resources = corev1.ResourceRequirements{
Requests: gitServerResources,
Limits: gitServerResources,
}
// Set resource requests and limits for http-git-server container
httpGitServerResources := corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("50m"),
corev1.ResourceMemory: resource.MustParse("64Mi"),
}
podSpec.Containers[1].Resources = corev1.ResourceRequirements{
Requests: httpGitServerResources,
Limits: httpGitServerResources,
}
// Explicitly set empty nodeSelector to ensure no node affinity/selector constraints
// This prevents Autopilot's optimize-utilization-scheduler from applying implicit constraints
// that could cause "didn't match Pod's node affinity/selector" errors
podSpec.NodeSelector = map[string]string{}|
/test all |
Set empty nodeSelector and add resource requirements for Autopilot clusters to resolve optimize-utilization-scheduler scheduling failures.
Example failure https://storage.googleapis.com/oss-prow-build-kpt-config-sync/logs/kpt-config-sync-autopilot-stable/2016983552020713472/build-log.txthttps://storage.googleapis.com/oss-prow-build-kpt-config-sync/logs/kpt-config-sync-autopilot-stable/2016983552020713472/build-log.txt