Commit Graph

736 Commits

Author SHA1 Message Date
dependabot[bot]
c64c54a95b build(deps): bump flowbite from 3.1.1 to 3.1.2 in /elixir/apps/web/assets (#8313)
Bumps [flowbite](https://github.com/themesberg/flowbite) from 3.1.1 to
3.1.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/themesberg/flowbite/releases">flowbite's
releases</a>.</em></p>
<blockquote>
<h2>v3.1.2</h2>
<ul>
<li>create new theme file to move CSS variables</li>
<li>update quickstart guide to reflect this change</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="4ffec1008a"><code>4ffec10</code></a>
refactor(flowbite): move color theme variables to css file</li>
<li><a
href="38984c12ae"><code>38984c1</code></a>
refactor(colors): move colors from plugin to theme file</li>
<li><a
href="23732fd518"><code>23732fd</code></a>
docs(datepicker): specify that you need to set source</li>
<li>See full diff in <a
href="https://github.com/themesberg/flowbite/compare/v3.1.1...v3.1.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=flowbite&package-manager=npm_and_yarn&previous-version=3.1.1&new-version=3.1.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-04 00:12:39 +00:00
dependabot[bot]
d94a16b583 build(deps): bump argon2_elixir from 4.0.0 to 4.1.2 in /elixir (#8305)
Bumps [argon2_elixir](https://github.com/riverrun/argon2_elixir) from
4.0.0 to 4.1.2.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/riverrun/argon2_elixir/blob/master/CHANGELOG.md">argon2_elixir's
changelog</a>.</em></p>
<blockquote>
<h1>Changelog</h1>
<p>All notable changes to this project will be documented in this
file.</p>
<p>The format is based on <a
href="https://keepachangelog.com/en/1.0.0/">Keep a Changelog</a>,
and this project adheres to <a
href="https://semver.org/spec/v2.0.0.html">Semantic Versioning</a>.</p>
<h2>v4.1.1 (2025-02-04)</h2>
<ul>
<li>Bug fixes
<ul>
<li>fixed unnecessary raise that results in warnings in Elixir 1.18</li>
</ul>
</li>
</ul>
<h2>v4.1.0 (2024-10-04)</h2>
<ul>
<li>Changes
<ul>
<li>Updated dependencies and made changes to silence warnings in Elixir
1.17</li>
</ul>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="f0e4a359f4"><code>f0e4a35</code></a>
update dependencies</li>
<li><a
href="bdc8be851e"><code>bdc8be8</code></a>
update to version 4.1.1</li>
<li><a
href="a390332029"><code>a390332</code></a>
Merge pull request <a
href="https://redirect.github.com/riverrun/argon2_elixir/issues/66">#66</a>
from flaviogrossi/fix_unnecessary_raise</li>
<li><a
href="db9a3f243e"><code>db9a3f2</code></a>
fix unnecessary raise</li>
<li><a
href="5b7a0757d5"><code>5b7a075</code></a>
update changelog</li>
<li><a
href="d3eb849c9f"><code>d3eb849</code></a>
update for Elixir 1.17</li>
<li>See full diff in <a
href="https://github.com/riverrun/argon2_elixir/compare/v4.0.0...v4.1.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=argon2_elixir&package-manager=hex&previous-version=4.0.0&new-version=4.1.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-04 00:12:07 +00:00
dependabot[bot]
75b11cf7ad build(deps): bump phoenix_html from 4.2.0 to 4.2.1 in /elixir (#8304)
Bumps [phoenix_html](https://github.com/phoenixframework/phoenix_html)
from 4.2.0 to 4.2.1.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/phoenixframework/phoenix_html/blob/main/CHANGELOG.md">phoenix_html's
changelog</a>.</em></p>
<blockquote>
<h2>4.2.1 (2025-02-21)</h2>
<ul>
<li>Enhancements
<ul>
<li>Add type to <code>Phoenix.HTML.FormField</code></li>
<li>Allow keyword lists in options to use nil as key/value</li>
</ul>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="71430c1d32"><code>71430c1</code></a>
Release v4.2.1</li>
<li><a
href="1a9341e931"><code>1a9341e</code></a>
Expand documentation of options_for_select (<a
href="https://redirect.github.com/phoenixframework/phoenix_html/issues/460">#460</a>)</li>
<li><a
href="0d15b13c78"><code>0d15b13</code></a>
Update ci.yml (<a
href="https://redirect.github.com/phoenixframework/phoenix_html/issues/459">#459</a>)</li>
<li><a
href="1bea177dfb"><code>1bea177</code></a>
Add type to Phoenix.HTML.FormField (<a
href="https://redirect.github.com/phoenixframework/phoenix_html/issues/458">#458</a>)</li>
<li><a
href="0a11e96826"><code>0a11e96</code></a>
Merge pull request <a
href="https://redirect.github.com/phoenixframework/phoenix_html/issues/457">#457</a>
from phoenixframework/sd-makeup-syntect</li>
<li><a
href="7ccce864f5"><code>7ccce86</code></a>
use makeup_syntect for highlighting JS (and diff)</li>
<li><a
href="9007635b14"><code>9007635</code></a>
Allow keyword list options to use nil as key and/or value (<a
href="https://redirect.github.com/phoenixframework/phoenix_html/issues/456">#456</a>)</li>
<li><a
href="df2a3f6352"><code>df2a3f6</code></a>
Update ExDoc</li>
<li>See full diff in <a
href="https://github.com/phoenixframework/phoenix_html/compare/v4.2.0...v4.2.1">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=phoenix_html&package-manager=hex&previous-version=4.2.0&new-version=4.2.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-04 00:12:01 +00:00
Jamil
fee808bc62 chore(portal): Log error for unknown channel messages (#8299)
Instead of crashing, it would make sense to log these and let the
connected entity maintain its WebSocket connection.

This should never happen in practice if we maintain our version
compatibility matrix properly, but it will help reduce the blast radius
of a channel message bug that happens to slip out into the wild.

Fixes #4679
2025-03-03 21:21:39 +00:00
Jamil
e5ae00ab99 fix(portal): norely -> noreply in gateway/channel.ex (#8329)
Fixes a typo that snuck in in #8267
2025-03-03 08:15:46 +00:00
Jamil
cb0bf44815 chore: Remove ability to create GCP log sinks (#8298)
This has long since been removed in the Clients.
2025-02-28 20:57:21 +00:00
Jamil
15938991d5 chore(portal): Remove NEW badge for DNS matching (#8259)
Fixes #8099
2025-02-28 04:52:56 +00:00
Jamil
e03047d549 feat(portal): Send gateway ipv4 and ipv6 to client (#8291)
In order to properly handle SRV and TXT records on the clients, we need
to be able to pick a Gateway using the initial query itself. After that,
we need to know the Gateway Tunnel IPs we're connecting to so we can
have the query perform the lookup.

Fixes #8281
2025-02-28 03:52:27 +00:00
Jamil
d09e9cfe08 fix(portal): Increase assert diff for last_flushed_at (#8292)
Fixes #8290
2025-02-28 01:23:37 +00:00
Jamil
d7be59707a fix(portal): Improve resource address validation (#8288)
We had a number of validation issues:

- DNS resources allow address `1.1.1.1` or `1.1.1.1/32`. These are not
valid and will cause issues during resolution.
- IP resources were allowing basically any string character on `edit`
caused by a logic bug in the changeset
- CIDR resources, same as above
- `*.*.*.*.google.com` and similar DNS wildcard resources were not
allowed

This PR beefs all of those up so that we have a higher degree of
certainty that our data is valid. If invalid data reaches connlib, it
will cause a panic.

This PR also introduces a migration to migrate any invalid resources
into the proper format in the DB.

Fixes #8287
2025-02-27 23:41:11 +00:00
Brian Manifold
bc150156ce fix(portal): Update gateway channel to process resource_update (#8280)
Why:

* After merging #8267 it was discovered that there was a race condition
that allowed a `resource_create` message to end up at the Gateway
Channel process. Previously, this message would not have ever arrived,
because we were replacing Resource IDs when a breaking change was made,
but since that is no longer the case, it is possible that a connection
could be established between the time the `delete_resource` and
`create_resource` messages are sent and the `create_resource` would end
up at the Gateway Channel process. This commit adds a no-op handler to
make sure the message gets processed without throwing an error.
2025-02-27 01:46:13 +00:00
Brian Manifold
d0f0de0f8d refactor(portal): Allow breaking changes in Resources/Policies (#8267)
Why:

* Rather than using a persistent_id field in Resources/Policies, it was
decided that we should allow "breaking changes" to these entities. This
means that Resources/Policies will now be able to update all fields on
the schema without changing the primary key ID of the entity.
* This change will greatly help the API and Terraform provider
development.

@jamilbk, would you like me to put a migration in this PR to actually
get rid of all of the existing soft deleted entities?

@thomaseizinger, I tagged you on this, because I wanted to make sure
that these changes weren't going to break any expectations in the client
and/or gateways.

---------

Signed-off-by: Brian Manifold <bmanifold@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2025-02-26 17:05:34 +00:00
Jamil
5650150b3f chore(portal): Enforce only internet resource in internet site (#8254)
Currently, it would theoretically be possible for an admin to connect
non-internet Resources to the Internet site. This PR fixes that by
enforcing only the `internet` Resource type can belong to the `Internet`
gateway group.


Related: #6834
2025-02-25 03:45:40 +00:00
Jamil
31111257e1 fix(portal): Fix layout of live_table filters controls (#8256)
Fixes layout of filters controls. A more permanent fix will be
introduced as part of #8255
2025-02-24 18:27:50 -08:00
Jamil
8bd94599a9 chore(portal): Remove dead ScimController (#8253)
This is leftover from a previous prototype and can be removed.
2025-02-24 22:58:38 +00:00
Jamil
c5929d4063 fix(portal): Show reload button when table data is stale (#8143)
Sentry uncovered a bug in the resources index liveview where it looks
like some code copy-pasted from the policies index view wasn't updated
properly to work in the resources live view, causing the view to crash
if an admin was viewing the table while the resources are changed in
another page.

In debugging that, I realized the best UX when viewing these tables is
usually just to show a `Reload` button and not update the data live
while the admin is viewing it, as this can cause missed clicks and other
annoyances.

This PR adds an optional `stale` component attribute that, if true, will
render a `Reload` button in the live table which upon clicking will
reload the live table.

Not all index views are updated with this - in some views there is
already logic to handle making an intelligent update without breaking
the view if the data is updated - for example for the clients table.

Ideally, we live-update things that don't reflow layout inline (such as
`online/offline` presence) and for things that do cause layout reflow
(create/delete), we show the `Reload` button.

However that work is saved for a future PR as this one fixes the
immediate bug and this is not the highest priority.

<img width="1195" alt="Screenshot 2025-02-16 at 8 44 43 AM"
src="https://github.com/user-attachments/assets/114efffa-85ea-490d-9cea-78c607081ce3"
/>
<img width="401" alt="Screenshot 2025-02-16 at 9 59 53 AM"
src="https://github.com/user-attachments/assets/8a570213-d4ec-4b6c-a489-dcd9ad1c351c"
/>
2025-02-24 15:39:16 +00:00
Jamil
29f0ac0a00 fix(portal): Handle missing params in idp callback (#8239)
It's possible for a client or admin to try and load the redirect URL
directly, or a misconfigured IdP may redirect back to us with missing
params. We should redirect with an error flash instead of 500'ing.
2025-02-24 13:38:10 +00:00
Jamil
d9a513fa54 fix(portal): optionally enable optimistic lock (#8229)
When the buffer is full, we want to update immediately, without locking.
2025-02-20 23:42:29 -08:00
Jamil
a797e350c0 fix(portal): Force update last_flushed_at for optimistic lock (#8228)
This PR fixes two issues:

1. Since we weren't updating any actual fields in the telemetry reporter
log record, it was never being updated, thus optimistic locking was not
taking effect. To fix this, we use `Repo.update(force: true)`.
2. If a buffer is full, we write immediately, but we provider an empty
`%Log{}` which causes a repetitive `the current value of last_flushed_at
is nil and will not be used as a filter for optimistic locking.`
2025-02-20 23:12:17 -08:00
Jamil
a07f1725c6 chore(portal): Refactor GCP labels logger to relax sentry alerts (#8213) 2025-02-20 11:20:45 +00:00
Jamil
2dae8bd656 fix(portal): move rename index before create internet site (#8209)
Otherwise prod won't run this migration...
2025-02-19 16:10:24 -08:00
Jamil
407085d7ec fix(portal): Add managed_by to gateway groups index (#8208)
Some customers have already picked the `Internet` name, which is making
our migrations fail.

This scopes the unique name index by `managed_by` so that our attempts
to create them succeed.
2025-02-19 15:55:51 -08:00
Jamil
80210a5093 fix(portal): fix typo on settings -> dns page (#8207) 2025-02-19 15:41:34 -08:00
Jamil
03558a5899 feat(website): Internet resource migration blogpost (#8150)
This is an announcement we will be linking to.
2025-02-19 15:28:52 -08:00
Jamil
0f4f20bd9c fix(elixir): Fix conditional in sentry clase in runtime.exs (#8188) 2025-02-18 17:50:18 -08:00
Jamil
6232f1a27e fix(elixir): Don't start sentry in unknown environments (#8185)
This ensures Sentry doesn't start in unknown `prod` environments.
2025-02-18 17:24:26 -08:00
Jamil
28559a317f chore(portal): Optionally drop NotFoundError to sentry (#8183)
By specifying the `before_send` hook, we can easily drop events based on
their data, such as `original_exception` which contains the original
exception instance raised.

Leveraging this, we can add a `report_to_sentry` parameter to
`Web.LiveErrors.NotFound` to optionally ignore certain not found errors
from going to Sentry.
2025-02-18 21:55:23 +00:00
Jamil
9b5a7e5fb3 fix(portal): Fix grammar on account lockout message (#8149) 2025-02-17 06:06:28 +00:00
Jamil
159e8e3dd5 fix(portal): Connect internet resource to internet site (#8151)
With the internet site changes now in, editing the Internet Resource is
impossible.

As such, the old instructions for using the Internet Resource no longer
apply, and we need to make sure the Internet Site and Internet Resource
are linked.

This migration ensures that's the case. However, if the internet
resource is currently connected to another site already, we don't move
it. This is only for internet resources that aren't connected to any
sites yet.
2025-02-16 17:30:48 -08:00
Jamil
d452e7d1b5 fix(portal): Parse string metric datetimes (#8148)
It turns out we can sometimes receive measurements with `DateTime`
fields, and other times they're strings. 🙃
2025-02-16 14:15:31 -08:00
Jamil
311988c5a2 fix(portal): Only compute diff for metrics with both start and end times (#8147)
A fix for a nil error from #8146
2025-02-16 12:57:03 -08:00
Jamil
36b887e98e fix(portal): Don't flush metrics when intervals < 5s (#8146) 2025-02-16 11:51:10 -08:00
Jamil
d29b210a63 chore(portal): Log metrics that failed to flush (#8142)
When flushing metrics to GCP, we sometimes get the following error:

```
{400, "{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"One or more TimeSeries could not be written: timeSeries[0-51]: write for resource=gce_instance{zone:us-east1-d,instance_id:6130184649770384727} failed with: One or more points were written more frequently than the maximum sampling period configured for the metric.\",\n    \"status\": \"INVALID_ARGUMENT\",\n    \"details\": [\n      {\n        \"@type\": \"type.googleapis.com/google.monitoring.v3.CreateTimeSeriesSummary\",\n        \"totalPointCount\": 52,\n        \"successPointCount\": 48,\n        \"errors\": [\n          {\n            \"status\": {\n              \"code\": 9\n            },\n            \"pointCount\": 4\n          }\n        ]\n      }\n    ]\n  }\n}\n"}
```

It would be helpful to know exactly which metrics are failing to flush
so we can further troubleshoot any issues.
2025-02-15 08:50:29 -08:00
Jamil
85ee37dfb3 Revert "fix(portal): Add node name key to metrics labels" (#8141)
The node_name label is already in the metrics.

Reverts firezone/firezone#8082
2025-02-15 08:47:45 -08:00
Jamil
5a3e940334 fix(portal): Fix typo in sites index (#8139)
Fixes a typo introduced in #6905
2025-02-15 07:25:08 -08:00
Andrew Dryga
bacb4596b7 feat(portal): Internet Sites (#6905)
Related #6834

Co-authored-by: Jamil Bou Kheir <jamilbk@users.noreply.github.com>
2025-02-15 00:34:30 +00:00
Jamil
5efb4b0fe2 fix(portal): Fix typo :dns -> :ip in seeds (#8134)
Fixes #8119
2025-02-14 20:32:28 +00:00
Jamil
93a88563f3 feat(portal): allow socket based postgres connections (#8044) (#8097)
This allows connections to the postgresql database via the standard
socket, which - opposed to TCP sockets - allows `peer` authentication
based on local unix users. This removes the need for a password and is
much simpler to deploy when running components locally.

In the current form, `DATABASE_SOCKET_DIR` takes precedence over
hostname, if the environment variable is present. I found that
`compile_config!` somehow enforces a value to be present which is
explicitly not what I want for some of these values (i think). I'd be
glad if anyone with more elixir experience can guide me as to how I can
make this more idiomatic.

---------

Supersedes: #8044

Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
Co-authored-by: oddlama <oddlama@oddlama.org>
2025-02-11 19:25:00 -08:00
Jamil
e32d2b845f fix(portal): Add node name key to metrics labels (#8082)
Ok, the reason why we're still getting the error `One or more points
were written more frequently than the maximum sampling period configured
for the metric.` is because the metric points are identified by the
labels in the metric, and so are "aggregated" more frequently than our
API calls.

By adding the node name to the labels, we scope the metric by that node
and prevent inserting the points more often than our API calls.
2025-02-11 17:21:27 +00:00
Jamil
feb1ec5e17 chore: Update client URLs & redirects for consistency (#8056)
Whenever changing a URL we care about, we add an entry in
`website/redirects.js` to avoid breaking links to the old page. Most
search engines reindex these after 1 year, but other websites and places
won't, so we should generally keep them indefinitely since they don't
cost us much to keep around.
2025-02-11 03:30:41 +00:00
oddlama
62ece23968 chore(portal): harden systemd relay example (#8045)
This adds hardening to the relay example systemd service shown in the
admin portal. Instead of running the service as root to download the
relay binary, we can let systemd manage the state directory and run with
lower privileges at all times.

I've also removed a shell injection which would in theory allow a
malicious github api server to run commands as root in the pre start
phase.

That being said I have no idea how this script is intended to function,
since it downloads the relay binary from the latest release on GitHub
which currently is a `gui-client` release without any relay binaries
attached.
2025-02-10 14:04:30 -08:00
Jamil
5bac3f5ec2 fix(infra): Don't send more/faster metrics than Google accepts (#8028)
We are getting quite a few of these warnings on prod:

```
{400, "{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"One or more TimeSeries could not be written: timeSeries[0-39]: write for resource=gce_instance{zone:us-east1-d,instance_id:2678918148122610092} failed with: One or more points were written more frequently than the maximum sampling period configured for the metric.\",\n    \"status\": \"INVALID_ARGUMENT\",\n    \"details\": [\n      {\n        \"@type\": \"type.googleapis.com/google.monitoring.v3.CreateTimeSeriesSummary\",\n        \"totalPointCount\": 40,\n        \"successPointCount\": 31,\n        \"errors\": [\n          {\n            \"status\": {\n              \"code\": 9\n            },\n            \"pointCount\": 9\n          }\n        ]\n      }\n    ]\n  }\n}\n"}
```

Since the point count is _much_ less than our flush buffer size of 1000,
we can only surmise the limit we're hitting is the flush interval.

The telemetry metrics reporter is run on each node, so we run the risk
of violating Google's API limit regardless of what a single node's
`@flush_interval` is set to.

To solve this, we use a new table `telemetry_reporter_logs` that stores
the last time a particular `flush` occurred for a reporter module. This
tracks global state as to when the last flush occurred, and if too
recent, the timer-based flush is call is `no-op`ed until the next one.

**Note**: The buffer-based `flush` is left unchanged, this will always
be called when `buffer_size > max_buffer_size`.
2025-02-10 18:21:40 +00:00
Jamil
3f62eff4a1 feat(portal): add configuration for the healthz port (#8020) (#8030)
This is required to run multiple components on a single machine (even if
the processes are sandboxed), since they will share a network namespace
and thus cannot bind to the same port.

Currently port `4000` is hardcoded, this PR allows this to be configured
by an environment variable.

---------

Co-authored-by: oddlama <oddlama@oddlama.org>
2025-02-07 10:35:05 +00:00
Jamil
a93f40befd chore(portal): Bump elixir to 1.18.2 (#8009)
This is mostly to stay up to date with current Elixir and benefit from
the new included [JSON parser](https://hexdocs.pm/elixir/JSON.html).

Removing `Jason` in favor of the embedded `JSON` parser is saved for a
[future PR](https://github.com/firezone/firezone/issues/8011).

It found a couple type violations which were simple to fix, and some
formatting changes.
2025-02-05 23:52:58 +00:00
Jamil
006ea4c6fd fix(infra): Inline sentry logging config (#8031)
It appears that something is initializing the Sentry.LoggerHandler
before we try to load it when starting:

```
Invalid logger handler config: {:logger,
 {:invalid_handler, {:function_not_exported, {Sentry.LoggerHandler, :log, 2}}}}
```

This doesn't seem to actually inhibit the Sentry logger at all,
presumably because it initializes just fine in the application start
callback.

Instead of defining the config in the `config/` directory, we can pass
it directly to `:logger` on start which solves the above issue.
2025-02-05 23:36:06 +00:00
Jamil
d1761e5a5d fix(infra): Bust cache for already-reported min/max metrics (#8026)
On staging (only), we see these logs spammed:


```
{400, "{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"One or more TimeSeries could not be written: timeSeries[22]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/queue_time/min must be CUMULATIVE, but is GAUGE.; timeSeries[11]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/query_time/max must be CUMULATIVE, but is GAUGE.; timeSeries[8]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/idle_time/max must be CUMULATIVE, but is GAUGE.; timeSeries[7]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/idle_time/min must be CUMULATIVE, but is GAUGE.; timeSeries[10]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/query_time/min must be CUMULATIVE, but is GAUGE.; timeSeries[14]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/query_time/max must be CUMULATIVE, but is GAUGE.; timeSeries[13]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/query_time/min must be CUMULATIVE, but is GAUGE.; timeSeries[16]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/query_time/min must be CUMULATIVE, but is GAUGE.; timeSeries[23]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/queue_time/max must be CUMULATIVE, but is GAUGE.; timeSeries[20]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/query_time/max must be CUMULATIVE, but is GAUGE.; timeSeries[19]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/query_time/min must be CUMULATIVE, but is GAUGE.; timeSeries[17]: Metric kind for metric custom.googleapis.com/elixir/domain/repo/query/query_time/max must be CUMULATIVE, but is GAUGE.\",\n    \"status\": \"INVALID_ARGUMENT\",\n    \"details\": [\n      {\n        \"@type\": \"type.googleapis.com/google.monitoring.v3.CreateTimeSeriesSummary\",\n        \"totalPointCount\": 36,\n        \"successPointCount\": 24,\n        \"errors\": [\n          {\n            \"status\": {\n              \"code\": 3\n            },\n            \"pointCount\": 12\n          }\n        ]\n      }\n    ]\n  }\n}\n"}
```

This does not happen on prod. As far as I can tell, GCP will cache the
initial metric kind used when the metric ID was first used, which
appears to be `CUMULATIVE` here.

The correct metric kind for these is `GAUGE` since they're reporting a
min/max value.

Since GCP doesn't support resetting the auto-defined metric kind of a
particular metric ID, we need to alter the ID to "bust" the cache and
create a new definition.
2025-02-05 18:30:04 +00:00
Jamil
dec2b0ee81 fix(portal): Only configure Sentry.LoggerHandler once (#8025)
The applications within our umbrella are all joined into a single Erlang
cluster, and logger configuration is applied already to the entire
umbrella.

As such, registering the Sentry log handler in each application's
startup routine triggers duplicate handlers to be registered for the
cluster, resulting in warnings like this in GCP:

```
Event dropped due to being a duplicate of a previously-captured event.
```

As such, we can move the log handler configuration to the top-level
`:logger` key, under the `:logger` subkey for configuring a single
handler. We then load this handler config in the `domain` app only and
it applies to the entire cluster.
2025-02-05 13:41:19 +00:00
Jamil
6be7cf6b45 feat(portal): Add Sentry reporting (#8013)
This adds https://github.com/getsentry/sentry-elixir to the portal for
automatic process crash and exception trace reporting.

It also configures Logger reporting for the `warning` level and higher,
and sets the data scrubbing rules to allow all Logger metadata keys
(`logger_metadata.*` in the Sentry project settings).

Lastly, it configures automatic HTTP error reporting by tying into the
`api` and `web` endpoint modules with a custom `plug` middleware so we
get automatic reporting of unsuccessful Phoenix responses.

It is expected this will be noisy when we first deploy and we'll need to
tune it down a bit. This is the same approach used with other Sentry
platforms.
2025-02-04 18:35:52 +00:00
dependabot[bot]
bbbd6eded2 build(deps): bump phoenix_live_view from 1.0.0-rc.6 to 1.0.3 in /elixir (#7983)
Bumps
[phoenix_live_view](https://github.com/phoenixframework/phoenix_live_view)
from 1.0.0-rc.6 to 1.0.3.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/phoenixframework/phoenix_live_view/blob/v1.0.3/CHANGELOG.md">phoenix_live_view's
changelog</a>.</em></p>
<blockquote>
<h2>1.0.3 (2025-01-28)</h2>
<h3>Bug fixes</h3>
<ul>
<li>Fix regression where browser back/forward buttons used
<code>patch</code> instead of <code>navigate</code>, failing to update
the page (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3529">#3529</a>)</li>
<li>Fix client hooks inside streams that contain nested LiveViews (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3530">#3530</a>)</li>
<li>Fix LiveComponents in nested LiveViews not updating under certain
conditions (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3626">#3626</a>)</li>
<li>Fix client-side hooks not being cleared properly (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3628">#3628</a>)</li>
<li>Fix LiveUpload from client hook not auto uploading when immediately
followed by form event (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3647">#3647</a>)</li>
<li>Fix inputs being cleared in some cases when patching locked trees
(<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3647">#3647</a>)</li>
<li>Fix client hooks with dynamic IDs not being destroyed properly when
parts of the DOM are locked (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3651">#3651</a>)</li>
</ul>
<h3>Enhancements</h3>
<ul>
<li>Allow to configure if duplicate IDs / other detected errors should
warn or raise by passing <code>on_error</code> to
<code>Phoenix.LiveViewTest.live/3</code> /
<code>Phoenix.LiveViewTest.live_isolated/3</code> (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/pull/3653">#3653</a>)</li>
<li>Also detect duplicate LiveComponents that are added dynamically to
the page in LiveViewTest (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/pull/3653">#3653</a>)</li>
<li>Log an error in the JavaScript console when detecting a stream
container with missing <code>phx-update=&quot;stream&quot;</code>
attribute (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/pull/3645">#3645</a>)</li>
<li>Update documentation to mention <code>:fun</code> and <code>{:fun,
arity}</code> as valid attribute types for
<code>Phoenix.Component.attr/3</code> (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/pull/3635">#3635</a>)</li>
<li>Update documentation to mention ways for <a
href="https://hexdocs.pm/phoenix_live_view/1.0.3/Phoenix.Component.html#module-dynamic-component-rendering">dynamically
rendering function components</a> (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/pull/3632">#3632</a>)</li>
<li>Update documentation to mention <code>{:inner, selector}</code> and
<code>{:closest, selector}</code> as <a
href="https://hexdocs.pm/phoenix_live_view/1.0.3/Phoenix.LiveView.JS.html#module-dom-selectors">valid
options for <code>to</code></a> in JS commands (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/pull/3638">#3638</a>)</li>
</ul>
<h2>1.0.2 (2025-01-09)</h2>
<h3>Bug fixes</h3>
<ul>
<li>Fix inconsistency between <code>mix format</code> and <code>mix
format --check-formatted</code> with new curly interpolation syntax (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3590">#3590</a>)</li>
<li>Fix unnecessary compile time dependencies when using
<code>attr</code> / <code>on_mount</code> / <code>live</code> (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3592">#3592</a>)</li>
<li>Fix crash when testing LiveViews with embedded XML (e.g. SVGs) (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3594">#3594</a>)</li>
<li>Fix type warning when using <code>follow_redirect</code> (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3581">#3581</a>)</li>
<li>Prevent <code>phx-trigger-action</code> from clashing with locked
forms (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3591">#3591</a>)</li>
<li>Fix form recovery sending wrong event name when using JS commands in
<code>phx-change</code> (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3607">#3607</a>)</li>
</ul>
<h3>Enhancements</h3>
<ul>
<li>Deduplicate items on <code>stream/4</code> /
<code>steam_insert/4</code> (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/pull/3599">#3599</a>)</li>
<li>Restore scroll position on initial navigation (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/pull/3572">#3572</a>)</li>
<li>Change-track non existing keys in maps (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/pull/3584">#3584</a>)</li>
<li>Only warn instead of raising when detecting a duplicate ID in
LiveViewTest (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/pull/3603">#3603</a>)</li>
</ul>
<h2>1.0.1 (2024-12-13)</h2>
<h3>Bug fixes</h3>
<ul>
<li>Raise when duplicate DOM IDs are found when rendering a LiveView
during tests to avoid undefined behaviour</li>
<li>Fix live session verification causing logged errors, push_patch
failures, and failed mounts when a cold deploy occurs</li>
<li>Fix a bug where the <code>live_session</code>'s
<code>on_mount</code> hooks would be called for sticky live views on
connected mount. Now a <code>sticky</code> live view is consistently
marked as <code>:not_mounted_at_router</code></li>
</ul>
<h2>1.0.0 (2024-12-03) 🚀</h2>
<h2>1.0.0-rc.9 (2024-12-03)</h2>
<h3>Enhancements</h3>
<ul>
<li>Support <code>phx-no-curly-interpolation</code> to disable HEEx
curly interpolation in a specific tag body</li>
</ul>
<h2>1.0.0-rc.8 (2024-12-02)</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="8ea6b487de"><code>8ea6b48</code></a>
Release 1.0.3</li>
<li><a
href="e419029347"><code>e419029</code></a>
mix format</li>
<li><a
href="df82b86f4b"><code>df82b86</code></a>
small refactor of on_error tests</li>
<li><a
href="f1b9d2b492"><code>f1b9d2b</code></a>
only raise by default in later release</li>
<li><a
href="aee1b64972"><code>aee1b64</code></a>
update tests to not use deprecated struct update syntax</li>
<li><a
href="7a69ff77ec"><code>7a69ff7</code></a>
update changelog</li>
<li><a
href="6ca0b8b655"><code>6ca0b8b</code></a>
Update assets</li>
<li><a
href="f100c75de3"><code>f100c75</code></a>
fail early when hook element is not owned by view (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3618">#3618</a>)</li>
<li><a
href="a414c2cdd9"><code>a414c2c</code></a>
Update assets</li>
<li><a
href="07e4340c30"><code>07e4340</code></a>
remove replaceRootHistory (<a
href="https://redirect.github.com/phoenixframework/phoenix_live_view/issues/3625">#3625</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/phoenixframework/phoenix_live_view/compare/v1.0.0-rc.6...v1.0.3">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=phoenix_live_view&package-manager=hex&previous-version=1.0.0-rc.6&new-version=1.0.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jamil Bou Kheir <jamilbk@users.noreply.github.com>
2025-02-04 14:18:00 +00:00
Jamil
a44787cc13 chore(portal): Bump to Alpine 3.20.5 (#8010)
Signed-off-by: Jamil <jamilbk@users.noreply.github.com>
2025-02-03 23:28:20 +00:00