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

Yield more information about services to client #30

Merged
merged 10 commits into from
Dec 20, 2024

Conversation

avnik
Copy link
Contributor

@avnik avnik commented Nov 14, 2024

Description

Yield more information about services to client

Checklist

  • Summary of the proposed changes in the PR description
  • More detailed description in the commit message(s)
  • Commits are squashed into relevant entities - avoid a lot of minimal dev time commits in the PR
  • Contribution guidelines followed
  • Test procedure added to nixos/tests
  • Author has run nix flake check --accept-flake-config and it passes
  • All automatic Github Action checks pass - see actions
  • Author has added reviewers and removed PR draft status

Testing

@avnik avnik marked this pull request as draft November 14, 2024 11:51
Signed-off-by: Alexander V. Nikolaev <[email protected]>
Signed-off-by: Alexander V. Nikolaev <[email protected]>
Signed-off-by: Alexander V. Nikolaev <[email protected]>
Signed-off-by: Alexander V. Nikolaev <[email protected]>
Signed-off-by: Alexander V. Nikolaev <[email protected]>
Signed-off-by: Alexander V. Nikolaev <[email protected]>
Signed-off-by: Alexander V. Nikolaev <[email protected]>
@avnik avnik requested review from slakkala and mbssrc December 18, 2024 17:00
@avnik avnik marked this pull request as ready for review December 18, 2024 17:03
Copy link
Contributor

@slakkala slakkala left a comment

Choose a reason for hiding this comment

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

The changes seem reasonable; added some stylistic comments.

pub fn vm_name(&self) -> Option<&str> {
match &self.placement {
Placement::Endpoint { vm, .. } => Some(vm),
Placement::Managed { vm, .. } => Some(vm),
Copy link
Contributor

Choose a reason for hiding this comment

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

These branches could be combined with |, either way is fine though.

@@ -103,11 +129,17 @@ impl From<RegistryEntry> for QueryResult {
} else {
VMStatus::PoweredOff
};
let vm_name = val.vm_name().map(|s| s.to_owned());
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use ToOwned::to_owned or str::to_owned instead of closure.

@@ -51,6 +56,12 @@ impl TryFrom<pb::QueryListItem> for QueryResult {
.with_context(|| format!("While parsing vm_status {}", item.vm_status))?,
trust_level: TrustLevel::from_str(item.trust_level.as_str())
.with_context(|| format!("While parsing trust_level {}", item.trust_level))?,
vm_type: VmType::from_str(item.vm_type.as_str())
Copy link
Contributor

Choose a reason for hiding this comment

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

I think item.vm_type.parse().with_context(...) would be more readable.

.await
.with_context(|| format!("handing error, by restart VM {}", entry.name))?;
if let Placement::Managed { vm: vm_name, .. } = entry.placement {
self.start_vm(&vm_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it makes a difference, but could move the & to above: &entry.placement to ensure no move occurs.

Placement::Managed(within) if within == name => Some(re.name.clone()),
_ => None,
.filter_map(|re| {
if re.agent_name() == Some(name) || re.vm_name() == Some(name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe (re.agent_name() == Some(name) || re.vm_name() == Some(name)).then(|| re.name.clone())

Tried to make it a one-liner, but the shortest I got was: .filter_map(|e| [e.agent_name(), e.vm_name()].contains(&Some(name)).then(|| e.name.clone())) which rustfmt still splits onto multiple lines :(

Signed-off-by: Alexander V. Nikolaev <[email protected]>
@mbssrc mbssrc merged commit e0f702c into tiiuae:main Dec 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants