|
|
@ -982,16 +982,13 @@ func (a adminAPIHandlers) TraceHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
|
|
|
|
w.Header().Set(xhttp.ContentType, "text/event-stream") |
|
|
|
w.Header().Set(xhttp.ContentType, "text/event-stream") |
|
|
|
|
|
|
|
|
|
|
|
doneCh := make(chan struct{}) |
|
|
|
|
|
|
|
defer close(doneCh) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Trace Publisher and peer-trace-client uses nonblocking send and hence does not wait for slow receivers.
|
|
|
|
// Trace Publisher and peer-trace-client uses nonblocking send and hence does not wait for slow receivers.
|
|
|
|
// Use buffered channel to take care of burst sends or slow w.Write()
|
|
|
|
// Use buffered channel to take care of burst sends or slow w.Write()
|
|
|
|
traceCh := make(chan interface{}, 4000) |
|
|
|
traceCh := make(chan interface{}, 4000) |
|
|
|
|
|
|
|
|
|
|
|
peers := getRestClients(globalEndpoints) |
|
|
|
peers := getRestClients(globalEndpoints) |
|
|
|
|
|
|
|
|
|
|
|
globalHTTPTrace.Subscribe(traceCh, doneCh, func(entry interface{}) bool { |
|
|
|
globalHTTPTrace.Subscribe(traceCh, ctx.Done(), func(entry interface{}) bool { |
|
|
|
return mustTrace(entry, trcAll, trcErr) |
|
|
|
return mustTrace(entry, trcAll, trcErr) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -999,7 +996,7 @@ func (a adminAPIHandlers) TraceHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
if peer == nil { |
|
|
|
if peer == nil { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
peer.Trace(traceCh, doneCh, trcAll, trcErr) |
|
|
|
peer.Trace(traceCh, ctx.Done(), trcAll, trcErr) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
keepAliveTicker := time.NewTicker(500 * time.Millisecond) |
|
|
|
keepAliveTicker := time.NewTicker(500 * time.Millisecond) |
|
|
@ -1018,7 +1015,7 @@ func (a adminAPIHandlers) TraceHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
w.(http.Flusher).Flush() |
|
|
|
w.(http.Flusher).Flush() |
|
|
|
case <-GlobalServiceDoneCh: |
|
|
|
case <-ctx.Done(): |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1052,20 +1049,18 @@ func (a adminAPIHandlers) ConsoleLogHandler(w http.ResponseWriter, r *http.Reque |
|
|
|
w.Header().Add("Connection", "close") |
|
|
|
w.Header().Add("Connection", "close") |
|
|
|
w.Header().Set(xhttp.ContentType, "text/event-stream") |
|
|
|
w.Header().Set(xhttp.ContentType, "text/event-stream") |
|
|
|
|
|
|
|
|
|
|
|
doneCh := make(chan struct{}) |
|
|
|
|
|
|
|
defer close(doneCh) |
|
|
|
|
|
|
|
logCh := make(chan interface{}, 4000) |
|
|
|
logCh := make(chan interface{}, 4000) |
|
|
|
|
|
|
|
|
|
|
|
peers := getRestClients(globalEndpoints) |
|
|
|
peers := getRestClients(globalEndpoints) |
|
|
|
|
|
|
|
|
|
|
|
globalConsoleSys.Subscribe(logCh, doneCh, node, limitLines, logKind, nil) |
|
|
|
globalConsoleSys.Subscribe(logCh, ctx.Done(), node, limitLines, logKind, nil) |
|
|
|
|
|
|
|
|
|
|
|
for _, peer := range peers { |
|
|
|
for _, peer := range peers { |
|
|
|
if peer == nil { |
|
|
|
if peer == nil { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
if node == "" || strings.EqualFold(peer.host.Name, node) { |
|
|
|
if node == "" || strings.EqualFold(peer.host.Name, node) { |
|
|
|
peer.ConsoleLog(logCh, doneCh) |
|
|
|
peer.ConsoleLog(logCh, ctx.Done()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1089,7 +1084,7 @@ func (a adminAPIHandlers) ConsoleLogHandler(w http.ResponseWriter, r *http.Reque |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
w.(http.Flusher).Flush() |
|
|
|
w.(http.Flusher).Flush() |
|
|
|
case <-GlobalServiceDoneCh: |
|
|
|
case <-ctx.Done(): |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1175,65 +1170,39 @@ func (a adminAPIHandlers) OBDInfoHandler(w http.ResponseWriter, r *http.Request) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vars := mux.Vars(r) |
|
|
|
vars := mux.Vars(r) |
|
|
|
pulse := make(chan struct{}) |
|
|
|
|
|
|
|
obdDone := make(chan struct{}) |
|
|
|
|
|
|
|
obdInfo := madmin.OBDInfo{} |
|
|
|
obdInfo := madmin.OBDInfo{} |
|
|
|
|
|
|
|
obdInfoCh := make(chan madmin.OBDInfo) |
|
|
|
|
|
|
|
|
|
|
|
enc := json.NewEncoder(w) |
|
|
|
enc := json.NewEncoder(w) |
|
|
|
doPartialWrite := func() { |
|
|
|
partialWrite := func(oinfo madmin.OBDInfo) { |
|
|
|
logger.LogIf(ctx, enc.Encode(obdInfo)) |
|
|
|
obdInfoCh <- oinfo |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
partialWrite := func() { |
|
|
|
|
|
|
|
pulse <- struct{}{} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
finish := func() { |
|
|
|
setCommonHeaders(w) |
|
|
|
obdDone <- struct{}{} |
|
|
|
w.Header().Set(xhttp.ContentType, "text/event-stream") |
|
|
|
} |
|
|
|
w.WriteHeader(http.StatusOK) |
|
|
|
|
|
|
|
|
|
|
|
errResp := func(err error) { |
|
|
|
errResp := func(err error) { |
|
|
|
errorResponse := getAPIErrorResponse(ctx, toAdminAPIErr(ctx, err), r.URL.String(), |
|
|
|
errorResponse := getAPIErrorResponse(ctx, toAdminAPIErr(ctx, err), r.URL.String(), |
|
|
|
w.Header().Get(xhttp.AmzRequestID), globalDeploymentID) |
|
|
|
w.Header().Get(xhttp.AmzRequestID), globalDeploymentID) |
|
|
|
encodedErrorResponse := encodeResponse(errorResponse) |
|
|
|
encodedErrorResponse := encodeResponse(errorResponse) |
|
|
|
obdInfo.Error = string(encodedErrorResponse) |
|
|
|
obdInfo.Error = string(encodedErrorResponse) |
|
|
|
finish() |
|
|
|
logger.LogIf(ctx, enc.Encode(obdInfo)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
deadline := 3600 * time.Second |
|
|
|
deadline := 3600 * time.Second |
|
|
|
deadlineStr := r.URL.Query().Get("deadline") |
|
|
|
if dstr := r.URL.Query().Get("deadline"); dstr != "" { |
|
|
|
if deadlineStr != "" { |
|
|
|
|
|
|
|
var err error |
|
|
|
var err error |
|
|
|
deadline, err = time.ParseDuration(deadlineStr) |
|
|
|
deadline, err = time.ParseDuration(dstr) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
errResp(err) |
|
|
|
errResp(err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
deadlinedCtx, cancel := context.WithDeadline(ctx, time.Now().Add(deadline)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setCommonHeaders(w) |
|
|
|
deadlinedCtx, cancel := context.WithTimeout(ctx, deadline) |
|
|
|
w.Header().Set(xhttp.ContentType, string(mimeJSON)) |
|
|
|
|
|
|
|
w.WriteHeader(http.StatusOK) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ticker := time.NewTicker(30 * time.Second) |
|
|
|
defer cancel() |
|
|
|
defer ticker.Stop() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
go func() { |
|
|
|
|
|
|
|
loop: |
|
|
|
|
|
|
|
for { |
|
|
|
|
|
|
|
select { |
|
|
|
|
|
|
|
case <-ticker.C: |
|
|
|
|
|
|
|
doPartialWrite() |
|
|
|
|
|
|
|
case <-pulse: |
|
|
|
|
|
|
|
doPartialWrite() |
|
|
|
|
|
|
|
case <-obdDone: |
|
|
|
|
|
|
|
break loop |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
w.(http.Flusher).Flush() |
|
|
|
|
|
|
|
cancel() |
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nsLock := objectAPI.NewNSLock(deadlinedCtx, minioMetaBucket, "obd-in-progress") |
|
|
|
nsLock := objectAPI.NewNSLock(deadlinedCtx, minioMetaBucket, "obd-in-progress") |
|
|
|
if err := nsLock.GetLock(newDynamicTimeout(deadline, deadline)); err != nil { // returns a locked lock
|
|
|
|
if err := nsLock.GetLock(newDynamicTimeout(deadline, deadline)); err != nil { // returns a locked lock
|
|
|
@ -1242,12 +1211,15 @@ func (a adminAPIHandlers) OBDInfoHandler(w http.ResponseWriter, r *http.Request) |
|
|
|
} |
|
|
|
} |
|
|
|
defer nsLock.Unlock() |
|
|
|
defer nsLock.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
go func() { |
|
|
|
|
|
|
|
defer close(obdInfoCh) |
|
|
|
|
|
|
|
|
|
|
|
if cpu, ok := vars["syscpu"]; ok && cpu == "true" { |
|
|
|
if cpu, ok := vars["syscpu"]; ok && cpu == "true" { |
|
|
|
cpuInfo := getLocalCPUOBDInfo(deadlinedCtx) |
|
|
|
cpuInfo := getLocalCPUOBDInfo(deadlinedCtx) |
|
|
|
|
|
|
|
|
|
|
|
obdInfo.Sys.CPUInfo = append(obdInfo.Sys.CPUInfo, cpuInfo) |
|
|
|
obdInfo.Sys.CPUInfo = append(obdInfo.Sys.CPUInfo, cpuInfo) |
|
|
|
obdInfo.Sys.CPUInfo = append(obdInfo.Sys.CPUInfo, globalNotificationSys.CPUOBDInfo(deadlinedCtx)...) |
|
|
|
obdInfo.Sys.CPUInfo = append(obdInfo.Sys.CPUInfo, globalNotificationSys.CPUOBDInfo(deadlinedCtx)...) |
|
|
|
partialWrite() |
|
|
|
partialWrite(obdInfo) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if diskHw, ok := vars["sysdiskhw"]; ok && diskHw == "true" { |
|
|
|
if diskHw, ok := vars["sysdiskhw"]; ok && diskHw == "true" { |
|
|
@ -1255,7 +1227,7 @@ func (a adminAPIHandlers) OBDInfoHandler(w http.ResponseWriter, r *http.Request) |
|
|
|
|
|
|
|
|
|
|
|
obdInfo.Sys.DiskHwInfo = append(obdInfo.Sys.DiskHwInfo, diskHwInfo) |
|
|
|
obdInfo.Sys.DiskHwInfo = append(obdInfo.Sys.DiskHwInfo, diskHwInfo) |
|
|
|
obdInfo.Sys.DiskHwInfo = append(obdInfo.Sys.DiskHwInfo, globalNotificationSys.DiskHwOBDInfo(deadlinedCtx)...) |
|
|
|
obdInfo.Sys.DiskHwInfo = append(obdInfo.Sys.DiskHwInfo, globalNotificationSys.DiskHwOBDInfo(deadlinedCtx)...) |
|
|
|
partialWrite() |
|
|
|
partialWrite(obdInfo) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if osInfo, ok := vars["sysosinfo"]; ok && osInfo == "true" { |
|
|
|
if osInfo, ok := vars["sysosinfo"]; ok && osInfo == "true" { |
|
|
@ -1263,7 +1235,7 @@ func (a adminAPIHandlers) OBDInfoHandler(w http.ResponseWriter, r *http.Request) |
|
|
|
|
|
|
|
|
|
|
|
obdInfo.Sys.OsInfo = append(obdInfo.Sys.OsInfo, osInfo) |
|
|
|
obdInfo.Sys.OsInfo = append(obdInfo.Sys.OsInfo, osInfo) |
|
|
|
obdInfo.Sys.OsInfo = append(obdInfo.Sys.OsInfo, globalNotificationSys.OsOBDInfo(deadlinedCtx)...) |
|
|
|
obdInfo.Sys.OsInfo = append(obdInfo.Sys.OsInfo, globalNotificationSys.OsOBDInfo(deadlinedCtx)...) |
|
|
|
partialWrite() |
|
|
|
partialWrite(obdInfo) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if mem, ok := vars["sysmem"]; ok && mem == "true" { |
|
|
|
if mem, ok := vars["sysmem"]; ok && mem == "true" { |
|
|
@ -1271,7 +1243,7 @@ func (a adminAPIHandlers) OBDInfoHandler(w http.ResponseWriter, r *http.Request) |
|
|
|
|
|
|
|
|
|
|
|
obdInfo.Sys.MemInfo = append(obdInfo.Sys.MemInfo, memInfo) |
|
|
|
obdInfo.Sys.MemInfo = append(obdInfo.Sys.MemInfo, memInfo) |
|
|
|
obdInfo.Sys.MemInfo = append(obdInfo.Sys.MemInfo, globalNotificationSys.MemOBDInfo(deadlinedCtx)...) |
|
|
|
obdInfo.Sys.MemInfo = append(obdInfo.Sys.MemInfo, globalNotificationSys.MemOBDInfo(deadlinedCtx)...) |
|
|
|
partialWrite() |
|
|
|
partialWrite(obdInfo) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if proc, ok := vars["sysprocess"]; ok && proc == "true" { |
|
|
|
if proc, ok := vars["sysprocess"]; ok && proc == "true" { |
|
|
@ -1279,14 +1251,14 @@ func (a adminAPIHandlers) OBDInfoHandler(w http.ResponseWriter, r *http.Request) |
|
|
|
|
|
|
|
|
|
|
|
obdInfo.Sys.ProcInfo = append(obdInfo.Sys.ProcInfo, procInfo) |
|
|
|
obdInfo.Sys.ProcInfo = append(obdInfo.Sys.ProcInfo, procInfo) |
|
|
|
obdInfo.Sys.ProcInfo = append(obdInfo.Sys.ProcInfo, globalNotificationSys.ProcOBDInfo(deadlinedCtx)...) |
|
|
|
obdInfo.Sys.ProcInfo = append(obdInfo.Sys.ProcInfo, globalNotificationSys.ProcOBDInfo(deadlinedCtx)...) |
|
|
|
partialWrite() |
|
|
|
partialWrite(obdInfo) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if config, ok := vars["minioconfig"]; ok && config == "true" { |
|
|
|
if config, ok := vars["minioconfig"]; ok && config == "true" { |
|
|
|
cfg, err := readServerConfig(ctx, objectAPI) |
|
|
|
cfg, err := readServerConfig(ctx, objectAPI) |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
logger.LogIf(ctx, err) |
|
|
|
obdInfo.Minio.Config = cfg |
|
|
|
obdInfo.Minio.Config = cfg |
|
|
|
partialWrite() |
|
|
|
partialWrite(obdInfo) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if drive, ok := vars["perfdrive"]; ok && drive == "true" { |
|
|
|
if drive, ok := vars["perfdrive"]; ok && drive == "true" { |
|
|
@ -1314,17 +1286,39 @@ func (a adminAPIHandlers) OBDInfoHandler(w http.ResponseWriter, r *http.Request) |
|
|
|
driveOBDs := globalNotificationSys.DriveOBDInfo(deadlinedCtx) |
|
|
|
driveOBDs := globalNotificationSys.DriveOBDInfo(deadlinedCtx) |
|
|
|
obdInfo.Perf.DriveInfo = append(obdInfo.Perf.DriveInfo, driveOBDs...) |
|
|
|
obdInfo.Perf.DriveInfo = append(obdInfo.Perf.DriveInfo, driveOBDs...) |
|
|
|
|
|
|
|
|
|
|
|
partialWrite() |
|
|
|
partialWrite(obdInfo) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if net, ok := vars["perfnet"]; ok && net == "true" && globalIsDistXL { |
|
|
|
if net, ok := vars["perfnet"]; ok && net == "true" && globalIsDistXL { |
|
|
|
obdInfo.Perf.Net = append(obdInfo.Perf.Net, globalNotificationSys.NetOBDInfo(deadlinedCtx)) |
|
|
|
obdInfo.Perf.Net = append(obdInfo.Perf.Net, globalNotificationSys.NetOBDInfo(deadlinedCtx)) |
|
|
|
obdInfo.Perf.Net = append(obdInfo.Perf.Net, globalNotificationSys.DispatchNetOBDInfo(deadlinedCtx)...) |
|
|
|
obdInfo.Perf.Net = append(obdInfo.Perf.Net, globalNotificationSys.DispatchNetOBDInfo(deadlinedCtx)...) |
|
|
|
obdInfo.Perf.NetParallel = globalNotificationSys.NetOBDParallelInfo(deadlinedCtx) |
|
|
|
obdInfo.Perf.NetParallel = globalNotificationSys.NetOBDParallelInfo(deadlinedCtx) |
|
|
|
partialWrite() |
|
|
|
partialWrite(obdInfo) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ticker := time.NewTicker(30 * time.Second) |
|
|
|
|
|
|
|
defer ticker.Stop() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for { |
|
|
|
|
|
|
|
select { |
|
|
|
|
|
|
|
case oinfo, ok := <-obdInfoCh: |
|
|
|
|
|
|
|
if !ok { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
logger.LogIf(ctx, enc.Encode(oinfo)) |
|
|
|
|
|
|
|
w.(http.Flusher).Flush() |
|
|
|
|
|
|
|
case <-ticker.C: |
|
|
|
|
|
|
|
if _, err := w.Write([]byte(" ")); err != nil { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
w.(http.Flusher).Flush() |
|
|
|
|
|
|
|
case <-deadlinedCtx.Done(): |
|
|
|
|
|
|
|
w.(http.Flusher).Flush() |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
finish() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ServerInfoHandler - GET /minio/admin/v3/info
|
|
|
|
// ServerInfoHandler - GET /minio/admin/v3/info
|
|
|
@ -1488,7 +1482,7 @@ func (a adminAPIHandlers) ServerInfoHandler(w http.ResponseWriter, r *http.Reque |
|
|
|
func fetchLambdaInfo(cfg config.Config) []map[string][]madmin.TargetIDStatus { |
|
|
|
func fetchLambdaInfo(cfg config.Config) []map[string][]madmin.TargetIDStatus { |
|
|
|
|
|
|
|
|
|
|
|
// Fetch the configured targets
|
|
|
|
// Fetch the configured targets
|
|
|
|
targetList, err := notify.FetchRegisteredTargets(cfg, GlobalServiceDoneCh, NewGatewayHTTPTransport(), true, false) |
|
|
|
targetList, err := notify.FetchRegisteredTargets(cfg, GlobalContext.Done(), NewGatewayHTTPTransport(), true, false) |
|
|
|
if err != nil && err != notify.ErrTargetsOffline { |
|
|
|
if err != nil && err != notify.ErrTargetsOffline { |
|
|
|
logger.LogIf(GlobalContext, err) |
|
|
|
logger.LogIf(GlobalContext, err) |
|
|
|
return nil |
|
|
|
return nil |
|
|
|