add _MINIO_SERVER_DEBUG env for enabling debug messages (#11128)

This commit is contained in:
Harshavardhana
2020-12-17 16:52:47 -08:00
committed by GitHub
parent 7c9ef76f66
commit f714840da7
9 changed files with 30 additions and 20 deletions

View File

@@ -25,6 +25,7 @@ import (
"github.com/dustin/go-humanize"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/console"
)
const (
@@ -140,6 +141,10 @@ wait:
}
}
if serverDebugLog {
console.Debugf("disk check timer fired, attempting to heal %d drives\n", len(healDisks))
}
// heal only if new disks found.
for _, endpoint := range healDisks {
disk, format, err := connectEndpoint(endpoint)

View File

@@ -30,6 +30,7 @@ import (
"strings"
"time"
"github.com/fatih/color"
dns2 "github.com/miekg/dns"
"github.com/minio/cli"
"github.com/minio/minio-go/v7/pkg/set"
@@ -38,9 +39,13 @@ import (
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/auth"
"github.com/minio/minio/pkg/certs"
"github.com/minio/minio/pkg/console"
"github.com/minio/minio/pkg/env"
)
// serverDebugLog will enable debug printing
var serverDebugLog = env.Get("_MINIO_SERVER_DEBUG", config.EnableOff) == config.EnableOn
func init() {
logger.Init(GOPATH, GOROOT)
logger.RegisterError(config.FmtError)
@@ -53,6 +58,8 @@ func init() {
globalReplicationState = newReplicationState()
globalTransitionState = newTransitionState()
console.SetColor("Debug", color.New())
gob.Register(StorageErr(""))
}

View File

@@ -35,6 +35,7 @@ import (
"github.com/minio/minio/pkg/bucket/lifecycle"
"github.com/minio/minio/pkg/bucket/replication"
"github.com/minio/minio/pkg/color"
"github.com/minio/minio/pkg/console"
"github.com/minio/minio/pkg/env"
"github.com/minio/minio/pkg/event"
"github.com/minio/minio/pkg/hash"
@@ -110,6 +111,10 @@ func runDataCrawler(ctx context.Context, objAPI ObjectLayer) {
// Reset the timer for next cycle.
crawlTimer.Reset(dataCrawlStartDelay)
if intDataUpdateTracker.debug {
console.Debugln("starting crawler cycle")
}
// Wait before starting next cycle and wait on startup.
results := make(chan DataUsageInfo, 1)
go storeDataUsageInBackend(ctx, objAPI, results)

View File

@@ -79,7 +79,7 @@ func newDataUpdateTracker() *dataUpdateTracker {
Current: dataUpdateFilter{
idx: 1,
},
debug: env.Get(envDataUsageCrawlDebug, config.EnableOff) == config.EnableOn,
debug: env.Get(envDataUsageCrawlDebug, config.EnableOff) == config.EnableOn || serverDebugLog,
input: make(chan string, dataUpdateTrackerQueueSize),
save: make(chan struct{}, 1),
saveExited: make(chan struct{}),

View File

@@ -34,6 +34,7 @@ import (
"github.com/minio/minio-go/v7/pkg/tags"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/bpool"
"github.com/minio/minio/pkg/console"
"github.com/minio/minio/pkg/dsync"
"github.com/minio/minio/pkg/madmin"
"github.com/minio/minio/pkg/sync/errgroup"
@@ -281,6 +282,10 @@ func (s *erasureSets) monitorAndConnectEndpoints(ctx context.Context, monitorInt
// Reset the timer once fired for required interval.
monitor.Reset(monitorInterval)
if serverDebugLog {
console.Debugln("running disk monitoring")
}
s.connectDisks()
}
}

View File

@@ -74,8 +74,8 @@ func newBucketMetacache(bucket string, cleanup bool) *bucketMetacache {
}
func (b *bucketMetacache) debugf(format string, data ...interface{}) {
if metacacheDebug {
console.Debugf(format, data...)
if serverDebugLog {
console.Debugf(format+"\n", data...)
}
}

View File

@@ -125,13 +125,13 @@ func (o listPathOptions) newMetacache() metacache {
}
func (o *listPathOptions) debugf(format string, data ...interface{}) {
if metacacheDebug {
if serverDebugLog {
console.Debugf(format, data...)
}
}
func (o *listPathOptions) debugln(data ...interface{}) {
if metacacheDebug {
if serverDebugLog {
console.Debugln(data...)
}
}

View File

@@ -46,9 +46,6 @@ const (
// Enabling this will make cache sharing more likely and cause less IO,
// but may cause additional latency to some calls.
metacacheSharePrefix = false
// metacacheDebug will enable debug printing
metacacheDebug = false
)
//go:generate msgp -file $GOFILE -unexported