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
feat(connlib): report resource status to client #4931
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
Terraform Cloud Plan Output
|
Performance Test ResultsTCP
UDP
|
cc817de
to
1ddd420
Compare
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.
Can't comment on the Rust stuff but the rest LGTM. Do we currently send the Site name in the on_update_resources
list as well? If so I can start working on displaying that, along with the Resource offline/online status in #3514
} | ||
} | ||
|
||
/// What the GUI clients should paste to the clipboard, e.g. `https://github.com/firezone` |
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.
Just a quick note -- this will be updated to use the address_description in #3514
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 just copy-pasted though
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.
Great PR description, thank you for the summary. Left some comments!
} | ||
} | ||
|
||
fn resources(&self) -> Vec<ResourceDescription> { | ||
self.resource_ids.values().sorted().cloned().collect_vec() | ||
pub(crate) fn resources(&self) -> Vec<callbacks::ResourceDescription> { |
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.
I think this creates a weird coupling to the callbacks. What if we just make this a tuple for now instead of duplicating the type?
Long-term, I'd like connlib to have a proper domain model and not (ab)use the DTO types with the portal. The new ResourceDescription
is yet another DTO and not a proper domain model.
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.
If we use a tuple here, it means having to update all clients as part of this PR since it breaks de-serialization and I don't see much benefit of using a tuple here vs adding a field, which is easier to understand the meaning of specially for the de-serializing code.
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.
the resources
function is only used after all for the callbacks.
We could also return a tuple here and create the callbacks::ResourceDescription
on the top function but that just seems like a bit more convoluted that simply returning the callbacks::ResourceDescription
here.
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.
Looks okay other than the changes Thomas and I requested. I skimmed through the tests without looking at them in depth.
fn on_update_resources(&self, resources: Vec<ResourceDescription>) { | ||
tracing::info!(len = resources.len(), "New resource list"); | ||
fn on_update_resources(&self, resources: Vec<callbacks::ResourceDescription>) { | ||
tracing::info!(?resources, "New resource list"); |
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 can't be logged as INFO because it has domain names and IPs and stuff, right? That's why I only had the length before in some places in the Clients.
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.
I should have caught these too. We need to keep logs like this to debug because otherwise it'll just consume too much disk space for all users.
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.
maybe it's a bit too often but I don't think there's any sensitive info here. I think it's safe to log users' resources
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 will be called pretty often now, so I'll leave at debug
with only the length, otherwise I think it will be too spammy.
pub fn name(&self) -> &str { | ||
match self { | ||
ResourceDescription::Dns(r) => &r.name, | ||
ResourceDescription::Cidr(r) => &r.name, | ||
} | ||
} | ||
|
||
pub fn status(&self) -> Status { | ||
match self { | ||
ResourceDescription::Dns(r) => r.status, | ||
ResourceDescription::Cidr(r) => r.status, | ||
} | ||
} | ||
|
||
pub fn id(&self) -> ResourceId { | ||
match self { | ||
ResourceDescription::Dns(r) => r.id, | ||
ResourceDescription::Cidr(r) => r.id, | ||
} | ||
} |
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.
Hm we can't flip ResourceDescription into a struct that shares these fields, because it would break compatibility with older code, right? Or if this type of ResourceDescription
is only used within the Client, between connlib and the GUI, it could be done?
e.g.
struct ResourceDescription {
id: ResourceId,
name: String,
status: Status,
other: ResourceType,
}
enum ResourceType {
Cidr,
Dns,
}
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.
address
is also part of a ResourceDescription
and it has a different type depending on whether it's DNS or CIDR
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.
But the other ones look like they have the same type, since there's no into
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.
yeah, but some clients uses the address
, maybe we can convert it to a String
but I'm not sure having a single type will simplify things, specially since these are used only for serialization and we don't need to access the fields.
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.
LGTM
This PR introduces site's `Status`. That's used to report to the client the status, either, unknown, online or offline, mostly as a hint to users as what's wrong with a connection. This are the criteria for an online or offline resource * If all sites related to a resource are offline the resource is considered offline, since there's no gateway that can respond to that resource's connection * If any site is online the resource is online, since that same peer can be used to reach that resource * Any other case is unknown Right now resources are single site so it doesn't matter too much but tracking online/offline per-site instead of per-gateway or resource seems like the better long-term solution. The way to "find out" the site's status is: * If a response to a connection details is offline, all sites related to that resource must be offline otherwise there would've been a gateway in the response * At the point we connect to a gateway, the site that corresponds to that gateway must be online * When a connection to a peer stops it's considered unknown again Fixes #4738
This PR introduces site's
Status
. That's used to report to the client the status, either, unknown, online or offline, mostly as a hint to users as what's wrong with a connection.This are the criteria for an online or offline resource
Right now resources are single site so it doesn't matter too much but tracking online/offline per-site instead of per-gateway or resource seems like the better long-term solution.
The way to "find out" the site's status is:
Fixes #4738