-
Notifications
You must be signed in to change notification settings - Fork 415
OCPBUGS-62445: prevent crash when rootDeviceHints format is invalid #2109
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
Conversation
@mhanss: This pull request references Jira Issue OCPBUGS-62445, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
Instructions 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 openshift-eng/jira-lifecycle-plugin repository. |
WalkthroughAdds input validation for the rootDeviceHints flag in the single-node path and introduces a corresponding negative test to ensure malformed values (not in key:value format) produce an error. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
Comment |
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)
pkg/cli/admin/nodeimage/create.go (1)
636-640
: Consider validating that both key and value are non-empty.The current validation correctly checks for the presence of the ":" separator, but it doesn't prevent edge cases like:
":"
→ empty key and value":value"
→ empty key"key:"
→ empty valueThese would pass validation but create malformed rootDeviceHints entries.
Consider adding validation to ensure both parts are non-empty:
if o.SingleNodeOpts.RootDeviceHints != "" { parts := strings.SplitN(o.SingleNodeOpts.RootDeviceHints, ":", 2) if len(parts) != 2 { return nil, fmt.Errorf("incorrect rootDeviceHints format provided: %s. Expected format: <hint name>:<value>, for example: deviceName:/dev/sda", o.SingleNodeOpts.RootDeviceHints) } + if strings.TrimSpace(parts[0]) == "" || strings.TrimSpace(parts[1]) == "" { + return nil, fmt.Errorf("incorrect rootDeviceHints format provided: %s. Both hint name and value must be non-empty", o.SingleNodeOpts.RootDeviceHints) + } host["rootDeviceHints"] = map[string]interface{}{ parts[0]: parts[1], } }
📜 Review details
Configuration used: CodeRabbit 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 (2)
pkg/cli/admin/nodeimage/create.go
(1 hunks)pkg/cli/admin/nodeimage/create_test.go
(1 hunks)
🔇 Additional comments (1)
pkg/cli/admin/nodeimage/create_test.go (1)
665-671
: LGTM! Test case correctly validates the error path.The test case appropriately validates that an invalid rootDeviceHints format (missing the ":" separator) produces the expected error message. The test is well-isolated, only populating the RootDeviceHints field to ensure it specifically tests the format validation.
} | ||
if o.SingleNodeOpts.RootDeviceHints != "" { | ||
parts := strings.SplitN(o.SingleNodeOpts.RootDeviceHints, ":", 2) | ||
if len(parts) != 2 { |
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.
In general we don't want to duplicate the node-joiner logic here, since the oc command must be as much as possible a simple wrapper. So, if there is an issue it must be fixed on the node-joiner side, and reuse the already existing workflow for reporting back the error to the user
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.
The format of the CLI arg is effectively already defined here (on the previous line) isn't it? And node-joiner uses a different format (proper yaml).
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.
That's perfectly right, I misread the original issue, this is an oc
interface and not related to node-joiner
/approve
/verified bypass |
@mhanss: This pull request references Jira Issue OCPBUGS-62445, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions 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 openshift-eng/jira-lifecycle-plugin repository. |
@openshift-ci-robot: GitHub didn't allow me to request PR reviews from the following users: mhanss. Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions 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. |
/retest |
/test e2e-aws-ovn-serial-2of2 |
/verified bypass |
@mhanss: The In response to this:
Instructions 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 openshift-eng/jira-lifecycle-plugin repository. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andfasano, bmanzari, mhanss The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@mhanss: The following test failed, say
Full PR test history. Your PR dashboard. Instructions 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. I understand the commands that are listed here. |
229ead6
into
openshift:main
@mhanss: Jira Issue Verification Checks: Jira Issue OCPBUGS-62445 Jira Issue OCPBUGS-62445 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓 In response to this:
Instructions 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 openshift-eng/jira-lifecycle-plugin repository. |
Fix included in accepted release 4.21.0-0.nightly-2025-10-07-102242 |
This PR adds validation for the --root-device-hint flag in the Create Node Image command.
Previously, providing an invalid format would cause the command to crash with a stack trace.