avoid 'panic' on mc admin update for single drive setup (#18876)

This commit is contained in:
Harshavardhana 2024-01-26 12:07:03 -08:00 committed by GitHub
parent 88837fb753
commit c88308cf0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -144,6 +144,7 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R
failedClients := make(map[int]struct{}) failedClients := make(map[int]struct{})
if globalIsDistErasure {
// Push binary to other servers // Push binary to other servers
for idx, nerr := range globalNotificationSys.VerifyBinary(ctx, u, sha256Sum, releaseInfo, binC) { for idx, nerr := range globalNotificationSys.VerifyBinary(ctx, u, sha256Sum, releaseInfo, binC) {
if nerr.Err != nil { if nerr.Err != nil {
@ -161,6 +162,7 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R
} }
} }
} }
}
if lrTime.Sub(currentReleaseTime) > 0 { if lrTime.Sub(currentReleaseTime) > 0 {
if err = verifyBinary(u, sha256Sum, releaseInfo, mode, bytes.NewReader(bin)); err != nil { if err = verifyBinary(u, sha256Sum, releaseInfo, mode, bytes.NewReader(bin)); err != nil {
@ -185,6 +187,7 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R
} }
if !dryRun { if !dryRun {
if globalIsDistErasure {
ng := WithNPeers(len(globalNotificationSys.peerClients)) ng := WithNPeers(len(globalNotificationSys.peerClients))
for idx, client := range globalNotificationSys.peerClients { for idx, client := range globalNotificationSys.peerClients {
_, ok := failedClients[idx] _, ok := failedClients[idx]
@ -213,7 +216,7 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R
} }
} }
} }
}
prs := peerResults[local] prs := peerResults[local]
if prs.Err == "" { if prs.Err == "" {
if err = commitBinary(); err != nil { if err = commitBinary(); err != nil {
@ -229,6 +232,7 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R
peerResults[local] = prs peerResults[local] = prs
} }
if globalIsDistErasure {
// Notify all other MinIO peers signal service. // Notify all other MinIO peers signal service.
ng := WithNPeers(len(globalNotificationSys.peerClients)) ng := WithNPeers(len(globalNotificationSys.peerClients))
for idx, client := range globalNotificationSys.peerClients { for idx, client := range globalNotificationSys.peerClients {
@ -260,6 +264,7 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R
} }
} }
} }
}
for _, pr := range peerResults { for _, pr := range peerResults {
updateStatus.Results = append(updateStatus.Results, pr) updateStatus.Results = append(updateStatus.Results, pr)
@ -538,8 +543,7 @@ func (a adminAPIHandlers) ServiceV2Handler(w http.ResponseWriter, r *http.Reques
} }
// Notify all other MinIO peers signal service. // Notify all other MinIO peers signal service.
nerrs := globalNotificationSys.SignalServiceV2(serviceSig, dryRun) srvResult := serviceResult{Action: act, Results: []servicePeerResult{}}
srvResult := serviceResult{Action: act, Results: make([]servicePeerResult, 0, len(nerrs))}
process := act == madmin.ServiceActionRestart || act == madmin.ServiceActionStop process := act == madmin.ServiceActionRestart || act == madmin.ServiceActionStop
if process { if process {
@ -554,7 +558,8 @@ func (a adminAPIHandlers) ServiceV2Handler(w http.ResponseWriter, r *http.Reques
}) })
} }
for _, nerr := range nerrs { if globalIsDistErasure {
for _, nerr := range globalNotificationSys.SignalServiceV2(serviceSig, dryRun) {
if nerr.Err != nil && process { if nerr.Err != nil && process {
waitingDrives := map[string]madmin.DiskMetrics{} waitingDrives := map[string]madmin.DiskMetrics{}
jerr := json.Unmarshal([]byte(nerr.Err.Error()), &waitingDrives) jerr := json.Unmarshal([]byte(nerr.Err.Error()), &waitingDrives)
@ -575,6 +580,7 @@ func (a adminAPIHandlers) ServiceV2Handler(w http.ResponseWriter, r *http.Reques
Err: errStr, Err: errStr,
}) })
} }
}
srvResult.DryRun = dryRun srvResult.DryRun = dryRun