Skip to content

Commit ead1c61

Browse files
authored
[client] Do not run up cmd if not needed in docker (#4508)
optimizes the NetBird client startup process by avoiding unnecessary login commands when the peer is already authenticated. The changes increase the default login timeout and expand the log message patterns used to detect successful authentication. - Increased default login timeout from 1 to 5 seconds for more reliable authentication detection - Enhanced log pattern matching to detect both registration and ready states - Added extended regex support for more flexible pattern matching
1 parent 55126f9 commit ead1c61

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

client/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ENV \
1818
NB_LOG_FILE="console,/var/log/netbird/client.log" \
1919
NB_DAEMON_ADDR="unix:///var/run/netbird.sock" \
2020
NB_ENTRYPOINT_SERVICE_TIMEOUT="5" \
21-
NB_ENTRYPOINT_LOGIN_TIMEOUT="1"
21+
NB_ENTRYPOINT_LOGIN_TIMEOUT="5"
2222

2323
ENTRYPOINT [ "/usr/local/bin/netbird-entrypoint.sh" ]
2424

client/netbird-entrypoint.sh

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

44
: ${NB_ENTRYPOINT_SERVICE_TIMEOUT:="5"}
5-
: ${NB_ENTRYPOINT_LOGIN_TIMEOUT:="1"}
5+
: ${NB_ENTRYPOINT_LOGIN_TIMEOUT:="5"}
66
NETBIRD_BIN="${NETBIRD_BIN:-"netbird"}"
77
export NB_LOG_FILE="${NB_LOG_FILE:-"console,/var/log/netbird/client.log"}"
88
service_pids=()
@@ -39,7 +39,7 @@ wait_for_message() {
3939
info "not waiting for log line ${message@Q} due to zero timeout."
4040
elif test -n "${log_file_path}"; then
4141
info "waiting for log line ${message@Q} for ${timeout} seconds..."
42-
grep -q "${message}" <(timeout "${timeout}" tail -F "${log_file_path}" 2>/dev/null)
42+
grep -E -q "${message}" <(timeout "${timeout}" tail -F "${log_file_path}" 2>/dev/null)
4343
else
4444
info "log file unsupported, sleeping for ${timeout} seconds..."
4545
sleep "${timeout}"
@@ -81,7 +81,7 @@ wait_for_daemon_startup() {
8181
login_if_needed() {
8282
local timeout="${1}"
8383

84-
if test -n "${log_file_path}" && wait_for_message "${timeout}" 'peer has been successfully registered'; then
84+
if test -n "${log_file_path}" && wait_for_message "${timeout}" 'peer has been successfully registered|management connection state READY'; then
8585
info "already logged in, skipping 'netbird up'..."
8686
else
8787
info "logging in..."

0 commit comments

Comments
 (0)