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:
Anis Elleuch 2022-04-20 14:18:21 +01:00 committed by GitHub
parent 6bc3c74c0c
commit cf4cf58faf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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" {