Skip to content

Commit 1411a69

Browse files
authored
Revert "feat: tighten gotrue.service deps and startup behavior (#1783)"
This reverts commit 493bd39.
1 parent 493bd39 commit 1411a69

File tree

2 files changed

+7
-80
lines changed

2 files changed

+7
-80
lines changed

ansible/files/gotrue.service.j2

Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,14 @@
11
[Unit]
22
Description=Gotrue
33

4-
# Avoid starting gotrue while cloud-init is running. It makes a lot of changes
5-
# and I would like to rule out side effects of it running concurrently along
6-
# side services.
7-
After=cloud-init.service
8-
Wants=cloud-init.target
9-
10-
# Given the fact that auth uses SO_REUSEADDR, I want to rule out capabilities
11-
# being modified between restarts early in boot. This plugs up the scenario that
12-
# EADDRINUSE errors originate from a previous gotrue process starting without
13-
# the SO_REUSEADDR flag (due to lacking capability at that point in boot proc)
14-
# so when the next gotrue starts it can't re-use a slow releasing socket.
15-
After=apparmor.service
16-
17-
# We want sysctl's to be applied
18-
After=systemd-sysctl.service
19-
20-
# UFW Is modified by cloud init, but started non-blocking, so configuration
21-
# could be in-flight while gotrue is starting. I want to ensure future rules
22-
# that are relied on for security posture are applied before gotrue runs.
23-
After=ufw.service
24-
25-
# We need networking & resolution, auth uses the Go DNS resolver (not libc)
26-
# so it's possible `localhost` resolution could be unstable early in startup. We
27-
# care about this because SO_REUSEADDR eligibility checks the tuple
28-
# (proto, family, addr, port) meaning the AF_INET (ipv4, ipv6) could affect the
29-
# binding resulting in a second way for EADDRINUSE errors to surface.
30-
#
31-
# Note: We should consider removing localhost usage given `localhost` resolution
32-
# can often be racey early in boot, can be difficult to debug and offers no real
33-
# advantage in our infra. At the very least avoiding DNS resolved binding would
34-
# be a good idea.
35-
Wants=network-online.target systemd-resolved.service
36-
After=network-online.target systemd-resolved.service
37-
38-
# Auth server can't start unless postgres is online, lets remove a lot of auth
39-
# server noise during slow starts by requiring it.
40-
Wants=postgresql.service
41-
After=postgresql.service
42-
43-
# Lower start limit ival and burst to prevent the noisy flapping
44-
StartLimitIntervalSec=10
45-
StartLimitBurst=5
46-
474
[Service]
48-
Type=exec
5+
Type=simple
496
WorkingDirectory=/opt/gotrue
50-
51-
# Both v2 & v3 need a config-dir for reloading support.
7+
{% if qemu_mode is defined and qemu_mode %}
8+
ExecStart=/opt/gotrue/gotrue
9+
{% else %}
5210
ExecStart=/opt/gotrue/gotrue --config-dir /etc/auth.d
53-
ExecReload=/bin/kill -10 $MAINPID
11+
{% endif %}
5412

5513
User=gotrue
5614
Restart=always
@@ -59,36 +17,11 @@ RestartSec=3
5917
MemoryAccounting=true
6018
MemoryMax=50%
6119

62-
# These are the historical location of env files. The /etc/auth.d dir will
63-
# override them when present.
6420
EnvironmentFile=-/etc/gotrue.generated.env
6521
EnvironmentFile=/etc/gotrue.env
6622
EnvironmentFile=-/etc/gotrue.overrides.env
6723

68-
# Both v2 & v3 support reloading via signals, on linux this is SIGUSR1.
69-
Environment=GOTRUE_RELOADING_SIGNAL_ENABLED=true
70-
Environment=GOTRUE_RELOADING_SIGNAL_NUMBER=10
71-
72-
# Both v2 & v3 disable the poller. While gotrue sets it to off by default we
73-
# defensively set it to false here.
74-
Environment=GOTRUE_RELOADING_POLLER_ENABLED=false
75-
76-
# Determines how much idle time must pass before triggering a reload. This
77-
# ensures only 1 reload operation occurs during a burst of config updates.
78-
Environment=GOTRUE_RELOADING_GRACE_PERIOD_INTERVAL=2s
79-
80-
{% if qemu_mode is defined and qemu_mode %}
81-
# v3 does not use filesystem notifications for config reloads.
82-
Environment=GOTRUE_RELOADING_NOTIFY_ENABLED=false
83-
{% else %}
84-
# v2 currently relies on notify support, so we will enable it until both v2 / v3
85-
# have migrated to strictly use signals across all projects. The default is true
86-
# in gotrue but we will set it defensively here.
87-
Environment=GOTRUE_RELOADING_NOTIFY_ENABLED=true
88-
{% endif %}
89-
9024
Slice=services.slice
9125

9226
[Install]
9327
WantedBy=multi-user.target
94-

testinfra/test_ami_nix.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,18 +374,12 @@ def is_healthy(ssh) -> bool:
374374
try:
375375
result = run_ssh_command(ssh, command)
376376
if not result["succeeded"]:
377-
info_text = ""
378-
info_command = f"sudo journalctl -b -u {service} -n 20 --no-pager"
379-
info_result = run_ssh_command(ssh, info_command)
380-
if info_result["succeeded"]:
381-
info_text = "\n" + info_result["stdout"].strip()
382-
383-
logger.warning(f"{service} not ready{info_text}")
377+
logger.warning(f"{service} not ready")
384378
return False
385-
386379
except Exception:
387380
logger.warning(f"Connection failed during {service} check")
388381
return False
382+
389383
return True
390384

391385
while True:

0 commit comments

Comments
 (0)