mirror of https://github.com/minio/minio.git
Wait one minute after startup to restart decommissioning (#19645)
Typically not all drives are connected, so we delay 3 minutes before resuming. This greatly reduces risk of starting to list unconnected drives, or drives we risk being disconnected soon. This delay is not applied when starting with an admin call.
This commit is contained in:
parent
08ff702434
commit
dbfb5e797b
|
@ -535,6 +535,10 @@ func (z *erasureServerPools) Init(ctx context.Context) error {
|
||||||
|
|
||||||
if len(poolIndices) > 0 && globalEndpoints[poolIndices[0]].Endpoints[0].IsLocal {
|
if len(poolIndices) > 0 && globalEndpoints[poolIndices[0]].Endpoints[0].IsLocal {
|
||||||
go func() {
|
go func() {
|
||||||
|
// Resume decommissioning of pools, but wait 3 minutes for cluster to stabilize.
|
||||||
|
if err := sleepContext(ctx, 3*time.Minute); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
for {
|
for {
|
||||||
if err := z.Decommission(ctx, poolIndices...); err != nil {
|
if err := z.Decommission(ctx, poolIndices...); err != nil {
|
||||||
|
|
18
cmd/utils.go
18
cmd/utils.go
|
@ -1127,16 +1127,12 @@ func ptr[T any](a T) *T {
|
||||||
return &a
|
return &a
|
||||||
}
|
}
|
||||||
|
|
||||||
func max(a, b int) int {
|
// sleepContext sleeps for d duration or until ctx is done.
|
||||||
if a > b {
|
func sleepContext(ctx context.Context, d time.Duration) error {
|
||||||
return a
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return ctx.Err()
|
||||||
|
case <-time.After(d):
|
||||||
}
|
}
|
||||||
return b
|
return nil
|
||||||
}
|
|
||||||
|
|
||||||
func min(a, b int) int {
|
|
||||||
if a < b {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue