Compare commits

...

5 Commits

Author SHA1 Message Date
Allan Roger Reid 3b3edbfc53
Merge e0182b85e0 into 534f4a9fb1 2025-10-02 08:32:37 +08:00
yangw 534f4a9fb1
fix: timeN function return final closure not be called (#21615)
VulnCheck / Analysis (push) Has been cancelled Details
2025-09-30 23:06:01 -07:00
Allan Roger Reid e0182b85e0
Merge branch 'master' into add-audit-site 2024-12-31 14:50:22 -08:00
Allan Roger Reid 9611aa9b15
Merge branch 'master' into add-audit-site 2024-12-19 12:25:18 -08:00
Allan Reid bebf04e2b6
Add SiteName to both internal and external audit logs 2024-12-19 12:12:03 -08:00
5 changed files with 17 additions and 8 deletions

View File

@ -523,6 +523,7 @@ func lookupConfigs(s config.Config, objAPI ObjectLayer) {
configLogIf(ctx, fmt.Errorf("Invalid site configuration: %w", err))
}
globalSite.Update(siteCfg)
xhttp.SetSiteName(globalSite.Name())
globalAutoEncryption = crypto.LookupAutoEncryption() // Enable auto-encryption if enabled
if globalAutoEncryption && GlobalKMS == nil {

View File

@ -106,16 +106,14 @@ func (p *scannerMetrics) log(s scannerMetric, paths ...string) func(custom map[s
// time n scanner actions.
// Use for s < scannerMetricLastRealtime
func (p *scannerMetrics) timeN(s scannerMetric) func(n int) func() {
func (p *scannerMetrics) timeN(s scannerMetric) func(n int) {
startTime := time.Now()
return func(n int) func() {
return func() {
duration := time.Since(startTime)
return func(n int) {
duration := time.Since(startTime)
atomic.AddUint64(&p.operations[s], uint64(n))
if s < scannerMetricLastRealtime {
p.latency[s].add(duration)
}
atomic.AddUint64(&p.operations[s], uint64(n))
if s < scannerMetricLastRealtime {
p.latency[s].add(duration)
}
}
}

View File

@ -37,6 +37,9 @@ var (
// GlobalDeploymentID - is sent in the header to all http targets
GlobalDeploymentID string
// GlobalSiteName - is sent in the header to all http targets
GlobalSiteName string
)
const (
@ -236,3 +239,8 @@ func SetMinIOVersion(version string) {
func SetDeploymentID(deploymentID string) {
GlobalDeploymentID = deploymentID
}
// SetSiteName -- user defined site from environment variable `MINIO_SITE_NAME` or from configuration `site.name`
func SetSiteName(siteName string) {
GlobalSiteName = siteName
}

View File

@ -52,6 +52,7 @@ func GetAuditEntry(ctx context.Context) *audit.Entry {
r = &audit.Entry{
Version: internalAudit.Version,
DeploymentID: xhttp.GlobalDeploymentID,
SiteName: xhttp.GlobalSiteName,
Time: time.Now().UTC(),
}
return r

View File

@ -36,6 +36,7 @@ func NewEntry(deploymentID string) audit.Entry {
return audit.Entry{
Version: Version,
DeploymentID: deploymentID,
SiteName: xhttp.GlobalSiteName,
Time: time.Now().UTC(),
}
}