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

Fix broker properties not getting updated on Configuration change #711

Merged

Conversation

diconico07
Copy link
Contributor

What this PR does / why we need it:
Move the moment we move to cdi::Kind abstraction so that updates to broker properties can be reflected here.

On Configuration reconciliation if request already exists, update broker properties

Fix #705

Special notes for your reviewer:

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

Move the cdi::Kind abstraction so that updates to broker properties can
be reflected here.

On Configuration reconciliation if request already exists, update broker
properties

Fix project-akri#705

Signed-off-by: Nicolas Belouin <[email protected]>
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.

LGTM -- just one clarifying question

fn device_to_instance(
&self,
dev: &DiscoveredDevice,
extra_device_properties: &HashMap<String, String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you passing in properties instead of reading them from self.extra_device_properties?

impl DiscoveryHandlerRequest for DHRequestImpl {
fn get_instances(&self) -> Result<Vec<Instance>, DiscoveryError> {
async fn get_instances(&self) -> Result<Vec<Instance>, DiscoveryError> {
let properties = self.extra_device_properties.read().await;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same point here: could this skipped and instead let the called function (device_to_instance) access the properties? Or is the concern wanting to avoid too many reads? It is RWLock, so reads should be cheaper. I could also see how your strategy is trying to avoid a racecase where some containers have properties that were written after the initial call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acquiring the lock is an async operation, you cannot do this from within the map call (same reason for not doing it in device_to_instance).
But in the end I find it better anyway, as it means we have a consistent set of properties for the entire run

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

device_to_instance could be made async but i am aligned on wanting the consistent set of properties

@kate-goldenring
Copy link
Contributor

/version patch

@github-actions github-actions bot added the version/patch Patch version change is needed label Nov 1, 2024
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@diconico07 diconico07 merged commit f12e5a2 into project-akri:main Nov 4, 2024
3 checks passed
@diconico07 diconico07 deleted the fix-broker-properties-update branch November 4, 2024 08:42
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.

Akri Agent is not recreating instances upon configuration updates
2 participants