add user-agent for all minio.Client usage (#16619)

This commit is contained in:
Harshavardhana 2023-02-14 13:19:30 -08:00 committed by GitHub
parent 857674c3a0
commit 0c1f8b4e0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 18 deletions

View File

@ -633,23 +633,24 @@ func (r *BatchJobReplicateV1) Start(ctx context.Context, api ObjectLayer, job Ba
if err != nil { if err != nil {
return err return err
} }
c.SetAppInfo("minio-"+batchJobPrefix, r.APIVersion+" "+job.ID)
workerSize, err := strconv.Atoi(env.Get("_MINIO_BATCH_REPLICATION_WORKERS", strconv.Itoa(runtime.GOMAXPROCS(0)/2))) workerSize, err := strconv.Atoi(env.Get("_MINIO_BATCH_REPLICATION_WORKERS", strconv.Itoa(runtime.GOMAXPROCS(0)/2)))
if err != nil { if err != nil {
return err return err
} }
wk, err := workers.New(workerSize)
if err != nil {
// invalid worker size.
return err
}
retryAttempts := ri.RetryAttempts retryAttempts := ri.RetryAttempts
retry := false retry := false
for attempts := 1; attempts <= retryAttempts; attempts++ { for attempts := 1; attempts <= retryAttempts; attempts++ {
attempts := attempts attempts := attempts
wk, err := workers.New(workerSize)
if err != nil {
// invalid worker size.
return err
}
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
results := make(chan ObjectInfo, 100) results := make(chan ObjectInfo, 100)
@ -737,7 +738,7 @@ func (e batchReplicationJobError) Error() string {
} }
// Validate validates the job definition input // Validate validates the job definition input
func (r *BatchJobReplicateV1) Validate(ctx context.Context, o ObjectLayer) error { func (r *BatchJobReplicateV1) Validate(ctx context.Context, job BatchJobRequest, o ObjectLayer) error {
if r == nil { if r == nil {
return nil return nil
} }
@ -813,6 +814,7 @@ func (r *BatchJobReplicateV1) Validate(ctx context.Context, o ObjectLayer) error
if err != nil { if err != nil {
return err return err
} }
c.SetAppInfo("minio-"+batchJobPrefix, r.APIVersion+" "+job.ID)
vcfg, err := c.GetBucketVersioning(ctx, r.Target.Bucket) vcfg, err := c.GetBucketVersioning(ctx, r.Target.Bucket)
if err != nil { if err != nil {
@ -851,7 +853,7 @@ func (j BatchJobRequest) Type() madmin.BatchJobType {
// persisting the job request // persisting the job request
func (j BatchJobRequest) Validate(ctx context.Context, o ObjectLayer) error { func (j BatchJobRequest) Validate(ctx context.Context, o ObjectLayer) error {
if j.Replicate != nil { if j.Replicate != nil {
return j.Replicate.Validate(ctx, o) return j.Replicate.Validate(ctx, j, o)
} }
return errInvalidArgument return errInvalidArgument
} }

View File

@ -453,6 +453,8 @@ func (sys *BucketTargetSys) getRemoteTargetClient(tcfg *madmin.BucketTarget) (*T
if err != nil { if err != nil {
return nil, err return nil, err
} }
api.SetAppInfo("minio-replication-target", ReleaseTag+" "+tcfg.Arn)
hcDuration := defaultHealthCheckDuration hcDuration := defaultHealthCheckDuration
if tcfg.HealthCheckDuration >= 1 { // require minimum health check duration of 1 sec. if tcfg.HealthCheckDuration >= 1 { // require minimum health check duration of 1 sec.
hcDuration = tcfg.HealthCheckDuration hcDuration = tcfg.HealthCheckDuration
@ -479,7 +481,10 @@ func (sys *BucketTargetSys) getRemoteARN(bucket string, target *madmin.BucketTar
} }
tgts := sys.targetsMap[bucket] tgts := sys.targetsMap[bucket]
for _, tgt := range tgts { for _, tgt := range tgts {
if tgt.Type == target.Type && tgt.TargetBucket == target.TargetBucket && target.URL().String() == tgt.URL().String() && tgt.Credentials.AccessKey == target.Credentials.AccessKey { if tgt.Type == target.Type &&
tgt.TargetBucket == target.TargetBucket &&
target.URL().String() == tgt.URL().String() &&
tgt.Credentials.AccessKey == target.Credentials.AccessKey {
return tgt.Arn, true return tgt.Arn, true
} }
} }

View File

@ -937,11 +937,16 @@ var getRemoteInstanceClient = func(r *http.Request, host string) (*miniogo.Core,
cred := getReqAccessCred(r, globalSite.Region) cred := getReqAccessCred(r, globalSite.Region)
// In a federated deployment, all the instances share config files // In a federated deployment, all the instances share config files
// and hence expected to have same credentials. // and hence expected to have same credentials.
return miniogo.NewCore(host, &miniogo.Options{ core, err := miniogo.NewCore(host, &miniogo.Options{
Creds: credentials.NewStaticV4(cred.AccessKey, cred.SecretKey, ""), Creds: credentials.NewStaticV4(cred.AccessKey, cred.SecretKey, ""),
Secure: globalIsTLS, Secure: globalIsTLS,
Transport: getRemoteInstanceTransport, Transport: getRemoteInstanceTransport,
}) })
if err != nil {
return nil, err
}
core.SetAppInfo("minio-federated", ReleaseTag)
return core, nil
} }
// Check if the destination bucket is on a remote site, this code only gets executed // Check if the destination bucket is on a remote site, this code only gets executed

View File

@ -753,6 +753,9 @@ func serverMain(ctx *cli.Context) {
}) })
logger.FatalIf(err, "Unable to initialize MinIO client") logger.FatalIf(err, "Unable to initialize MinIO client")
// Add User-Agent to differentiate the requests.
globalMinioClient.SetAppInfo("minio-perf-test", ReleaseTag)
if serverDebugLog { if serverDebugLog {
logger.Info("== DEBUG Mode enabled ==") logger.Info("== DEBUG Mode enabled ==")
logger.Info("Currently set environment settings:") logger.Info("Currently set environment settings:")

View File

@ -53,10 +53,9 @@ func newWarmBackendMinIO(conf madmin.TierMinIO) (*warmBackendMinIO, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
core, err := minio.NewCore(u.Host, opts) client.SetAppInfo("minio-tier-target", ReleaseTag)
if err != nil {
return nil, err core := &minio.Core{Client: client}
}
return &warmBackendMinIO{ return &warmBackendMinIO{
warmBackendS3{ warmBackendS3{
client: client, client: client,

View File

@ -128,10 +128,9 @@ func newWarmBackendS3(conf madmin.TierS3) (*warmBackendS3, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
core, err := minio.NewCore(u.Host, opts) client.SetAppInfo("s3-tier-target", ReleaseTag)
if err != nil {
return nil, err core := &minio.Core{Client: client}
}
return &warmBackendS3{ return &warmBackendS3{
client: client, client: client,
core: core, core: core,