mirror of
https://github.com/minio/minio.git
synced 2025-02-02 17:35:58 -05:00
avoid 'panic' on mc admin update for single drive setup (#18876)
This commit is contained in:
parent
88837fb753
commit
c88308cf0e
@ -144,20 +144,22 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R
|
|||||||
|
|
||||||
failedClients := make(map[int]struct{})
|
failedClients := make(map[int]struct{})
|
||||||
|
|
||||||
// Push binary to other servers
|
if globalIsDistErasure {
|
||||||
for idx, nerr := range globalNotificationSys.VerifyBinary(ctx, u, sha256Sum, releaseInfo, binC) {
|
// Push binary to other servers
|
||||||
if nerr.Err != nil {
|
for idx, nerr := range globalNotificationSys.VerifyBinary(ctx, u, sha256Sum, releaseInfo, binC) {
|
||||||
peerResults[nerr.Host.String()] = madmin.ServerPeerUpdateStatus{
|
if nerr.Err != nil {
|
||||||
Host: nerr.Host.String(),
|
peerResults[nerr.Host.String()] = madmin.ServerPeerUpdateStatus{
|
||||||
Err: nerr.Err.Error(),
|
Host: nerr.Host.String(),
|
||||||
CurrentVersion: Version,
|
Err: nerr.Err.Error(),
|
||||||
}
|
CurrentVersion: Version,
|
||||||
failedClients[idx] = struct{}{}
|
}
|
||||||
} else {
|
failedClients[idx] = struct{}{}
|
||||||
peerResults[nerr.Host.String()] = madmin.ServerPeerUpdateStatus{
|
} else {
|
||||||
Host: nerr.Host.String(),
|
peerResults[nerr.Host.String()] = madmin.ServerPeerUpdateStatus{
|
||||||
CurrentVersion: Version,
|
Host: nerr.Host.String(),
|
||||||
UpdatedVersion: lrTime.Format(minioReleaseTagTimeLayout),
|
CurrentVersion: Version,
|
||||||
|
UpdatedVersion: lrTime.Format(minioReleaseTagTimeLayout),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,35 +187,36 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !dryRun {
|
if !dryRun {
|
||||||
ng := WithNPeers(len(globalNotificationSys.peerClients))
|
if globalIsDistErasure {
|
||||||
for idx, client := range globalNotificationSys.peerClients {
|
ng := WithNPeers(len(globalNotificationSys.peerClients))
|
||||||
_, ok := failedClients[idx]
|
for idx, client := range globalNotificationSys.peerClients {
|
||||||
if ok {
|
_, ok := failedClients[idx]
|
||||||
continue
|
|
||||||
}
|
|
||||||
client := client
|
|
||||||
ng.Go(ctx, func() error {
|
|
||||||
return client.CommitBinary(ctx)
|
|
||||||
}, idx, *client.host)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, nerr := range ng.Wait() {
|
|
||||||
if nerr.Err != nil {
|
|
||||||
prs, ok := peerResults[nerr.Host.String()]
|
|
||||||
if ok {
|
if ok {
|
||||||
prs.Err = nerr.Err.Error()
|
continue
|
||||||
peerResults[nerr.Host.String()] = prs
|
}
|
||||||
} else {
|
client := client
|
||||||
peerResults[nerr.Host.String()] = madmin.ServerPeerUpdateStatus{
|
ng.Go(ctx, func() error {
|
||||||
Host: nerr.Host.String(),
|
return client.CommitBinary(ctx)
|
||||||
Err: nerr.Err.Error(),
|
}, idx, *client.host)
|
||||||
CurrentVersion: Version,
|
}
|
||||||
UpdatedVersion: lrTime.Format(minioReleaseTagTimeLayout),
|
|
||||||
|
for _, nerr := range ng.Wait() {
|
||||||
|
if nerr.Err != nil {
|
||||||
|
prs, ok := peerResults[nerr.Host.String()]
|
||||||
|
if ok {
|
||||||
|
prs.Err = nerr.Err.Error()
|
||||||
|
peerResults[nerr.Host.String()] = prs
|
||||||
|
} else {
|
||||||
|
peerResults[nerr.Host.String()] = madmin.ServerPeerUpdateStatus{
|
||||||
|
Host: nerr.Host.String(),
|
||||||
|
Err: nerr.Err.Error(),
|
||||||
|
CurrentVersion: Version,
|
||||||
|
UpdatedVersion: lrTime.Format(minioReleaseTagTimeLayout),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prs := peerResults[local]
|
prs := peerResults[local]
|
||||||
if prs.Err == "" {
|
if prs.Err == "" {
|
||||||
if err = commitBinary(); err != nil {
|
if err = commitBinary(); err != nil {
|
||||||
@ -229,35 +232,37 @@ func (a adminAPIHandlers) ServerUpdateV2Handler(w http.ResponseWriter, r *http.R
|
|||||||
peerResults[local] = prs
|
peerResults[local] = prs
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify all other MinIO peers signal service.
|
if globalIsDistErasure {
|
||||||
ng := WithNPeers(len(globalNotificationSys.peerClients))
|
// Notify all other MinIO peers signal service.
|
||||||
for idx, client := range globalNotificationSys.peerClients {
|
ng := WithNPeers(len(globalNotificationSys.peerClients))
|
||||||
_, ok := failedClients[idx]
|
for idx, client := range globalNotificationSys.peerClients {
|
||||||
if ok {
|
_, ok := failedClients[idx]
|
||||||
continue
|
if ok {
|
||||||
}
|
|
||||||
client := client
|
|
||||||
ng.Go(ctx, func() error {
|
|
||||||
prs, ok := peerResults[client.String()]
|
|
||||||
if ok && prs.CurrentVersion != prs.UpdatedVersion && prs.UpdatedVersion != "" {
|
|
||||||
return client.SignalService(serviceRestart, "", dryRun)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}, idx, *client.host)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, nerr := range ng.Wait() {
|
|
||||||
if nerr.Err != nil {
|
|
||||||
waitingDrives := map[string]madmin.DiskMetrics{}
|
|
||||||
jerr := json.Unmarshal([]byte(nerr.Err.Error()), &waitingDrives)
|
|
||||||
if jerr == nil {
|
|
||||||
prs, ok := peerResults[nerr.Host.String()]
|
|
||||||
if ok {
|
|
||||||
prs.WaitingDrives = waitingDrives
|
|
||||||
peerResults[nerr.Host.String()] = prs
|
|
||||||
}
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
client := client
|
||||||
|
ng.Go(ctx, func() error {
|
||||||
|
prs, ok := peerResults[client.String()]
|
||||||
|
if ok && prs.CurrentVersion != prs.UpdatedVersion && prs.UpdatedVersion != "" {
|
||||||
|
return client.SignalService(serviceRestart, "", dryRun)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}, idx, *client.host)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, nerr := range ng.Wait() {
|
||||||
|
if nerr.Err != nil {
|
||||||
|
waitingDrives := map[string]madmin.DiskMetrics{}
|
||||||
|
jerr := json.Unmarshal([]byte(nerr.Err.Error()), &waitingDrives)
|
||||||
|
if jerr == nil {
|
||||||
|
prs, ok := peerResults[nerr.Host.String()]
|
||||||
|
if ok {
|
||||||
|
prs.WaitingDrives = waitingDrives
|
||||||
|
peerResults[nerr.Host.String()] = prs
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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,26 +558,28 @@ func (a adminAPIHandlers) ServiceV2Handler(w http.ResponseWriter, r *http.Reques
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, nerr := range nerrs {
|
if globalIsDistErasure {
|
||||||
if nerr.Err != nil && process {
|
for _, nerr := range globalNotificationSys.SignalServiceV2(serviceSig, dryRun) {
|
||||||
waitingDrives := map[string]madmin.DiskMetrics{}
|
if nerr.Err != nil && process {
|
||||||
jerr := json.Unmarshal([]byte(nerr.Err.Error()), &waitingDrives)
|
waitingDrives := map[string]madmin.DiskMetrics{}
|
||||||
if jerr == nil {
|
jerr := json.Unmarshal([]byte(nerr.Err.Error()), &waitingDrives)
|
||||||
srvResult.Results = append(srvResult.Results, servicePeerResult{
|
if jerr == nil {
|
||||||
Host: nerr.Host.String(),
|
srvResult.Results = append(srvResult.Results, servicePeerResult{
|
||||||
WaitingDrives: waitingDrives,
|
Host: nerr.Host.String(),
|
||||||
})
|
WaitingDrives: waitingDrives,
|
||||||
continue
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
errStr := ""
|
||||||
|
if nerr.Err != nil {
|
||||||
|
errStr = nerr.Err.Error()
|
||||||
|
}
|
||||||
|
srvResult.Results = append(srvResult.Results, servicePeerResult{
|
||||||
|
Host: nerr.Host.String(),
|
||||||
|
Err: errStr,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
errStr := ""
|
|
||||||
if nerr.Err != nil {
|
|
||||||
errStr = nerr.Err.Error()
|
|
||||||
}
|
|
||||||
srvResult.Results = append(srvResult.Results, servicePeerResult{
|
|
||||||
Host: nerr.Host.String(),
|
|
||||||
Err: errStr,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
srvResult.DryRun = dryRun
|
srvResult.DryRun = dryRun
|
||||||
|
Loading…
x
Reference in New Issue
Block a user