mirror of
https://github.com/minio/minio.git
synced 2025-04-18 17:55:28 -04:00
Fix locking in some admin APIs: (#5438)
- read lock for get config - write lock for update creds - write lock for format file
This commit is contained in:
parent
a003de72bf
commit
254b05e314
@ -575,6 +575,16 @@ func (a adminAPIHandlers) GetConfigHandler(w http.ResponseWriter, r *http.Reques
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Take a read lock on minio/config.json. NB minio is a
|
||||||
|
// reserved bucket name and wouldn't conflict with normal
|
||||||
|
// object operations.
|
||||||
|
configLock := globalNSMutex.NewNSLock(minioReservedBucket, minioConfigFile)
|
||||||
|
if configLock.GetRLock(globalObjectTimeout) != nil {
|
||||||
|
writeErrorResponseJSON(w, ErrOperationTimedOut, r.URL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer configLock.RUnlock()
|
||||||
|
|
||||||
// Get config.json - in distributed mode, the configuration
|
// Get config.json - in distributed mode, the configuration
|
||||||
// occurring on a quorum of the servers is returned.
|
// occurring on a quorum of the servers is returned.
|
||||||
configBytes, err := getPeerConfig(globalAdminPeers)
|
configBytes, err := getPeerConfig(globalAdminPeers)
|
||||||
@ -784,6 +794,15 @@ func (a adminAPIHandlers) UpdateCredentialsHandler(w http.ResponseWriter,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Take a lock on minio/config.json. Prevents concurrent
|
||||||
|
// config file/credentials updates.
|
||||||
|
configLock := globalNSMutex.NewNSLock(minioReservedBucket, minioConfigFile)
|
||||||
|
if configLock.GetLock(globalObjectTimeout) != nil {
|
||||||
|
writeErrorResponseJSON(w, ErrOperationTimedOut, r.URL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer configLock.Unlock()
|
||||||
|
|
||||||
// Notify all other Minio peers to update credentials
|
// Notify all other Minio peers to update credentials
|
||||||
updateErrs := updateCredsOnPeers(creds)
|
updateErrs := updateCredsOnPeers(creds)
|
||||||
for peer, err := range updateErrs {
|
for peer, err := range updateErrs {
|
||||||
|
@ -528,6 +528,13 @@ func (h *healSequence) healDiskFormat() error {
|
|||||||
return errServerNotInitialized
|
return errServerNotInitialized
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Acquire lock on format.json
|
||||||
|
formatLock := globalNSMutex.NewNSLock(minioMetaBucket, formatConfigFile)
|
||||||
|
if err := formatLock.GetLock(globalHealingTimeout); err != nil {
|
||||||
|
return errFnHealFromAPIErr(err)
|
||||||
|
}
|
||||||
|
defer formatLock.Unlock()
|
||||||
|
|
||||||
// Create a new set of storage instances to heal format.json.
|
// Create a new set of storage instances to heal format.json.
|
||||||
bootstrapDisks, err := initStorageDisks(globalEndpoints)
|
bootstrapDisks, err := initStorageDisks(globalEndpoints)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user