Skip to content
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

Merged

Conversation

harrison-tin
Copy link
Collaborator

@harrison-tin harrison-tin commented Nov 17, 2022

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:

  • this PR has an associated PR with documentation in akri-docs
  • this PR contains unit tests
  • added code adheres to standard Rust formatting (cargo fmt)
  • code builds properly (cargo build)
  • code is free of common mistakes (cargo clippy)
  • all Akri tests succeed (cargo test)
  • inline documentation builds (cargo doc)
  • all commits pass the DCO bot check by being signed off -- see the failing DCO check for instructions on how to retroactively sign commits

Copy link
Contributor

@kate-goldenring kate-goldenring left a 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 {
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

@kate-goldenring kate-goldenring left a 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]>
@adithyaj
Copy link
Collaborator

@harrison-tin I think with the latest merge there's a clippy error that popped up

@kate-goldenring
Copy link
Contributor

/version patch

@github-actions github-actions bot added the version/patch Patch version change is needed label Dec 6, 2022
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@kate-goldenring
Copy link
Contributor

@harrison-tin @adithyaj are we good to merge this?

@harrison-tin
Copy link
Collaborator Author

@harrison-tin @adithyaj are we good to merge this?

yep LGTM. I can go ahead and merge it.

@harrison-tin harrison-tin merged commit 6a2ba06 into project-akri:main Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version/patch Patch version change is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ListAndWatch should only send Devices when the list has changed
3 participants