Skip to content

Commit

Permalink
Make aws sdk v2 the default choice
Browse files Browse the repository at this point in the history
Remove the aws-sdk-v2 feature flag and replace it with aws-sdk-v1. This
makes SDK v2 the default, unless v1 is explicitly enabled.

Signed-off-by: Cristian Greco <[email protected]>
  • Loading branch information
cristiangreco committed Feb 2, 2025
1 parent 5940fa2 commit 65b3210
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
40 changes: 22 additions & 18 deletions cmd/yace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,18 @@ func startScraper(c *cli.Context) error {

featureFlags := c.StringSlice(enableFeatureFlag)
s := NewScraper(featureFlags)
var cache cachingFactory = v1.NewFactory(logger, jobsCfg, fips)

var cache cachingFactory
cache, err = v2.NewFactory(logger, jobsCfg, fips)
if err != nil {
return fmt.Errorf("Failed to construct aws sdk v2 client cache: %w", err)
}

// Switch to v1 SDK if feature flag is enabled
for _, featureFlag := range featureFlags {
if featureFlag == config.AwsSdkV2 {
var err error
// Can't override cache while also creating err
cache, err = v2.NewFactory(logger, jobsCfg, fips)
if err != nil {
return fmt.Errorf("failed to construct aws sdk v2 client cache: %w", err)
}
if featureFlag == config.AwsSdkV1 {
cache = v1.NewFactory(logger, jobsCfg, fips)
logger.Info("Using aws sdk v1")
}
}

Expand Down Expand Up @@ -321,17 +324,18 @@ func startScraper(c *cli.Context) error {
}

logger.Info("Reset clients cache")
cache = v1.NewFactory(logger, newJobsCfg, fips)
var cache cachingFactory
cache, err = v2.NewFactory(logger, newJobsCfg, fips)
if err != nil {
logger.Error("Failed to construct aws sdk v2 client cache", "err", err, "path", configFile)
return
}

// Switch to v1 SDK if feature flag is enabled
for _, featureFlag := range featureFlags {
if featureFlag == config.AwsSdkV2 {
logger.Info("Using aws sdk v2")
var err error
// Can't override cache while also creating err
cache, err = v2.NewFactory(logger, newJobsCfg, fips)
if err != nil {
logger.Error("Failed to construct aws sdk v2 client cache", "err", err, "path", configFile)
return
}
if featureFlag == config.AwsSdkV1 {
cache = v1.NewFactory(logger, newJobsCfg, fips)
logger.Info("Using aws sdk v1")
}
}

Expand Down
6 changes: 3 additions & 3 deletions docs/feature_flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ List of features or changes that are disabled by default since they are breaking

You can enable them using the `-enable-feature` flag with a comma separated list of features. They may be enabled by default in future versions.

## AWS SDK v2
## AWS SDK v1

`-enable-feature=aws-sdk-v2`
`-enable-feature=aws-sdk-v1`

Uses the v2 version of the aws sdk for go. The sdk v2 version was released in Jan 2021 and is marketed to come with large performance gains. This version offers a drastically different interface and should be compatible with sdk v2.
Uses the v1 version of the aws sdk for go for backward compatibility. By default, YACE now uses AWS SDK v2 which was released in Jan 2021 and comes with large performance gains.

## Always return info metrics

Expand Down
4 changes: 2 additions & 2 deletions pkg/config/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import "context"

type flagsCtxKey struct{}

// AwsSdkV2 is a feature flag used to enable the use of aws sdk v2 which is expected to come with performance benefits
const AwsSdkV2 = "aws-sdk-v2"
// AwsSdkV1 is a feature flag used to enable the use of aws sdk v1 (v2 is the default)
const AwsSdkV1 = "aws-sdk-v1"

// AlwaysReturnInfoMetrics is a feature flag used to enable the return of info metrics even when there are no corresponding CloudWatch metrics
const AlwaysReturnInfoMetrics = "always-return-info-metrics"
Expand Down

0 comments on commit 65b3210

Please sign in to comment.