mirror of
https://github.com/minio/minio.git
synced 2024-12-25 06:35:56 -05:00
Do not allow parallel upgrade in one server (#14782)
It is wasteful to allow parallel upgrades of MinIO server. This also generates weird error invoked by selfupdate module when it happens such as: 'rename /opt/bin/.minio.old /opt/bin/..minio.old.old'
This commit is contained in:
parent
6bc3c74c0c
commit
cf4cf58faf
@ -33,6 +33,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
xhttp "github.com/minio/minio/internal/http"
|
xhttp "github.com/minio/minio/internal/http"
|
||||||
@ -515,7 +516,14 @@ func getUpdateReaderFromURL(u *url.URL, transport http.RoundTripper, mode string
|
|||||||
return resp.Body, nil
|
return resp.Body, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var updateInProgress uint32
|
||||||
|
|
||||||
func doUpdate(u *url.URL, lrTime time.Time, sha256Sum []byte, releaseInfo string, mode string) (err error) {
|
func doUpdate(u *url.URL, lrTime time.Time, sha256Sum []byte, releaseInfo string, mode string) (err error) {
|
||||||
|
if !atomic.CompareAndSwapUint32(&updateInProgress, 0, 1) {
|
||||||
|
return errors.New("update already in progress")
|
||||||
|
}
|
||||||
|
defer atomic.StoreUint32(&updateInProgress, 0)
|
||||||
|
|
||||||
transport := getUpdateTransport(30 * time.Second)
|
transport := getUpdateTransport(30 * time.Second)
|
||||||
var reader io.ReadCloser
|
var reader io.ReadCloser
|
||||||
if u.Scheme == "https" || u.Scheme == "http" {
|
if u.Scheme == "https" || u.Scheme == "http" {
|
||||||
|
Loading…
Reference in New Issue
Block a user