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

feat(connlib): react to config updates #4322

Merged
merged 14 commits into from
Mar 28, 2024
Merged

feat(connlib): react to config updates #4322

merged 14 commits into from
Mar 28, 2024

Conversation

conectado
Copy link
Collaborator

@conectado conectado commented Mar 26, 2024

  • Move the resource changes to ClientState to unit test easier
  • Add unit tests
  • Set new config on update from portal
  • Set parameters as told by portal on re-init

Fixes: #2728

Copy link

vercel bot commented Mar 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
firezone ⬜️ Ignored (Inspect) Visit Preview Mar 28, 2024 1:04am

Copy link

github-actions bot commented Mar 26, 2024

Terraform Cloud Plan Output

Plan: 15 to add, 14 to change, 2 to destroy.

Terraform Cloud Plan

Copy link

github-actions bot commented Mar 26, 2024

Performance Test Results

TCP

Test Name Received/s Sent/s Retransmits
direct-tcp-client2server 223.7 MiB (-1%) 225.1 MiB (-1%) 260 (+31%)
direct-tcp-server2client 221.5 MiB (-6%) 222.9 MiB (-7%) 201 (+97%)
relayed-tcp-client2server 140.5 MiB (-9%) 141.1 MiB (-9%) 167 (+3%)
relayed-tcp-server2client 153.5 MiB (+2%) 153.9 MiB (+2%) 138 (-28%)

UDP

Test Name Total/s Jitter Lost
direct-udp-client2server 50.0 MiB (+0%) 0.30ms (+813%) 0.00% (NaN%)
direct-udp-server2client 50.0 MiB (-0%) 0.01ms (-45%) 0.00% (NaN%)
relayed-udp-client2server 50.0 MiB (-0%) 0.13ms (+87%) 0.00% (NaN%)
relayed-udp-server2client 50.0 MiB (+0%) 0.05ms (-13%) 0.00% (NaN%)

fn add_resources(&mut self, resources: &[ResourceDescription]) {
for resource_description in resources {
if let Some(resource) = self.resource_ids.get(&resource_description.id()) {
if resource.has_different_address(resource_description) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks god for unit tests

@conectado conectado marked this pull request as ready for review March 27, 2024 04:54
Copy link
Member

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you for adding all these tests!

I've left some comments on how I think we could cover more ground with them but that is not a blocker for merging.

rust/connlib/tunnel/src/client.rs Outdated Show resolved Hide resolved
rust/connlib/tunnel/src/client.rs Outdated Show resolved Hide resolved
rust/connlib/shared/src/messages.rs Outdated Show resolved Hide resolved
Comment on lines 1186 to 1303
let mut client_state = ClientState::for_test();
client_state.add_resources(&[cidr_resource("10.0.0.0/24"), dns_resource("baz.com")]);

assert_eq!(
HashSet::<&ResourceDescription>::from_iter(client_state.resources().iter()),
HashSet::from_iter([cidr_resource("10.0.0.0/24"), dns_resource("baz.com")].iter())
);
assert_eq!(
HashSet::<IpNetwork>::from_iter(client_state.routes()),
expected_routes(vec![IpNetwork::from_str("10.0.0.0/24").unwrap()])
);
Copy link
Member

Choose a reason for hiding this comment

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

I think "having routes for CIDR resources" should be a separate test.

Copy link
Collaborator Author

@conectado conectado Mar 27, 2024

Choose a reason for hiding this comment

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

I think for now, it's a good idea to leave them here until we have better tests for routes in general, we could repeat all tests with these assertions.

But for now, it's the only way we have to know that the internal state is consistent, it has caught some bugs.

rust/connlib/tunnel/src/client.rs Show resolved Hide resolved
rust/connlib/tunnel/src/client.rs Outdated Show resolved Hide resolved
rust/connlib/tunnel/src/client.rs Outdated Show resolved Hide resolved
rust/connlib/tunnel/src/client.rs Show resolved Hide resolved
rust/connlib/tunnel/src/client.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@ReactorScram ReactorScram left a comment

Choose a reason for hiding this comment

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

I skimmed through it

@conectado
Copy link
Collaborator Author

Tested the set_resources with all platforms:

  1. Disconnect from internet
  2. Modify resources
  3. Reconnect
  4. Changes are fully reflected after adding and removing

Right now there's a bug on the portal that prevents testing that the upstream dns are updated in real-time, there's a fix on the way, will merge after that is tested.

@conectado
Copy link
Collaborator Author

With fab9548 in I tested that the DNS updates works on all platforms

Merging :)

@conectado conectado added this pull request to the merge queue Mar 28, 2024
Merged via the queue into main with commit f879b43 Mar 28, 2024
152 checks passed
@conectado conectado deleted the feat/update-config branch March 28, 2024 01:42
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.

Handle DNS configuration change updates
3 participants