Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-s3 input: Split S3 poller and SQS reader into explicit input objects #39353

Merged
merged 87 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
a4019ec
cleanup
faec Apr 10, 2024
a3d3757
cleanups
faec Apr 11, 2024
597e0a5
break input sources up into separate helper functions
faec Apr 11, 2024
0df748a
finish helper function split
faec Apr 11, 2024
4b70900
rewrite the sqsReader main loop
faec Apr 11, 2024
90d9e24
simplify sqsReader loop
faec Apr 12, 2024
5f94e9b
adjust variable names
faec Apr 12, 2024
b797261
remove unused parameter
faec Apr 12, 2024
88f3980
createS3Lister -> createS3Poller
faec Apr 12, 2024
9f32df6
remove unused error checks
faec Apr 12, 2024
48ec82a
cleanup
faec Apr 12, 2024
58e084a
make a wrapper for v2.Canceler that doesn't use an extra goroutine
faec Apr 12, 2024
1974f8f
remove unused parameter
faec Apr 12, 2024
646374c
cleanup
faec Apr 12, 2024
a43cae6
remove redundant helper
faec Apr 12, 2024
f46ef06
adjust variable names
faec Apr 12, 2024
d9be04b
remove extra index indirection in state lookup
faec Apr 13, 2024
5e1fbcc
remove redundant sync.Map
faec Apr 13, 2024
c16a22f
merge redundant state maps
faec Apr 13, 2024
f07915a
remove redundant state map
faec Apr 13, 2024
0f483a3
simplify s3Poller worker handling
faec Apr 13, 2024
8916d91
Merge branch 'main' of github.com:elastic/beats into awss3-cleanup
faec Apr 13, 2024
a8cb6bd
simplify waitgroup handling / unused errors
faec Apr 13, 2024
78a7db4
clean up context handling
faec Apr 13, 2024
edc1bd3
adjust delay timer
faec Apr 13, 2024
1497be4
remove unused struct fields
faec Apr 13, 2024
a3e0dc8
cleanup
faec Apr 13, 2024
219e857
Refactor cloudwatch worker task allocation
faec Apr 15, 2024
977a0d3
add unit tests for cloudwatchPoller.receive
faec Apr 15, 2024
71134f9
Merge branch 'main' of github.com:elastic/beats into cloudwatch-fix
faec Apr 15, 2024
6cf5506
update changelog
faec Apr 15, 2024
ff24571
make check
faec Apr 15, 2024
5ec8a86
Merge branch 'cloudwatch-fix' into awss3-cleanup
faec Apr 15, 2024
2a6abb8
Remove unused custom semaphore helper
faec Apr 15, 2024
12a2a3c
cleanups in input.go
faec Apr 15, 2024
dd29fa0
revert unintentional return value change
faec Apr 15, 2024
4956db9
Concurrency / error handling fixes in awss3
faec Apr 22, 2024
fc641e1
give the registry accessor its own mutex
faec Apr 22, 2024
4a9cb60
update tests
faec Apr 23, 2024
959d557
Merge branch 'main' of github.com:elastic/beats into s3-concurrency-fix
faec Apr 23, 2024
3d93d22
make check
faec Apr 23, 2024
7d6369f
lint
faec Apr 23, 2024
b4b5b28
lint
faec Apr 23, 2024
45619e3
Merge branch 'main' of github.com:elastic/beats into s3-concurrency-fix
faec Apr 24, 2024
e88be00
Merge branch 's3-concurrency-fix' of github.com:faec/beats into awss3…
faec Apr 24, 2024
1308a2d
Merge branch 'main' into s3-concurrency-fix
faec Apr 24, 2024
0abf663
Merge branch 's3-concurrency-fix' into awss3-cleanup
faec Apr 24, 2024
942ae03
cleaning up context use
faec Apr 26, 2024
e84471b
Merge branch 'main' into s3input-cleanup
faec Apr 26, 2024
0289604
Merge branch 's3input-cleanup' into awss3-cleanup
faec Apr 26, 2024
2c084bb
splitting S3 and SQS into distinct inputs internally
faec Apr 26, 2024
dbe4691
splitting awss3 into two input objects
faec Apr 29, 2024
73d1465
Merge branch 'main' of github.com:elastic/beats into s3input-cleanup
faec Apr 30, 2024
ad7d342
Merge branch 's3input-cleanup' into awss3-cleanup
faec Apr 30, 2024
e05c45d
reorganize {s3,sqs}.go by adding {s3,sqs}_input.go for the code speci…
faec Apr 30, 2024
54f0a87
clean up sqs helpers
faec Apr 30, 2024
122ee8c
Merge branch 'main' into awss3-cleanup
faec Apr 30, 2024
d396457
fix merge
faec Apr 30, 2024
be54ac7
update tests
faec Apr 30, 2024
568d2b0
merge sqsReaderInput and sqsReader
faec Apr 30, 2024
383c111
get tests building again
faec May 1, 2024
4b2ea11
remove redundant fields
faec May 1, 2024
de36816
more reorganization
faec May 1, 2024
3117334
organizing
faec May 1, 2024
6b43ac5
reordering code
faec May 1, 2024
d38af54
Merge branch 'main' of github.com:elastic/beats into awss3-cleanup
faec May 1, 2024
3712af4
clean up states initialization
faec May 1, 2024
894ba4c
remove unused helper
faec May 1, 2024
31f3b95
working on test updates
faec May 2, 2024
7d12f0a
fix benchmark tests
faec May 2, 2024
f1b7761
updating unit tests
faec May 3, 2024
fa22239
fix remaining tests
faec May 3, 2024
e253681
remove unused debug parameter
faec May 3, 2024
5b922df
Merge branch 'main' of github.com:elastic/beats into awss3-cleanup
faec May 3, 2024
1fef199
remove commented code
faec May 3, 2024
800fc73
move helper function
faec May 3, 2024
1694f0d
clean up aws client config modifiers
faec May 3, 2024
63be523
reorder helper functions
faec May 3, 2024
1bae757
reorder helper functions
faec May 3, 2024
939c38f
update comments
faec May 3, 2024
b032106
move log creation earlier
faec May 3, 2024
0995921
update comments
faec May 3, 2024
5d9f731
make check
faec May 3, 2024
3f152f4
starting unit tests
faec May 7, 2024
a722f68
update log initialization
faec May 9, 2024
9e06e1e
Merge branch 'main' of github.com:elastic/beats into awss3-cleanup
faec May 9, 2024
9cc8e7c
add comments
faec May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions x-pack/filebeat/input/awss3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
"fmt"
"time"

awssdk "github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/dustin/go-humanize"

"github.com/elastic/beats/v7/libbeat/common/cfgtype"
Expand Down Expand Up @@ -222,3 +226,59 @@ func (rc *readerConfig) InitDefaults() {
rc.MaxBytes = 10 * humanize.MiByte
rc.LineTerminator = readfile.AutoLineTerminator
}

func (c config) getBucketName() string {
if c.NonAWSBucketName != "" {
return c.NonAWSBucketName
}
if c.BucketARN != "" {
return getBucketNameFromARN(c.BucketARN)
}
return ""
}

func (c config) getBucketARN() string {
if c.NonAWSBucketName != "" {
return c.NonAWSBucketName
}
if c.BucketARN != "" {
return c.BucketARN
}
return ""
}
Comment on lines +230 to +248
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea.


// An AWS SDK callback to apply the input configuration's settings to an S3
// options struct.
// Should be provided as a parameter to s3.NewFromConfig.
func (c config) s3ConfigModifier(o *s3.Options) {
if c.NonAWSBucketName != "" {
o.EndpointResolver = nonAWSBucketResolver{endpoint: c.AWSConfig.Endpoint}
}

if c.AWSConfig.FIPSEnabled {
o.EndpointOptions.UseFIPSEndpoint = awssdk.FIPSEndpointStateEnabled
}
o.UsePathStyle = c.PathStyle

o.Retryer = retry.NewStandard(func(so *retry.StandardOptions) {
so.MaxAttempts = 5
// Recover quickly when requests start working again
so.NoRetryIncrement = 100
})
}

// An AWS SDK callback to apply the input configuration's settings to an SQS
// options struct.
// Should be provided as a parameter to sqs.NewFromConfig.
func (c config) sqsConfigModifier(o *sqs.Options) {
if c.AWSConfig.FIPSEnabled {
o.EndpointOptions.UseFIPSEndpoint = awssdk.FIPSEndpointStateEnabled
}
}

func (c config) getFileSelectors() []fileSelectorConfig {
if len(c.FileSelectors) > 0 {
return c.FileSelectors
}
return []fileSelectorConfig{{ReaderConfig: c.ReaderConfig}}
}
Loading
Loading