Skip to content

Commit fd9d430

Browse files
authored
[client] Simplify entrypoint by running netbird up unconditionally (#5652)
1 parent 91f0d5c commit fd9d430

4 files changed

Lines changed: 7 additions & 31 deletions

File tree

client/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ ENV \
1717
NETBIRD_BIN="/usr/local/bin/netbird" \
1818
NB_LOG_FILE="console,/var/log/netbird/client.log" \
1919
NB_DAEMON_ADDR="unix:///var/run/netbird.sock" \
20-
NB_ENTRYPOINT_SERVICE_TIMEOUT="30" \
21-
NB_ENTRYPOINT_LOGIN_TIMEOUT="30"
20+
NB_ENTRYPOINT_SERVICE_TIMEOUT="30"
2221

2322
ENTRYPOINT [ "/usr/local/bin/netbird-entrypoint.sh" ]
2423

client/Dockerfile-rootless

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ ENV \
2323
NB_DAEMON_ADDR="unix:///var/lib/netbird/netbird.sock" \
2424
NB_LOG_FILE="console,/var/lib/netbird/client.log" \
2525
NB_DISABLE_DNS="true" \
26-
NB_ENTRYPOINT_SERVICE_TIMEOUT="30" \
27-
NB_ENTRYPOINT_LOGIN_TIMEOUT="30"
26+
NB_ENTRYPOINT_SERVICE_TIMEOUT="30"
2827

2928
ENTRYPOINT [ "/usr/local/bin/netbird-entrypoint.sh" ]
3029

client/cmd/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func runHealthCheck(cmd *cobra.Command) error {
218218
ctx := internal.CtxInitState(cmd.Context())
219219

220220
isStartup := check == "startup"
221-
resp, err := getStatus(ctx, isStartup, isStartup)
221+
resp, err := getStatus(ctx, isStartup, false)
222222
if err != nil {
223223
return err
224224
}

client/netbird-entrypoint.sh

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
set -eEuo pipefail
33

44
: ${NB_ENTRYPOINT_SERVICE_TIMEOUT:="30"}
5-
: ${NB_ENTRYPOINT_LOGIN_TIMEOUT:="30"}
65
NETBIRD_BIN="${NETBIRD_BIN:-"netbird"}"
76
export NB_LOG_FILE="${NB_LOG_FILE:-"console,/var/log/netbird/client.log"}"
87
service_pids=()
@@ -51,31 +50,10 @@ wait_for_daemon_startup() {
5150
exit 1
5251
}
5352

54-
login_if_needed() {
55-
local timeout="${1}"
56-
57-
if "${NETBIRD_BIN}" status --check ready 2>/dev/null; then
58-
info "already logged in, skipping 'netbird up'..."
59-
return
60-
fi
61-
62-
if [[ "${timeout}" -eq 0 ]]; then
63-
info "logging in..."
64-
"${NETBIRD_BIN}" up
65-
return
66-
fi
67-
68-
local deadline=$((SECONDS + timeout))
69-
while [[ "${SECONDS}" -lt "${deadline}" ]]; do
70-
if "${NETBIRD_BIN}" status --check ready 2>/dev/null; then
71-
info "already logged in, skipping 'netbird up'..."
72-
return
73-
fi
74-
sleep 1
75-
done
76-
77-
info "logging in..."
53+
connect() {
54+
info "running 'netbird up'..."
7855
"${NETBIRD_BIN}" up
56+
return $?
7957
}
8058

8159
main() {
@@ -85,7 +63,7 @@ main() {
8563
info "registered new service process 'netbird service run', currently running: ${service_pids[@]@Q}"
8664

8765
wait_for_daemon_startup "${NB_ENTRYPOINT_SERVICE_TIMEOUT}"
88-
login_if_needed "${NB_ENTRYPOINT_LOGIN_TIMEOUT}"
66+
connect
8967

9068
wait "${service_pids[@]}"
9169
}

0 commit comments

Comments
 (0)