Commit Graph

175 Commits

Author SHA1 Message Date
Jamil
3bd7dc504e fix(ci): Fix flaky iperf3 "Bad file descriptor" (#3731)
- Lower UDP bandwidth to 50M -- this fixes intermittent file descriptor
issues because we overload iperf3 for more than 5 seconds
- Simplify iperf3 to the minimum set that makes tests reliable
2024-02-22 19:57:22 +00:00
Jamil
5bd717b877 fix(ci): Use workflow id to fetch perf results (#3710) 2024-02-20 19:40:16 -08:00
Jamil
63cdd09a01 refactor(ci): Merge perf results into one comment (#3707)
One comment vs eight, need I say more?
2024-02-20 18:17:48 -08:00
Jamil
19a7bac4ae chore(ci): enforce shellscript formatting and style (#3679)
Noticed that we all have different styles of writing scripts :-).

This PR adds linting to our shell scripts to standardize on formatting,
catch common issues and/or possible security bugs.

For editor setup:
- Ensure [`shellcheck`](https://github.com/koalaman/shellcheck) and
[`shfmt`](https://github.com/mvdan/sh) are in your `PATH`
- Configure `shfmt` with indentation of `4`, otherwise it uses tabs by
default.
[Here](https://github.com/jamilbk/nvim/blob/master/init.vim#L159) is how
you can do that with Vim and
[here](https://marketplace.visualstudio.com/items?itemName=mkhl.shfmt)
is how for VScode.

---------

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Brian Manifold <bmanifold@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Dryga <andrew@dryga.com>
Co-authored-by: Gabi <gabrielalejandro7@gmail.com>
2024-02-21 01:01:32 +00:00
Jamil
2d208b1991 fix(ci): Fix js typo (#3704)
More fixes from the perf test refactor
2024-02-20 16:38:05 -08:00
Jamil
0598ca55c3 fix(ci): Fix result overwrite (#3700)
Buttoning up fixes from #3695
2024-02-20 15:46:59 -08:00
Jamil
7ff40b82ed fix(ci): Run each perf test in its own matrix job (#3695)
The iperf3 server sometimes hangs, or takes a while to startup.

Rather than trying to reset the iperf3 state between performance tests,
this PR refactors them so they each run in their matrix job. This
ensures each performance test will run on a separate VM, unaffected by
previous test runs to eliminate the effect any residual network buffer
state can have on a particular test.

It also makes sure the server is listening with a `healthcheck`.
2024-02-20 22:44:20 +00:00
Gabi
3d3e737ba3 refactor(connlib): replace webrtc-rs with snownet (#3391)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>

Resolves: #3377.

---------

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-02-20 06:56:31 +00:00
Jamil
eebd7fc7f1 fix(ci): Ensure integration-tests allow for at least 30 seconds to establish a connection (#3676)
So the cause of the flaky tests is that they aren't waiting long enough
for a connection to be established. Both the test in #3666 and the
`iperf` tests have a timeout of 10 seconds.

Connections _should_ be established **very quickly** in CI. However, I
have a few guesses as to why they might not be, essentially causing us
to have to wait for a timeout to re-initiate a connection request:

- Packets arrive out of order or too quickly for the WireGuard state
machine to establish a handshake.
- Too many ICE candidates gathered (the gateway has 3 interfaces)


This PR:

- Refactors the iperf tests to be a little easier to maintain
- Ensures `integration-tests` run for at least 30 seconds before timing
out


In any case, we can debug / optimize this further after snownet is
merged, which might just solve the problem completely.
2024-02-19 20:50:58 +00:00
Andrew Dryga
4dc8cdf908 Revert "fix(gateway): Remove /dev/net/tun requirement and clean up upgrade script (#3691)
This reverts PR #3392.
This reverts commit 16f5401a73.
2024-02-19 20:03:14 +00:00
Reactor Scram
87f843dcfb ci: document and fix a couple things for local Docker testing (#3672)
Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2024-02-17 16:16:39 +00:00
Jamil
20dc0cf1e9 refactor(ci): Use curl for connectivity tests in CI (#3674)
It would be good to run tests with a TCP protocol like `http` to catch
things like MTU and port issues.
2024-02-16 22:48:13 +00:00
Reactor Scram
46228a1e62 feat(linux): Control DNS with systemd-resolved (#3643)
If `FIREZONE_DNS_CONTROL` is set to `systemd-resolved`, then shell out
to `resolvectl` to request all system DNS queries to go to Firezone's
sentinel DNS server(s).

```[tasklist]
- [ ] Figure out how to stop the runner from using the Docker bridge iface
```

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-02-16 17:17:02 +00:00
Jamil
9054f70995 refactor(ci): simplify dns resources in ci (#3653)
Attempt at cleaning a couple things I missed in code review.

The old httpbin resource wasn't being used anyhow, so I just deduped
them and updated things in a couple other places that had drifted.

Hopefully this fixes the [flaky
CI](https://github.com/firezone/firezone/actions/runs/7918422653/job/21616835910)
2024-02-15 23:50:12 +00:00
Reactor Scram
0fbd40fcb2 feat(linux): Notify systemd when we've started (#3628)
Regardless of `FIREZONE_DNS_CONTROL`, always try to notify systemd that
we've started.

I had accidentally conflated the idea of running as a systemd service
with the idea of using systemd to control DNS. They're separate, but
I'll keep the service unit in here and always use `sd-notify` since it
should be harmless to use even in Alpine.

~~If `FIREZONE_DNS_CONTROL` is `systemd-resolved`, try to notify systemd
that we've finished startup and the tunnel is ready.~~

Also adds a CI test, including a systemd service file that is **not**
ready for general use.
Ready for review once it's green.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-02-15 20:12:37 +00:00
Reactor Scram
00f6fcdd09 feat(linux): If FIREZONE_DNS_CONTROL is etc-resolv-conf, modify '/etc/resolv.conf' (#3639)
Only user-facing if users are using the Docker image for the Linux
client.

I split off a module for `/etc/resolv.conf` since the code and unit
tests are about 300 lines and aren't related to the rest of the
`tun_linux.rs` code.

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-02-14 23:50:01 +00:00
Thomas Eizinger
e47c1766bf ci: move tests to bash scripts (#3648)
This improves maintenance because we can now use a regular matrix for
the integration tests and one can locally use tools like shellcheck or a
`bash-lsp` during development.

---------

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2024-02-14 13:55:28 +00:00
Reactor Scram
b42f623ad6 ci(linux): add CI setup script for NetworkManager (#3641)
No user-facing changes. Just making sure I can install NM in the runner.
2024-02-14 02:54:42 +00:00
Jamil
16f5401a73 fix(gateway): Remove /dev/net/tun requirement and clean up upgrade script (#3392)
* Clean up gateway upgrade script
* Fixes #3226 to remove another place where things can go wrong when
upgrading gateways
2024-01-29 04:19:59 +00:00
Jamil
eeaa65812e fix(gateway): Use new prod Docker registry for upgrades (#3386) 2024-01-24 10:48:18 -08:00
Jamil
3c2b32c215 revert(devops): Revert healthcommands (#3280) 2024-01-17 03:35:45 -08:00
Jamil
36209c7d2d fix(rust): Check /proc for health checks (#3250)
Debian slim is slimmer than we could ever have imagined.
2024-01-16 16:46:44 +00:00
Jamil
34ab093dbc security(gateway): Don't run systemd gateways as root (#2943)
Docker-based gateways won't have working IPv6 (good point @AndrewDryga),
so I started testing the systemd gateways more and found some issues I
fixed.

* Update default tab order for Deploy gateways page to prefer systemd
* Update unit file to run gateway as unprivileged user
* Remove dependency on `wget` in unit file
* Fix iptables logic so rules as re-created on reboot
* Use `/var/lib/firezone` instead of `/etc/firezone` for writing runtime
files (`/etc/` is often mounted read-only on hardened systems)

---------

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
Co-authored-by: Andrew Dryga <andrew@dryga.com>
2023-12-21 18:29:10 +00:00
Jamil
54e2258264 Gateway upgrade docs (#2914)
Realized we need a small script to upgrade Docker-based gateways
reliably.
2023-12-14 21:20:30 -08:00
Andrew Dryga
37a2d7b7f5 Move elixir code to a subfolder (#1631) 2023-05-24 15:46:51 -06:00
Andrew Dryga
6a9012c964 Remove omnibus install scripts 2023-04-04 09:53:21 -06:00
Andrew Dryga
6eba82499a Use DEFAULT_ADMIN_EMAIL everywhere to prevent legacy key usage warnings on fresh installs (#1509) 2023-03-13 14:33:53 -07:00
Jamil
49d4040b60 Add version tag to migrate script (#1400)
* Add new `VERSION` to `docker_migrate.sh` script
* Add missing `SAML_KEYFILE_PATH` and `SAML_CERTFILE_PATH` env vars to
migrate script
* Add missing `PHOENIX_PORT` var
* Bump Elixir to 1.14.3
* Bump Erlang to 25.2.1
* Update docs to document new VERSION var in docker-compose.yml upgrade
mechanism

Fixes #1395
2023-02-01 19:38:55 -08:00
Andrew Dryga
8033d618c1 Expose phoenix and Wireguard ports specified in configuration (#1372) 2023-02-01 16:23:46 -08:00
Jamil
e4854902cd Revert to old Project API key (#1379)
Also update ping event timer to 1 day, with a 1 minute delay on boot.

Waiting on PostHog to confirm old API key is set.
2023-01-26 12:49:11 -08:00
Jamil
394008c008 Chore/update project api key (#1348)
Refs firezone/marketing#109
2023-01-19 19:46:01 -08:00
Jamil
3514bbfce4 Omit ownership statements from Postgres DB dump (#1334)
Fixes #1302
2023-01-18 11:54:58 -08:00
Jamil
bff52590e1 Migrate DB before using for the first time (#1310) 2023-01-13 17:43:44 -08:00
Jamil
5320596cec Add missing env var (#1309)
Makes the telem vars more robust
2023-01-13 17:30:09 -08:00
Jamil
330cafbbe5 Boot minimal app for DB changes (#1305)
Adds a minimal supervision tree for making DB changes from the
`FzHttp.Release` module. This allows the `bin/create-or-reset-admin` and
`bin/create-api-token` commands to be with `docker compose exec` or
`docker compose run --rm` indiscriminately.

Starting the FzHttp.Repo directly is more involved it's not compiled
into the release as an OTP app.
2023-01-13 13:45:18 -08:00
Jamil
ed23d9f346 Use eval for create-or-reset-admin; expose with RESET_ADMIN_ON_BOOT (#1287)
Fixes #1285
2023-01-11 19:55:18 -08:00
Jamil
1de24ff77e REST API (#1155)
### TODO

- [x] "/v0"
- [x] Double-check migration order; re-timestamp if necessary
- [x] Move `sites` fields to `configurations` so they can be updated
from API
- [x] #1240 -- it introduces possible race conditions for API requests
- [x] #1249 
- [ ] #1008 
- [ ] Final review

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
Co-authored-by: Andrew Dryga <andrew@dryga.com>
2022-12-31 12:58:11 -06:00
Jamil
de3919fb69 Add SupportOptions component and utm_source for links (#1219)
This PR also moves to `yarn` for docs package management for improved
speed, security, and developer experience. Docusaurus prefers yarn.

Refs firezone/marketing#126
2022-12-24 16:16:55 -06:00
Jamil
3a2c03d98f Use $tid
Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
2022-12-20 22:27:43 -06:00
Jamil
7e34b0fc71 Fix install script param
Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
2022-12-20 22:24:48 -06:00
Jamil
25e7de4f24 Enrichment (#1220)
* Debug TID

* Use new TID from wrapped install script

* Add as script param
2022-12-20 22:20:30 -06:00
Jamil
1cbd96be6d Fix double-quotes in docker migrate
Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
2022-12-11 14:09:28 -08:00
Andrew Dryga
28fe571543 Small improvements to make setup process easier for OS contributors (#1171)
* Remove _build folders for umbrella apps

For umbrella apps everything goes into /_build directory so there no need to ignore directories that should never be created

* Change mix aliases to be more aligned with what OS community would expect

1. We want ecto.create and ecto.migrate to be run on each tests, this will simplify setup steps (no need to run migrations manually)

2. ecto.remigrate is not needed because now you can just run ecto.drop and on tests migrations would be executed anyways.

* Rename docker-compose step name in CONTRIBUTING.md

The step was renamed here: dd67baf629 (diff-67a4805fdcc6145d7b3ada2a6099a9b2e91c9d0fd108c22f95d2f01d219793d1R10)

* Remove .devcontainer

This an is opinionated change. Right now devcontainer doesn't work but should be easy to fix (with renaming step name), but at the same time it forces developers that use VS code to have unified development environment (including plugins for the editor itself).

I feel like it's not a good path to go for OS and for small team - everyone should be allowed to use setup they like. Especially for people like me that tend to recompile ls-elixir for Elixir plugin from master branch.

Plus it's yet another thing to maintain while nobody on the team is using it, which means it will be always causing issues.

* Make fz_http mix.exs aliases aligned with umbrella app ones

* Redirect stderr to stdout in a command called from dev.exs

Otherwise I'm getting this on my MacOS (that has a `route` implementation that doesn't show interfaces) when `mix phx.server` is executed:
```
usage: route [-dnqtv] command [[modifiers] args]
```

* Fix race condition due to static device field values

Both public_key and name are unique and we should not use static values for field covered by unique index, otherwise deadlocks and slow tests are expected.

* Remove unwanted transaction block

The changeset code doesn't have any code that accesses the database and individual Ecto.SQL commands are already wrapped in transactions by default, so there is no need to start it manually and hold for longer than expected (while irrelevant Elixir code is running).

* Use netstat to identify egress interface on MacOS

* Rename uninstall.sh to omnibus-uninstall.sh

* Fix uninstall path in omnibus_build.yml
2022-12-06 15:07:45 -08:00
Jamil
25145bba47 Update Docker migration script to match install improvements (#1166) 2022-12-02 07:34:21 -08:00
Jamil
5d545da398 double-quote (#1095) 2022-11-05 15:01:05 -07:00
Jamil
4f4556d1c8 tlsOpts (#1094) 2022-11-05 14:51:34 -07:00
Jamil
5f14b1ab30 use tls opts (#1093) 2022-11-05 11:56:22 -07:00
Gabi
029891c69e Build/fix no prefix (#1089)
* fix: use caddy in host network_mode and make sure urls have a scheme

* fix: remove unnecesary exposed ports

* fix: remove support for hostnames begining with // since caddy doesn't support it

* Fix schemeless external URLs; error on invalid ones (#1090)

* Fix schemeless external URLs; error on invalid ones

* use different dockerfile for linux vs non-linux

* Use conditional EXTERNAL_URL defaults

* suppress empty warning

* postgres volume location

* Use inline Caddyfile

Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2022-11-03 19:36:37 -07:00
Jamil
b77eb394b3 check for docker compose before docker-compose (#1084)
* check for docker compose before docker-compose

* fix docker compose check

* formatting
2022-11-01 11:35:59 -07:00
Jamil
5ad4c8ccd5 Minor docs fixes (#1071)
* sudo for migrate

* Use sudo for cat

* docker-compose version 2 or higher
2022-10-27 16:28:26 -07:00