fix: ensureNodePlugins does not work
Reason for Change:
resources.CheckNvidiaPlugin(ctx, nodeObj) checked nodeObj, which is a cached value. Retry is no use.
Another problem is that return nil in default condition will always be executed no matter found or not found. I think this is not what we want. This fix assume that we only return nil when found.
Requirements
- [ ] added unit tests and e2e tests (if applicable).
Issue Fixed:
Notes for Reviewers:
Title
(Describe updated until commit https://github.com/kaito-project/kaito/commit/219228de68d29f84d61007b7eeb10a5c5ec9c524)
Fix node plugin installation and add tests
Description
-
Ensure fresh node object retrieval in
ensureNodePlugins -
Correct logic for Nvidia plugin check and label update
-
Add unit tests for
UpdateNodeWithLabelandensureNodePlugins
Changes walkthrough 📝
| Relevant files | |||||||
|---|---|---|---|---|---|---|---|
| Bug fix |
| ||||||
| Tests |
| ||||||
| Enhancement |
|
Need help?
Type /help how to ...in the comments thread for any questions about PR-Agent usage.Check out the documentation for more information.
PR Reviewer Guide 🔍
(Review updated until commit https://github.com/kaito-project/kaito/commit/219228de68d29f84d61007b7eeb10a5c5ec9c524)
Here are some key observations to aid the review process:
| ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪ |
| 🧪 No relevant tests |
| 🔒 No security concerns identified |
⚡ Recommended focus areas for reviewPossible Issue
return nil statement inside the default case will now always return nil if the Nvidia plugin is found, which might not be the intended behavior. The original code returned nil only if the Nvidia plugin was not found. |
PR Code Suggestions ✨
Latest suggestions up to 219228d
Explore these optional code suggestions:
| Category | Suggestion | Impact |
| General |
Simplify label checkRemove unnecessary nested if statement for checking Nvidia label value. pkg/utils/resources/nodes.go [53-55]
Suggestion importance[1-10]: 8__ Why: The suggestion removes unnecessary nesting, making the code cleaner and easier to read without changing the functionality. | Medium |
Remove obsolete testRemove redundant test case as the function no longer retrieves the node within pkg/utils/resources/nodes_test.go [25-30]
Suggestion importance[1-10]: 8__ Why: The test case is indeed obsolete since the function no longer retrieves the node within | Medium |
Previous suggestions
Suggestions up to commit 6b4fe1f
| Category | Suggestion | Impact |
| General |
Simplify label checkRemove unnecessary label value check. pkg/utils/resources/nodes.go [53-55]
Suggestion importance[1-10]: 6__ Why: The suggestion simplifies the label check by removing the unnecessary value comparison, which improves code readability and maintainability without changing the functionality. | Low |
Suggestions up to commit 537b325
| Category | Suggestion | Impact |
| General |
Simplify label checkRemove unnecessary label value check. pkg/utils/resources/nodes.go [53-55]
Suggestion importance[1-10]: 6__ Why: The suggestion simplifies the label check by removing the unnecessary value comparison. This improves the code's readability and maintainability without affecting its functionality. | Low |
Suggestions up to commit 5f9a5d0
| Category | Suggestion | Impact |
| Possible issue |
Fix Nvidia plugin installation logicCorrect logic to install Nvidia plugin if not found. pkg/workspace/controllers/workspace_controller.go [511-513]
Suggestion importance[1-10]: 8__ Why: The suggestion corrects the logic to ensure the Nvidia plugin is installed only if not found, addressing a potential bug in the original code. | Medium |
| General |
Simplify Nvidia label checkRemove unnecessary check for Nvidia label value. pkg/utils/resources/nodes.go [56-59]
Suggestion importance[1-10]: 5__ Why: The suggestion simplifies the check by removing the unnecessary comparison, which improves readability but has minimal functional impact. | Low |
Suggestions up to commit 703d9bd
| Category | Suggestion | Impact |
| Possible issue |
Fix Nvidia plugin check logicCorrect logic to update label if Nvidia plugin is not found. pkg/workspace/controllers/workspace_controller.go [511-513]
Suggestion importance[1-10]: 8__ Why: The suggestion corrects the logic to update the label if the Nvidia plugin is not found, addressing a potential bug in the original code. | Medium |
| General |
Simplify Nvidia label checkRemove unnecessary check for Nvidia label value. pkg/utils/resources/nodes.go [56-59]
Suggestion importance[1-10]: 5__ Why: The suggestion removes an unnecessary check for the Nvidia label value, which simplifies the code but does not address any critical issue. | Low |
Improve error loggingLog error details instead of generic message. pkg/workspace/controllers/workspace_controller.go [525]
Suggestion importance[1-10]: 3__ Why: The suggestion improves error logging by using | Low |
If we add node informer(https://github.com/kaito-project/kaito/pull/1052), resources.GetNode will get node from cache rather than apiserver. But this fix should still work, because node informer will make sure the cache always sync with apiserver.
@cvvz I agree with you, we need to get fresh node before checking nvidia plugin. btw: please fix go lint errors and unit tests errors.