Skip to content

Commit

Permalink
agent: don't check S3.Endpoint for emptyness (#934)
Browse files Browse the repository at this point in the history
We can actually use the default value in prod, it simplifies
configuration.

Also, tiny changes for logs and error formatting.

Signed-off-by: Oleg Vasilev <[email protected]>
  • Loading branch information
Omrigan authored May 14, 2024
1 parent d932bc5 commit e3b2cec
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
9 changes: 2 additions & 7 deletions pkg/agent/billing/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,9 @@ func StartBillingMetricsCollector(
if c := conf.Clients.S3; c != nil {
client, err := billing.NewS3Client(ctx, c.S3ClientConfig)
if err != nil {
return fmt.Errorf("Failed to create S3 client: %w", err)
return fmt.Errorf("failed to create S3 client: %w", err)
}
logger.Info("Created S3 client",
zap.String("bucket", c.Bucket),
zap.String("region", c.Region),
zap.String("prefixInBucket", c.PrefixInBucket),
zap.String("endpoint", c.Endpoint),
)
logger.Info("Created S3 client", client.LogFields())
clients = append(clients, clientInfo{
client: client,
name: "s3",
Expand Down
1 change: 0 additions & 1 deletion pkg/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ func (c *Config) validate() error {
erc.Whenf(ec, c.Billing.Clients.S3.Bucket == "", emptyTmpl, ".billing.clients.s3.bucket")
erc.Whenf(ec, c.Billing.Clients.S3.Region == "", emptyTmpl, ".billing.clients.s3.region")
erc.Whenf(ec, c.Billing.Clients.S3.PrefixInBucket == "", emptyTmpl, ".billing.clients.s3.prefixInBucket")
erc.Whenf(ec, c.Billing.Clients.S3.Endpoint == "", emptyTmpl, ".billing.clients.s3.endpoint")
}
erc.Whenf(ec, c.DumpState != nil && c.DumpState.Port == 0, zeroTmpl, ".dumpState.port")
erc.Whenf(ec, c.DumpState != nil && c.DumpState.TimeoutSeconds == 0, zeroTmpl, ".dumpState.timeoutSeconds")
Expand Down
4 changes: 3 additions & 1 deletion pkg/billing/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ func NewS3Client(ctx context.Context, cfg S3ClientConfig) (*S3Client, error) {
}

client := s3.NewFromConfig(s3Config, func(o *s3.Options) {
o.BaseEndpoint = &cfg.Endpoint
if cfg.Endpoint != "" {
o.BaseEndpoint = &cfg.Endpoint
}
o.UsePathStyle = true // required for minio
})

Expand Down

0 comments on commit e3b2cec

Please sign in to comment.