-
Notifications
You must be signed in to change notification settings - Fork 150
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
ListAndWatch only sends device if the list has changed #540
ListAndWatch only sends device if the list has changed #540
Conversation
Signed-off-by: Harrison Tin <[email protected]>
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 looking into this!
dps.instance_map.lock().await.remove(&dps.instance_name); | ||
dps.server_ender_sender.clone().send(()).await.unwrap(); | ||
keep_looping = false; | ||
if prev_virtual_devices != virtual_devices { |
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 assumes that the discovery handler always returns the devices in the same order. For example, the following assertion fails:
let vec1 = vec![1,2,3];
let vec2 = vec![2,1,3];
assert!(vec1 == vec2);
You may consider using HashSets.
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.
Updated to use a simple looping to compare all virtual devices
Signed-off-by: Harrison Tin <[email protected]>
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 great! Thank you for this change that gets us more aligned with the device plugin interface specification of only sending updated device lists
Signed-off-by: Harrison Tin <[email protected]>
@harrison-tin I think with the latest merge there's a clippy error that popped up |
Signed-off-by: Harrison Tin <[email protected]>
/version patch |
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@harrison-tin @adithyaj are we good to merge this? |
yep LGTM. I can go ahead and merge it. |
Signed-off-by: Harrison Tin [email protected]
What this PR does / why we need it:
As suggested here, the change keeps a vector of previously returned virtual devices and only send updates to kubelet if the list has changed.
It closes #379
Special notes for your reviewer:
Test: passed all unit tests, and manually tested it with some debug messages.
If applicable:
cargo fmt
)cargo build
)cargo clippy
)cargo test
)cargo doc
)