mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-22 21:39:08 +02:00
session-extend: drop dead retry loop in mgmClient.ExtendAuthSession
The backoff loop only retried on codes.Canceled, but mgmCtx was derived from context.Background() and never cancelled by anything — so every real error path (Unavailable, DeadlineExceeded, etc.) went through backoff.Permanent on the first attempt. The loop was a no-op wrapper that just held the call open for the daemon's lifetime regardless of shutdown. Replace with a single context.WithTimeout(c.ctx, ConnectTimeout) call. Daemon shutdown now interrupts the RPC; behaviour on real errors is unchanged.
This commit is contained in:
@@ -630,26 +630,14 @@ func (c *GrpcClient) ExtendAuthSession(sysInfo *system.Info, jwtToken string) (*
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var resp *proto.EncryptedMessage
|
mgmCtx, cancel := context.WithTimeout(c.ctx, ConnectTimeout)
|
||||||
operation := func() error {
|
defer cancel()
|
||||||
mgmCtx, cancel := context.WithTimeout(context.Background(), ConnectTimeout)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
var err error
|
resp, err := c.realClient.ExtendAuthSession(mgmCtx, &proto.EncryptedMessage{
|
||||||
resp, err = c.realClient.ExtendAuthSession(mgmCtx, &proto.EncryptedMessage{
|
WgPubKey: c.key.PublicKey().String(),
|
||||||
WgPubKey: c.key.PublicKey().String(),
|
Body: reqBody,
|
||||||
Body: reqBody,
|
})
|
||||||
})
|
if err != nil {
|
||||||
if err != nil {
|
|
||||||
if s, ok := gstatus.FromError(err); ok && s.Code() == codes.Canceled {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return backoff.Permanent(err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := backoff.Retry(operation, nbgrpc.Backoff(c.ctx)); err != nil {
|
|
||||||
log.Errorf("failed to extend auth session on Management Service: %v", err)
|
log.Errorf("failed to extend auth session on Management Service: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user