mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
fix: filter rest errors and logs returned (#16019)
This commit is contained in:
parent
19d0340ddf
commit
ddeca9f12a
@ -1611,7 +1611,10 @@ func (a adminAPIHandlers) ConsoleLogHandler(w http.ResponseWriter, r *http.Reque
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case log := <-logCh:
|
case log, ok := <-logCh:
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if log.SendLog(node, logKind) {
|
if log.SendLog(node, logKind) {
|
||||||
if err := enc.Encode(log); err != nil {
|
if err := enc.Encode(log); err != nil {
|
||||||
return
|
return
|
||||||
|
@ -1130,7 +1130,10 @@ func (s *peerRESTServer) ConsoleLogHandler(w http.ResponseWriter, r *http.Reques
|
|||||||
enc := gob.NewEncoder(w)
|
enc := gob.NewEncoder(w)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case entry := <-ch:
|
case entry, ok := <-ch:
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if err := enc.Encode(entry); err != nil {
|
if err := enc.Encode(entry); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ func (l Info) Mask() uint64 {
|
|||||||
// SendLog returns true if log pertains to node specified in args.
|
// SendLog returns true if log pertains to node specified in args.
|
||||||
func (l Info) SendLog(node string, logKind madmin.LogMask) bool {
|
func (l Info) SendLog(node string, logKind madmin.LogMask) bool {
|
||||||
if logKind.Contains(l.LogKind.LogMask()) {
|
if logKind.Contains(l.LogKind.LogMask()) {
|
||||||
return node == "" || strings.EqualFold(node, l.NodeName)
|
return node == "" || strings.EqualFold(node, l.NodeName) && !l.Time.IsZero()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -199,11 +199,12 @@ func (c *Client) newRequest(ctx context.Context, u *url.URL, body io.Reader) (*h
|
|||||||
|
|
||||||
type respBodyMonitor struct {
|
type respBodyMonitor struct {
|
||||||
io.ReadCloser
|
io.ReadCloser
|
||||||
|
expectTimeouts bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r respBodyMonitor) Read(p []byte) (n int, err error) {
|
func (r respBodyMonitor) Read(p []byte) (n int, err error) {
|
||||||
n, err = r.ReadCloser.Read(p)
|
n, err = r.ReadCloser.Read(p)
|
||||||
if err != nil && err != io.EOF {
|
if xnet.IsNetworkOrHostDown(err, r.expectTimeouts) {
|
||||||
atomic.AddUint64(&globalStats.errs, 1)
|
atomic.AddUint64(&globalStats.errs, 1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -211,7 +212,7 @@ func (r respBodyMonitor) Read(p []byte) (n int, err error) {
|
|||||||
|
|
||||||
func (r respBodyMonitor) Close() (err error) {
|
func (r respBodyMonitor) Close() (err error) {
|
||||||
err = r.ReadCloser.Close()
|
err = r.ReadCloser.Close()
|
||||||
if err != nil {
|
if xnet.IsNetworkOrHostDown(err, r.expectTimeouts) {
|
||||||
atomic.AddUint64(&globalStats.errs, 1)
|
atomic.AddUint64(&globalStats.errs, 1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -297,7 +298,7 @@ func (c *Client) Call(ctx context.Context, method string, values url.Values, bod
|
|||||||
return nil, errors.New(resp.Status)
|
return nil, errors.New(resp.Status)
|
||||||
}
|
}
|
||||||
if !c.NoMetrics && !c.ExpectTimeouts {
|
if !c.NoMetrics && !c.ExpectTimeouts {
|
||||||
resp.Body = &respBodyMonitor{resp.Body}
|
resp.Body = &respBodyMonitor{ReadCloser: resp.Body, expectTimeouts: c.ExpectTimeouts}
|
||||||
}
|
}
|
||||||
return resp.Body, nil
|
return resp.Body, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user