-
Notifications
You must be signed in to change notification settings - Fork 432
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
Add unit tests for raycluster_controller reconcilePods function #219
Merged
sriram-anyscale
merged 9 commits into
ray-project:master
from
Waynegates:brucez/reconcileUnitTest
Apr 5, 2022
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
82c90ee
Write raycluster_controller reconcilePods unit tests
86258fe
Improve unit tests code
Waynegates b0c6de8
Fix lint issue and Improve unit tests code
Waynegates 6e3db6c
Run goimports
Waynegates 37fb342
Fix a bug of workersToDelete update and update unit tests
Waynegates be89699
Fix a bug of workersToDelete update and update unit tests
Waynegates f34632e
Update unit tests log
Waynegates 84d5e09
Update workersToDelete local var to avoid unuseful kube api server de…
Waynegates 0138e28
Remove code of updating instance spec workersToDelete
Waynegates File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is a bug fix to clear the
instance.Spec.WorkerGroupSpecs[index].ScaleStrategy.WorkersToDelete
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.
Isn't that precisely what the line above is doing?
as per the outer for loop :)
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.
Actually no.
WorkerGroupSpecs []WorkerGroupSpec
is notWorkerGroupSpecs []*WorkerGroupSpec
. So updateworker
will not updateinstance.Spec.WorkerGroupSpecs[index]
.This is found by the unit tests. So
instance.Spec.WorkerGroupSpecs[index].ScaleStrategy.WorkersToDelete = []string{}
is needed.Check this for more info.
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.
Thanks for catching this bug.
Could you replace line 239 with:
then you would not require both lines 272 and 273
However, even after you do this, does the CR actually get updated? The only place I see this happening is within updateStatus() which has:
Doesn't this only update the Status and not the Spec? See https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/client#StatusClient
So how does this clear WorkersToDelete in the CR?
Separately (strictly speaking) the operator should not be changing the Spec, it should only update the Status given the declarative nature of the k8s programming style. But in this case I would say it is OK given that ScaleStrategy is not really declarative.
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.
Also would like to discuss the sync logic.
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.
Right now, this
has a conflict with
diff < 0
(line 310) branch code.