mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-29 15:59:10 +01:00
Merge branch 'embed-start-timeout-auth' into embed-multi-client-knobs
This commit is contained in:
+12
-2
@@ -300,13 +300,23 @@ func (c *Client) Start(startCtx context.Context) error {
|
||||
// nolint:staticcheck
|
||||
ctx = context.WithValue(ctx, system.DeviceNameCtxKey, c.deviceName)
|
||||
|
||||
authClient, err := auth.NewAuth(ctx, c.config.PrivateKey, c.config.ManagementURL, c.config)
|
||||
// Authentication runs on startCtx, not the client's own context. Both
|
||||
// calls retry, and a management endpoint that accepts connections but
|
||||
// never completes a stream leaves them retrying with no deadline of their
|
||||
// own, so a caller's start timeout has to reach them. Neither outlives
|
||||
// startup: authClient is closed below.
|
||||
// Carry the device name onto the start context: registration happens during
|
||||
// login and reads it from there, so authenticating on a context without it
|
||||
// would register every client under the host's hostname instead.
|
||||
authCtx := context.WithValue(startCtx, system.DeviceNameCtxKey, c.deviceName) //nolint:staticcheck
|
||||
|
||||
authClient, err := auth.NewAuth(authCtx, c.config.PrivateKey, c.config.ManagementURL, c.config)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create auth client: %w", err)
|
||||
}
|
||||
defer authClient.Close()
|
||||
|
||||
if err, _ := authClient.Login(ctx, c.setupKey, c.jwtToken); err != nil {
|
||||
if err, _ := authClient.Login(authCtx, c.setupKey, c.jwtToken); err != nil {
|
||||
return fmt.Errorf("login: %w", err)
|
||||
}
|
||||
client := internal.NewConnectClient(ctx, c.config, c.recorder)
|
||||
|
||||
Reference in New Issue
Block a user