Commit Graph

160 Commits

Author SHA1 Message Date
Jamil
a8f93d24a3 chore(infra): ditch gcp registry for ghcr.io (#9913)
Google Cloud Artifact registry and Cloud storage is a significant cost.
GitHub, on the other hand, is completely free due to our being a public
repository. Hence, it makes sense to ditch GCP for GHCR.

To do this, we move all "staging" artifacts to GHCR. These will then be
used in the infra repo to push to GCP for deploys - we probably still
want pulls for our infra to hit GCP and not GitHub.

One big element of this is that we potentially lose sccache, so I'll be
checking the compile time of this PR and looking for alternatives that
don't involve such a massive cloud bill.
2025-07-19 07:00:30 -07:00
Thomas Eizinger
2fd56fb7ae chore: remove pull_policy from containers (#9887)
Having to pull these every time one does `docker compose up` is annoying
and unnecessary.
2025-07-16 09:15:29 +00:00
Thomas Eizinger
d8ca2b4f7e chore: fix invalid build stage in docker-compose.yml (#9886)
We have since removed the `dev` stage from the Rust Dockerfile.

Resolves: #9768
2025-07-16 07:01:20 +00:00
Jamil
dddd1b57fc refactor(portal): remove flow_activities (#9693)
This has been dead code for a long time. The feature this was meant to
support, #8353, will require a different domain model, views, and user
flows.

Related: #8353
2025-06-27 20:40:25 +00:00
Thomas Eizinger
e36efa5d62 ci: set static Firezone ID for docker-compose setup (#9637) 2025-06-23 14:59:53 +00:00
Jamil
a20989a819 feat(portal): conditional migrations on prod (#9562)
Some migrations take a long time to run because they require locks or
modify large amounts of data. To prevent this from causing issues during
deploy, we leverage Ecto's native support for loading migrations from
multiple directories to introduce a `conditional_migrations/` directory
that houses any conditional migrations we want to run.

To run these migrations, you'll need to do one of the following:

- `dev, test`: The `mix ecto.migrate` will run them by default because
we have aliased this to load conditional_migrations for dev
- `prod`: Set the `RUN_CONDITIONAL_MIGRATIONS` env var to `true` before
starting a prod server using the `bin/migrate` script.
- `dev, test, prod`: Run `Domain.Release.migrate(conditional: true)`
from an IEx shell.

If conditional migrations were found that weren't executed during
`Domain.Release.migrate`, a warning is logged to remind us to run them.

---------

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
2025-06-18 18:08:25 +00:00
Jamil
d18c40ef7d feat(infra): Use Postgres 17 for dev and test (#9215)
Upgrades dev and test envs to use Postgres 17.

Related: #5442
2025-05-23 21:43:47 +00:00
Jamil
2ef49b2e75 chore: remove unused DATABASE_REPLICATION vars (#9039)
These were added in #8909 and never removed and are unused.
2025-05-06 04:01:16 +00:00
Thomas Eizinger
7d96953265 ci: add integration test with ECN enabled (#9012) 2025-05-02 10:25:12 +00:00
Jamil
968db2ae39 feat(portal): Receive WAL events (#8909)
Firezone's control plane is a realtime, distributed system that relies
on a broadcast/subscribe system to function. In many cases, these events
are broadcasted whenever relevant data in the DB changes, such as an
actor losing access to a policy, a membership being deleted, and so
forth.

Today, this is handled in the application layer, typically happening at
the place where the relevant DB call is made (i.e. in an
`after_commit`). While this approach has worked thus far, it has several
issues:

1. We have no guarantee that the DB change will issue a broadcast. If
the application is deployed or the process crashes after the DB changes
are made but before the broadcast happens, we will have potentially
failed to update any connected clients or gateways with the changes.
2. We have no guarantee that the order of DB updates will be maintained
in order for broadcasts. In other words, app server A could win its DB
operation against app server B, but then proceed to lose being the first
to broadcast.
3. If the cluster is in a bad state where broadcasts may return an error
(i.e. https://github.com/firezone/firezone/issues/8660), we will never
retry the broadcast.

To fix the above issues, we introduce a WAL logical decoder that process
the event stream one message at a time and performs any needed work.
Serializability is guaranteed since we only process the WAL in a single,
cluster-global process, `ReplicationConnection`. Durability is also
guaranteed since we only ACK WAL segments after we've successfully
ingested the event.

This means we will only advance the position of our WAL stream after
successfully broadcasting the event.

This PR only introduces the WAL stream processing system but does not
introduce any changes to our current broadcasting behavior - that's
saved for another PR.
2025-04-29 23:53:06 -07:00
Jamil
48319df9f0 revert(#8893): Revert adding wal2json dev image (#8908)
Turns out that the standard `pgoutput` plugin shipped with Postgres will
do everything we need it to, and there are good examples of prior art
decoding its binary output in Elixir (in production).

So to avoid adding a dependency on `wal2json` here, we'll go with that.
2025-04-26 22:43:32 +00:00
Jamil
7e052313af feat(infra): Enable wal logical for dev (#8879)
Enables `wal_level = logical` so we can start implementing CDC.


**WARNING**: This will trigger a restart of our database instance, so it
should be deployed during our standard maintenance window (Saturday
evening).
2025-04-25 19:01:37 +00:00
Jamil
f6ae7559e8 feat(ci): Add custom postgres Dockerfile for wal2json (#8893)
In order to develop and test WAL replication, we need the wal2json
module installed in our dev postgres image. The module itself builds
very quickly, but I thought it would be better to have this
automatically built and pushed as part of a nightly job so that CI and
developers can make use of it.
2025-04-25 12:31:40 +00:00
Thomas Eizinger
0a46fdf7b5 chore(rust): remove dev stage in Dockerfile (#8688)
We don't ever use the `dev` stage within our Rust Dockerfile that
actually builds the binaries within the container. In CI, we build the
binaries on the host and then copy them in. During local development, I
always do the same because it is much faster to iterate that way.

Long story short: We don't need this stage within our Dockerfile and it
causes confusion when people try to use `docker compose build`. If
somebody really wanted to do that, they need to follow the instructions
in the Dockerfile and build the binary first.

Related: #8687

---------

Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2025-04-10 04:00:58 +00:00
Thomas Eizinger
82a52ef497 feat: add edgeshark to local docker compose (#8526)
EdgeShark is extremely useful if you want to attach WireShark to a TUN
device within a container. So far, I've just run this ad-hoc next to our
setup whenever I needed to debug something but I think it is actually
worthwhile adding permanently so it is just there when you need it.
2025-03-27 01:11:37 +00:00
Jamil
06aa485e18 ci: Use search_domain for one resource in CI test (#8393)
- Adds a `search_domain` of `httpbin.test` in seeds
- Updates one of our DNS resources under CI test to use this
2025-03-15 13:27:22 +00:00
Jamil
7df1bf2718 feat(portal): Create pgaudit extension (#8435)
[Step
2](https://cloud.google.com/sql/docs/postgres/pg-audit#set-pgaudit-flag-values)
of the pgaudit setup guide for Google Cloud SQL. It would be good to
have detailed pg audit logs on the master application instance in case
things go wrong.

Notably, this prevents erroring out when the `pgaudit` is not available,
which by default, it is. Enabling the `pgaudit` extension for our dev
instance is left as a future endeavor.

Supersedes #5442
2025-03-14 20:04:47 +00:00
Jamil
e3897aebd8 feat(portal): Add Mock sync adapter and more seeds (#8370)
- Adds more actor groups to the existing `oidc_provider`
- Configures a rand seed so our seed data is reproducible across
machines
- Formats the seeds file to allow for some refactoring a later PR
- Adds a `Mock` identity provider adapter with sync enabled
2025-03-07 09:37:32 -08:00
Thomas Eizinger
d12ce29c94 chore(docker-compose): add init shim for Gateway (#8257)
In order for the Gateway container to correctly react to signals for
restarting / rebuilding, it needs to have the `init` shim activated.
2025-02-25 03:51:05 +00:00
Jamil
cdb669f6c5 chore(dev): Use postgres:15 for docker-compose.yml (#8029)
This will ensure we're using the latest Postgres major, which should
more closely track staging/prod.
2025-02-06 14:16:34 +00:00
Jamil
ac77fc7ab0 fix(dev): Update tokens in local docker dev env (#7825)
These have drifted and are no longer working, so they've been updated
from a fresh `mix ecto.seed` output.
2025-01-22 05:27:01 +00:00
Jamil
6f7f6a4f34 style: Enforce code style across all supported languages using Prettier (#7322)
This ensure that we run prettier across all supported filetypes to check
for any formatting / style inconsistencies. Previously, it was only run
for files in the website/ directory using a deprecated pre-commit
plugin.

The benefit to keeping this in our pre-commit config is that devs can
optionally run these checks locally with `pre-commit run --config
.github/pre-commit-config.yaml`.

---------

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-11-13 00:19:15 +00:00
FTB_lag
f4512175ad chore(infra): fix hostname for domain in cluster config (#6650)
Fix hostname for domain
2024-09-13 11:13:58 -07:00
Andrew Dryga
2d083379c6 feat(portal): Internet resources (#6299)
They will be sent in the API for connlib 1.3 and above.

I think in future we can make a whole menu section called "Internet
Security" which will be a specialized UI for the new resource type (and
now show it in Resources list) to improve the user experience around it.

Closes #5852

---------

Signed-off-by: Andrew Dryga <andrew@dryga.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2024-08-27 23:11:17 +00:00
Brian Manifold
e78737c4c8 fix(portal): Refactor API URL config for Web app (#6202)
Why:

* The Swagger UI is currently served from the API application. This
means that the Web application does not have access to the external URL
in the API configuration during/after compilation. Without the API
external URL, we cannot generate a proper link in the portal to the
Swagger UI. This commit refactors how the API external URL is set from
the environment variables and allows the Web app to have access to the
value of the API URL.

Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2024-08-07 19:30:18 +00:00
Jamil
0c6cd4a804 fix(ci): Add http test server image specifiers to CI (#6208)
- Adds `http_test_server_image` to inputs so that it gets set properly
for CI (`debug`) and CD (`perf`)
- Updates `dev` -> `debug` in docker-compose.yml to fix pulls
- Fixes issue with seeds and relevant docs from #6205
2024-08-07 12:15:00 -07:00
Thomas Eizinger
94527f9fa1 fix(gateway): always masquerade for docker-deployed gateways (#6169)
Without masquerading, packets sent by the gateway through the TUN
interface use the wrong source address (the TUN device's address)
instead of the gateway's actual network interface.

We set this env variable in all our uses of the gateway, thus we might
as well remove it and always perform unconditionally.

---------

Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
2024-08-07 03:00:50 +00:00
Thomas Eizinger
5687befc9d ci: use correct service name in docker-compose.yml (#6055)
The compose service I defined is called `otel` not `otlp`. With this fix
in place, the relay successfully connects to the OTLP exporter.

it is worthwhile noting that the connection to the OTLP exporter itself
is not critical for relay operation. Even if it fails, it won't affect
the actual data plane. I do think it makes sense to still have a working
OTLP exporter in the compose definition. As it makes it easier to test
whether the ingestion of metrics and traces works as expected.
2024-07-27 02:48:08 +00:00
Jamil
607a73ba0d ci: Use OTLP_ENDPOINT for both CI relays (#6049)
~~Relays are still failing to boot~~. By setting OTLP_ENDPOINT for both
relays in CI we will more closely mimic staging/prod env.

Edit: They just started working randomly. It had failed with a core dump
error after #6034 was merged, which is a bit concerning.
2024-07-25 23:38:36 +00:00
Thomas Eizinger
f800875aff fix(relay): don't hang when connecting to OTLP exporter (#6034)
The dependency update in #6003 introduced a regression: Connecting to
the OTLP exporter was hanging forever and thus the relay failed to start
up.

The hang seems to be related to _dropping_ the `meter_provider`. Looking
at the changelog update, this change was actually called out:
https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-otlp/CHANGELOG.md#v0170.

By setting these providers globally, the relay starts up just fine.

To ensure this doesn't regress again, we add an OTEL collector to our
`docker-compose.yml` and configure the `relay-1` to connect to it.
2024-07-25 10:36:42 -06:00
FTB_lag
2f9175b66a chore(infra): fix docker image and tag for domain (#5769)
Signed-off-by: FTB_lag <tabolskyy.git@gmail.com>
2024-07-05 19:52:37 -07:00
Jamil
60d2a2befd fix(infra): relay listens on UDP only (#5718)
I don't believe we use/need TCP for the Relays. Better to keep the ports
closed if so.

Also, the docker-compose.yml is updated to allow the `relay-1` service
to respond to all its ports, since we don't need those mapped typically.
2024-07-04 16:53:08 +00:00
FTB_lag
efd0218383 chore: fix contributing docs and fix feature flags in docker compose (#5572) 2024-06-27 11:45:59 -07:00
Thomas Eizinger
8fe43a8afe chore(phoenix-channel): only flush after writing (#5510)
Currently, `phoenix-channel` calls `flush` manually to ensure we don't
have messages sitting in a buffer somewhere. This is somewhat wasteful
if we haven't actually written any message. We can move the flushing to
directly after sending the message.

To avoid further buffering on the TCP level, we disable Nagle's
algorithm to avoid buffering on the TCP level.
2024-06-25 20:07:54 +00:00
Jamil
a2c76cbeb8 fix: Use correct seeds token used for local Gateway (#5533)
After this, you can once again spin up a local env by `docker compose up
-d` and then seeding the DB [with the instructions
here](https://github.com/firezone/firezone/tree/main/elixir#running-control-plane-for-local-development).
2024-06-25 05:26:26 +00:00
Jamil
a45acc04db fix(connlib): set default firezone_tunnel log level from trace to debug for development and some ci (#5411)
"Encapsulated packet" is now spamming dev clients, so this level is
changed to `debug` by default in dev builds.

```
2024-06-17 14:04:15.419  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
2024-06-17 14:04:15.419  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
2024-06-17 14:04:15.420  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
2024-06-17 14:04:15.420  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
2024-06-17 14:04:15.420  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
2024-06-17 14:04:15.420  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
2024-06-17 14:04:15.421  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
2024-06-17 14:04:15.421  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
2024-06-17 14:04:15.422  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
2024-06-17 14:04:15.422  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
2024-06-17 14:04:15.422  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
2024-06-17 14:04:15.423  6911-7520  connlib                 dev.firezone.android                 V  firezone_tunnel::client: s0_name: encapsulates0_target=firezone_tunnel::clients0_file=connlib/tunnel/src/client.rss0_line=441s0_dst=fd00:2021:1111:8000::2Encapsulated packet
```
2024-06-18 04:48:52 +00:00
Jamil
0d2d9c3fdb chore: Enable jumpcloud adapter for dev and staging (#5343)
Will need to do the same for prod after deploy.
2024-06-12 21:54:44 +00:00
Jamil
56a8f3c974 chore(ci): Bump CI tool versions (#5285)
Bumps the tool versions that fall through the Dependabot cracks.
2024-06-10 16:13:28 +00:00
Andrew Dryga
650d7d7998 feat(portal): Add Policy conditions (#5144)
Now policies can have additional conditions based on Client location
(country or IP range), IdP provider used for sign in or the current time
of the day at a given timezone. This covers use cases where employees
can access the production system only from certain countries (states can
be added later) or when contractors can only access internal tools
during working hours.

Closes https://github.com/firezone/firezone/issues/4743
Closes #4742
Closes #4741
Closes #4740


<img width="1728" alt="Screenshot 2024-05-31 at 13 50 53"
src="https://github.com/firezone/firezone/assets/1877644/55f509f2-0f49-4edb-8c03-7a5a6d884ccc">
<img width="1728" alt="Screenshot 2024-05-31 at 13 50 56"
src="https://github.com/firezone/firezone/assets/1877644/756bb03f-4024-4978-ac85-6daa918ae037">
<img width="1728" alt="Screenshot 2024-05-31 at 13 51 01"
src="https://github.com/firezone/firezone/assets/1877644/cf159a86-077f-4ada-9952-9e8d399d0dc1">
<img width="1728" alt="Screenshot 2024-05-31 at 13 51 03"
src="https://github.com/firezone/firezone/assets/1877644/c070719e-2d4b-41bd-ad03-430baf2dbe9b">
<img width="676" alt="Screenshot 2024-05-31 at 14 56 06"
src="https://github.com/firezone/firezone/assets/1877644/435a4951-479d-4371-99c4-29a055348175">
2024-06-09 12:46:35 -06:00
Reactor Scram
b444dee1c9 refactor(headless-client): deprecate subcommands for now (#4953)
Closes #4907

They're still accepted, but the binary entirely determines the behavior.
This makes the code for CLI parsing and token handling simpler with
fewer branches, so it's easier to be sure it's correct.

Replaces #4942 which isn't doing what I intended anymore.
2024-05-13 16:05:44 +00:00
Jamil
4a6ff03626 refactor(portal): Remove Permit all and grey out form when traffic filters disabled (#4887)
- Simplify traffic filters: empty means permit all
- Grey out form instead of hiding when traffic filters disabled, fixes
#4816
- Fix port range population when no ports have been entered
- Update tests
- Add migration to migrate existing prod data
- Add "UPGRADE TO UNLOCK" badge
- Add `inline_errors` attr to show inline error messages
- Remove traffic filters feature flag to allow enable/disable by billing
instead

<img width="757" alt="Screenshot 2024-05-03 at 12 43 24 PM"
src="https://github.com/firezone/firezone/assets/167144/9e9277cb-4653-427c-ade3-4e3b9d479411">

<img width="194" alt="Screenshot 2024-05-03 at 2 03 06 PM"
src="https://github.com/firezone/firezone/assets/167144/06e03314-9010-48a0-8504-0ab49173f0a9">

---------

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
Co-authored-by: Andrew Dryga <andrew@dryga.com>
2024-05-07 16:27:00 +00:00
Andrew Dryga
a666d63051 Add environment variables to allow enabling all features locally 2024-04-22 13:32:52 -06:00
Thomas Eizinger
51089b89e7 feat(connlib): smoothly migrate relayed connections (#4568)
Whenever we receive a `relays_presence` message from the portal, we
invalidate the candidates of all now disconnected relays and make
allocations on the new ones. This triggers signalling of new candidates
to the remote party and migrates the connection to the newly nominated
socket.

This still relies on #4613 until we have #4634.

Resolves: #4548.

---------

Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2024-04-20 06:16:35 +00:00
Gabi
d0c33681fe chore(rust): fix local docker development (#4642)
some small fixes to make local development a bit easier
2024-04-16 21:08:02 +00:00
Reactor Scram
493716ab6b refactor(headless-client): change CLI args for the IPC daemon (#4604)
Closes #4515
2024-04-15 18:33:30 +00:00
Reactor Scram
3a67eacfbe refactor(linux-client): replace client-tunnel with headless-client which is the same thing (#4516)
Unfortunately I had to keep `linux-client` to get the compatibility
tests to pass. #4578 aims to remove that package.

Please add to this list if you think of anything:

```[tasklist]
# Things that may break that CI/CD won't catch
- [ ] Github release artifacts
- [ ] Knowledge base 
- [ ] Docker images
- [ ] Docker containers
- [ ] Existing `linux-client` users
- [ ] Anything that downloads ghcr artifacts
- [ ] Nix (Not sure if it's built in CI. It had a merge conflict)
```

Refs #4515, and #3712, #3782

I think this is what Thomas and I agreed on in Slack / Github

---------

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2024-04-10 22:01:55 +00:00
Jamil
7d88e28872 chore(ci): Configure relay with new IP on restart tests (#4571)
See https://firezonehq.slack.com/archives/C0575SD66E5/p1712726575563089
2024-04-10 08:45:38 +00:00
Jamil
09532ea845 chore(ci): Add portal and relay downtime DNS resource tests (#4517)
Tests that DNS still works in the client with established connections
after the portal and/or relay go down.
2024-04-08 09:43:59 +00:00
Reactor Scram
1e4ed7bad6 refactor(ci): move DNS control method up to docker-compose.yml (#4341)
This is part of a yak shave towards CI testing of #3812 

Moving the DNS control method out of `docker-compose.yml` and up to the
integration tests themselves allows us to test these scenarios:

- `systemd-resolved`
- `etc-resolv-conf`
- `systemd-resolved` but we're in a container where that won't work, so
we should gracefully degrade to just allowing IP/CIDR resources
2024-04-02 17:11:29 +00:00
Andrew Dryga
2cf63cb33a fix(portal): Serve static files with digests at root (#4386)
Closes #4384
2024-03-28 16:13:13 -06:00