mirror of
https://github.com/minio/minio.git
synced 2025-02-09 04:38:09 -05:00
record err time when remote node is offline (#17262)
This commit is contained in:
parent
6fe028b7c5
commit
fb5ce3b87a
@ -99,6 +99,7 @@ type Client struct {
|
|||||||
|
|
||||||
sync.RWMutex // mutex for lastErr
|
sync.RWMutex // mutex for lastErr
|
||||||
lastErr error
|
lastErr error
|
||||||
|
lastErrTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type restError string
|
type restError string
|
||||||
@ -339,7 +340,7 @@ func (c *Client) LastConn() time.Time {
|
|||||||
func (c *Client) LastError() error {
|
func (c *Client) LastError() error {
|
||||||
c.RLock()
|
c.RLock()
|
||||||
defer c.RUnlock()
|
defer c.RUnlock()
|
||||||
return c.lastErr
|
return fmt.Errorf("[%s] %w", c.lastErrTime.Format(time.RFC3339), c.lastErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// computes the exponential backoff duration according to
|
// computes the exponential backoff duration according to
|
||||||
@ -370,6 +371,7 @@ func exponentialBackoffWait(r *rand.Rand, unit, cap time.Duration) func(uint) ti
|
|||||||
func (c *Client) MarkOffline(err error) bool {
|
func (c *Client) MarkOffline(err error) bool {
|
||||||
c.Lock()
|
c.Lock()
|
||||||
c.lastErr = err
|
c.lastErr = err
|
||||||
|
c.lastErrTime = time.Now()
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
// Start goroutine that will attempt to reconnect.
|
// Start goroutine that will attempt to reconnect.
|
||||||
// If server is already trying to reconnect this will have no effect.
|
// If server is already trying to reconnect this will have no effect.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user