-
Notifications
You must be signed in to change notification settings - Fork 427
feat: Support passing node selectors and tolerations to hypershift install cmd #7404
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
|
Skipping CI for Draft Pull Request. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Review skipped — only excluded labels are configured. (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes add operator tolerations and node selectors support to HyperShift deployments. New public fields are introduced to the Options and HyperShiftOperatorDeployment structs, validation logic is implemented, a toleration parsing utility function is added, and test coverage is extended across multiple test files. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ashishmax31 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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
cmd/util/util.go (1)
46-86: Consider extracting duplicate key/value parsing logic.The key=value parsing logic is duplicated in both the 2-part and 3-part branches (lines 53-61 and 68-76). While the current implementation works correctly, extracting this into a helper function would improve maintainability.
Example refactor:
+func parseTolerationKeyValue(part string) (key, value string, operator corev1.TolerationOperator) { + if strings.Contains(part, "=") { + kv := strings.SplitN(part, "=", 2) + return kv[0], kv[1], corev1.TolerationOpEqual + } + return part, "", corev1.TolerationOpExists +} + func ParseTolerationString(s string) corev1.Toleration { toleration := corev1.Toleration{} parts := strings.Split(s, ":") // No toleration seconds if len(parts) == 2 { - if strings.Contains(parts[0], "=") { - kv := strings.SplitN(parts[0], "=", 2) - toleration.Key = kv[0] - toleration.Value = kv[1] - toleration.Operator = corev1.TolerationOpEqual - } else { - toleration.Key = parts[0] - toleration.Operator = corev1.TolerationOpExists - } + toleration.Key, toleration.Value, toleration.Operator = parseTolerationKeyValue(parts[0]) toleration.Effect = corev1.TaintEffect(parts[1]) } // With toleration seconds if len(parts) == 3 { - if strings.Contains(parts[0], "=") { - kv := strings.SplitN(parts[0], "=", 2) - toleration.Key = kv[0] - toleration.Value = kv[1] - toleration.Operator = corev1.TolerationOpEqual - } else { - toleration.Key = parts[0] - toleration.Operator = corev1.TolerationOpExists - } + toleration.Key, toleration.Value, toleration.Operator = parseTolerationKeyValue(parts[0]) toleration.Effect = corev1.TaintEffect(parts[1]) tolerationSeconds, _ := strconv.ParseInt(parts[2], 10, 64) if tolerationSeconds > 0 { toleration.TolerationSeconds = &tolerationSeconds } } return toleration }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (5)
cmd/install/assets/hypershift_operator.go(4 hunks)cmd/install/assets/hypershift_operator_test.go(3 hunks)cmd/install/install.go(7 hunks)cmd/install/install_test.go(1 hunks)cmd/util/util.go(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
cmd/util/util.gocmd/install/install.gocmd/install/install_test.gocmd/install/assets/hypershift_operator_test.gocmd/install/assets/hypershift_operator.go
🧬 Code graph analysis (3)
cmd/install/install_test.go (2)
cmd/install/install.go (1)
Options(79-139)api/hypershift/v1beta1/hostedcluster_types.go (1)
NonePlatform(1215-1215)
cmd/install/assets/hypershift_operator_test.go (2)
cmd/install/assets/hypershift_operator.go (1)
HyperShiftOperatorDeployment(386-427)api/hypershift/v1beta1/hostedcluster_types.go (1)
NonePlatform(1215-1215)
cmd/install/assets/hypershift_operator.go (1)
cmd/util/util.go (1)
ParseTolerationString(47-86)
🪛 golangci-lint (2.5.0)
cmd/install/install.go
[error] 228-228: : # github.com/openshift/hypershift/sync-global-pullsecret [github.com/openshift/hypershift/sync-global-pullsecret.test]
sync-global-pullsecret/sync-global-pullsecret_test.go:228:23: undefined: MockdbusConn
sync-global-pullsecret/sync-global-pullsecret_test.go:234:26: undefined: MockdbusConn
sync-global-pullsecret/sync-global-pullsecret_test.go:247:26: undefined: MockdbusConn
sync-global-pullsecret/sync-global-pullsecret_test.go:257:26: undefined: MockdbusConn
sync-global-pullsecret/sync-global-pullsecret_test.go:270:26: undefined: MockdbusConn
sync-global-pullsecret/sync-global-pullsecret_test.go:283:26: undefined: MockdbusConn
sync-global-pullsecret/sync-global-pullsecret_test.go:296:26: undefined: MockdbusConn
sync-global-pullsecret/sync-global-pullsecret_test.go:309:26: undefined: MockdbusConn
sync-global-pullsecret/sync-global-pullsecret_test.go:327:12: undefined: NewMockdbusConn
(typecheck)
🔇 Additional comments (11)
cmd/install/install_test.go (1)
143-185: LGTM! Comprehensive test coverage for tolerations and node selectors.The test cases effectively cover validation scenarios for both valid and invalid operator tolerations and node selectors, including edge cases like mixed valid/invalid tolerations and malformed keys.
cmd/install/assets/hypershift_operator_test.go (2)
437-483: LGTM! Well-structured test case for tolerations and node selectors.The test case effectively validates both toleration formats (with and without values, with TolerationSeconds) and node selector application on the deployment.
493-498: LGTM! Proper conditional assertions.The conditional checks ensure tolerations and node selectors are only validated when explicitly provided in test cases, preventing false positives.
cmd/install/assets/hypershift_operator.go (3)
406-407: LGTM! Appropriate field types for tolerations and node selectors.The field types align well with the CLI input format and downstream usage.
617-628: LGTM! Proper parsing and filtering of tolerations and node selectors.The implementation correctly:
- Parses toleration strings using the utility function
- Filters out empty tolerations
- Preserves non-empty keys from node selectors (empty values are valid)
841-847: LGTM! Correct application of tolerations and node selectors to deployment.The conditional application ensures these fields are only set when values are provided, maintaining clean deployment specs.
cmd/install/install.go (5)
254-287: LGTM! Comprehensive toleration string validation.The validation correctly handles both toleration formats and provides clear error messages for each failure mode.
289-351: LGTM! Thorough validation helper functions.The helper functions correctly validate each component of the toleration string using appropriate Kubernetes validators and provide clear error messages.
427-428: LGTM! Appropriate CLI flags for tolerations and node selectors.The flags use correct types (StringSliceVar and StringToStringVar) and provide clear descriptions with format examples.
500-501: LGTM! Correct default initialization.Initializing as empty slice and map ensures proper handling when flags are not provided.
974-975: LGTM! Fields correctly propagated to deployment.The operator tolerations and node selectors are properly passed through to the HyperShiftOperatorDeployment builder.
…stall cmd Signed-off-by: Ashish <[email protected]>
d926516 to
af57705
Compare
|
@muraee Ptal, i've addressed your review comments. |
|
PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What this PR does / why we need it:
Allow passing node selectors and tolerations to hypershift install cmd so that we can influence the placement of the HO pods.
Fixes
https://issues.redhat.com/browse/ARO-23223
Special notes for your reviewer:
Checklist: