Commit graph

77 commits

Author SHA1 Message Date
John Calixto
c1f6b270ab chore: Remove extraneous err check
After checking the scan result above this line, checking err here no
longer has any effect.

Signed-off-by: John Calixto <jcalixto@vmware.com>
2023-04-04 14:15:59 -07:00
vmwjc
6120c11333
Merge pull request #10 from mrmonaghan/fix-infinite-worker-loop
fixing infinite worker loop
2023-04-04 14:08:59 -07:00
Shiva Pentakota
86d70940e6 fix: return err log in case of ErrLeaseNotAcquired
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-04-04 11:17:22 -07:00
Shiva Pentakota
4aebaf1ae0 feat: make lease renewal async
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-04-03 14:58:04 -07:00
Shiva Pentakota
02d4b44ff6 fix: add shutdown and leaseExpired error cases for checkpoint function
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-03-28 11:46:55 -07:00
John Calixto
987fada9d3 fix: Check token bucket corner cases correctly.
Signed-off-by: John Calixto <jcalixto@vmware.com>
2023-03-23 11:23:35 -07:00
Shiva Pentakota
a7c063b99c chore: add info logs in sleep case for kinesis backoff errors
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-03-22 12:22:26 -07:00
Shiva Pentakota
df16ef451c fix: use nanosecond precision in lease comparisons
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-02-13 17:56:11 -08:00
spentakota
fb17ec8bc6
Merge pull request #23 from vmware/spentakota_filNilError
fix: add check for GetRecords error within callGetRecordsAPI
2023-02-01 08:10:38 -08:00
Shiva Pentakota
04c5062ace fix: add check for GetRecords error within callGetRecordsAPI
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-02-01 08:00:49 -08:00
Shiva Pentakota
f879712f9d chore: log RemoveLeaseOwner errors with debug instead of error
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-01-31 10:18:15 -08:00
Shiva Pentakota
7d6b1c33d0 fix: add maxBytes per second getRecord check
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-01-24 16:28:22 -08:00
Shiva Pentakota
b5515931d1 fix: add hard cap maxRetries for getRecord errors
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-01-24 14:09:02 -08:00
Shiva Pentakota
66006caf89 fix: add getRecords TPS rate limiting
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-01-24 11:56:29 -08:00
John Calixto
3be57e8a74 Refactor in prep for testing rate limiting improvements
Signed-off-by: John Calixto <jcalixto@vmware.com>
2023-01-23 17:32:27 -08:00
Shiva Pentakota
599aa06ecd fix: add DeleteMetricMillisBehindLatest for error case
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-01-20 13:23:02 -08:00
Shiva Pentakota
e1425047a7 feat: Sending renewed lease metric
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2023-01-12 11:31:16 -08:00
Shiva Pentakota
09cc5896e9 chore: Adding periods to copyright comment to satisfy gofmt
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2022-12-16 19:03:29 -05:00
Shiva Pentakota
08b7fd9447 fix: catch DynamoDB Scan error when trying to scan nonexistent table/index in syncLeases()
Signed-off-by: Shiva Pentakota <spentakota@vmware.com>
2022-12-16 18:07:22 -05:00
Mike Monaghan
aab08b9050 fixing infinite worker loop
Signed-off-by: Mike Monaghan <mike_monaghan@live.ca>
2022-09-13 15:31:16 -06:00
Fabiano Arruda
c19ae1d605
Feature/fabiano commits (#2)
* use cammel case

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* fix credential usage

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* apply lint against MD file

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* upgrade versions

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* remove calls to deprecated functions.

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* fix cammel case usage

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* since deaggregation package was upgraded to sdk v2 makes sense to use it.

https://github.com/awslabs/kinesis-aggregation/pull/143#issuecomment-953308464
Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* fix format

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

Co-authored-by: Fabiano Graças <fabiano.gracas@faro.com>
2022-01-06 20:13:32 -06:00
Tao Jiang
c02b7a85d4 Update unit tests
Signed-off-by: Tao Jiang <taoj@vmware.com>
2021-12-22 22:16:06 -06:00
Tao Jiang
86cc5a1a64 Update the libray reference path to new repo
Signed-off-by: Tao Jiang <taoj@vmware.com>
2021-12-21 13:49:47 -06:00
Fabiano Graças
f9ced84cbd improve gofmt 2021-12-20 21:21:15 -06:00
Fabiano Graças
7538535bff remove debug code 2021-12-20 21:21:15 -06:00
Fabiano Graças
a44513ef08 add parameters names in order to serve as suggestions and ignore explicitly bellow to avoid lint msgs. 2021-12-20 21:21:15 -06:00
Fabiano Graças
97c6633ea0 migrate to aws-sdk-go-v2 2021-12-20 21:21:15 -06:00
Fabiano Graças
0c204685a9 improve comments 2021-12-20 21:21:15 -06:00
Fabiano Graças
6372087bc3 removed due the new error handling https://github.com/aws/aws-sdk-go-v2/blob/main/CHANGELOG.md#error-handling 2021-12-20 21:21:15 -06:00
Fabiano Arruda
7af9290557 Upgrade golang 1.17 (#98)
* upgrade to golang 1.17

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

# Conflicts:
#	go.mod
#	go.sum

* improve after shell lint

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* improve after upgrade docker image (used by the build system)

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* remove not needed variable

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* apply fixes after security scan (hmake test)

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* add missing package after merge with latest master branch code.

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* improve docker layer

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

* upgrade packages

Signed-off-by: Fabiano Graças <fabiano.gracas@faro.com>

Co-authored-by: Fabiano Graças <fabiano.gracas@faro.com>
2021-12-20 21:21:15 -06:00
Luca Rinaldi
0094ef5a69 improve log event (#93)
* improve log event

Signed-off-by: lucarin91 <lucarin@protonmail.com>

* use %+v in template string

Signed-off-by: lucarin91 <lucarin@protonmail.com>
2021-12-20 21:21:15 -06:00
Connor McKelvey
7de4607b71 Add support for lease stealing (#78)
Fixes #4

Signed-off-by: Connor McKelvey <connormckelvey@gmail.com>
Signed-off-by: Ali Hobbs <alisuehobbs@gmail.com>
Co-authored-by: Ali Hobbs <alisuehobbs@gmail.com>

Co-authored-by: Ali Hobbs <alisuehobbs@gmail.com>
2021-12-20 21:21:15 -06:00
Ilia Cimpoes
4a642bfa2f Use application name as default enhanced fan-out consumer name (#91)
* Use ApplicationName as default for EnhancedFanOutConsumerName

Signed-off-by: Ilia Cimpoes <ilia.cimpoes@ellation.com>

* Add tests

Signed-off-by: Ilia Cimpoes <ilia.cimpoes@ellation.com>
2021-12-20 21:21:15 -06:00
Ilia Cimpoes
ddcc2d0f95 Support enhanced fan-out feature (#90)
* Implement enhanced fan-out consumer

Signed-off-by: Ilia Cimpoes <ilia.cimpoes@ellation.com>

* Add test cases

Signed-off-by: Ilia Cimpoes <ilia.cimpoes@ellation.com>

* Small adjustments in fan-out consumer

Signed-off-by: Ilia Cimpoes <ilia.cimpoes@ellation.com>
2021-12-20 21:21:15 -06:00
Aurélien Rainone
909d1774a3 Add context to ErrLeaseNotAcquired (#87)
* clientlibrary/checkpoint: convert ErrLeaseAcquired to struct

Signed-off-by: Aurélien Rainone <aurelien.rainone@gmail.com>

* clientlibrary/checkpoint: add context to ErrLeaseNotAcquired

Signed-off-by: Aurélien Rainone <aurelien.rainone@gmail.com>

* Use errors.As to check for ErrLeaseNotAcquired error

Signed-off-by: Aurélien Rainone <aurelien.rainone@gmail.com>
2021-12-20 21:21:15 -06:00
Tao Jiang
adb264717b Fix naming convention (#85)
Minor fix on constant naming convention.

Signed-off-by: Tao Jiang <taoj@vmware.com>
2021-12-20 21:21:15 -06:00
Tao Jiang
1044485392 Support Kinesis aggregation format (#84)
Add support for Kinesis aggregation format to consume record
published by KPL.

Note: current implementation need to checkpoint the whole batch
of the de-aggregated records instead of just portion of them.

Add cache entry and exit time.

Signed-off-by: Tao Jiang <taoj@vmware.com>
2021-12-20 21:21:15 -06:00
Tao Jiang
6ff3cd1b15 Fix retry logic for dynamodb (#83)
Adding min/max retry and throttle delay for the retryer.
Also, increase the max retries to 10 which is inline with
dynamodb default retry count.

Signed-off-by: Tao Jiang <taoj@vmware.com>
2021-12-20 21:21:15 -06:00
Tao Jiang
f1982602ff Fix data race during checkpointing (#82)
Make sure shard is locked during checkpointing.

Signed-off-by: Tao Jiang <taoj@vmware.com>
2021-12-20 21:21:15 -06:00
Tao Jiang
499e9cf1be Update aws go sdk and tests (#81)
Update aws go sdk to the latest. Also, update
integration tests by publishing data using both
PutRecord and PutRecords.

Signed-off-by: Tao Jiang <taoj@vmware.com>
2021-12-20 21:21:15 -06:00
wgerges-discovery
384482169c Refactor getShardIDs (#70)
* Refactor

* Use `nextToken` paramter as string.

Use `nextToken` paramter as string instead of pointer to match the original code base.

* Log the last shard token when failing.

* Use aws.StringValue to get the string pointer value.

Co-authored-by: Wesam Gerges <wesam.gerges.discovery@gmail.com>
2021-12-20 21:21:15 -06:00
Tao Jiang
5dd53bf731 Add nil check before shutdown (#68)
Signed-off-by: Tao Jiang <taoj@vmware.com>
2021-12-20 21:21:15 -06:00
Kevin Burns
8f0d7bc8d8 Reduce log noise from found shards in worker event loop (#66)
Signed-off-by: Kev Burns <kevburnsjr@gmail.com>
2021-12-20 21:21:15 -06:00
Aurélien Rainone
f1935bc0ff Fix potentially delayed shutdown on shard sync (#64)
ull-request #62 wrongly introduced an increased delay on
shutdown.

Before #62 the `stop` channel could be triggered while waiting for
`syncShard` milliseconds, so the function could return as soon as
`stop` was received.

However #62 changed this behavior by sleeping in the default case:
`stop` couldn't be handled right away anymore. Instead it was
handled after a whole new loop, potentially delaying shutdown by
minutes. (up to synchard * 1.5 ms).

This commit fixes that.

Signed-off-by: Aurélien Rainone <aurelien.rainone@gmail.com>
2021-12-20 21:21:15 -06:00
Tao Jiang
df60778d89 Re-org code for adding jittered delay for syncShard (#63)
Minor update for the previous commit by removing duplicated code.
No functional change.

Signed-off-by: Tao Jiang <taoj@vmware.com>
2021-12-20 21:21:15 -06:00
Aurélien Rainone
43a936cab3 Issue 61/add shard sync jitter (#62)
* Add a random number generator to Worker

Signed-off-by: Aurélien Rainone <aurelien.rainone@gmail.com>

* Add random jitter to the worker shard sync sleep

Signed-off-by: Aurélien Rainone <aurelien.rainone@gmail.com>

* Add random jitter in case syncShard fails

Fixes #61

Signed-off-by: Aurélien Rainone <aurelien.rainone@gmail.com>
2021-12-20 21:21:15 -06:00
dferstay
a35f4960a8 Make Worker.Shutdown() synchronous (#58)
Previously, a WaitGroup was used to track executing ShardConsumers
and prevent Worker.Shutdown() from returning until all ShardConsumers
had completed.  Unfortunately, it was possible for Shutdown() to race
with the eventLoop(), leading to a situation where Worker.Shutdown()
returns while a ShardConsumer is still executing.

Now, we increment the WaitGroup to keep track the eventLoop() as well
as the ShardConsumers.  This prevents shutdown from returning until all
background go-routines have completed.

Signed-off-by: Daniel Ferstay <dferstay@splunk.com>
2021-12-20 21:21:15 -06:00
Aurélien Rainone
6c9e594751 Make the lease refresh period configurable (#56)
* Add LeaseRefreshSpanMillis in configuration

For certain use cases of KCL the hard-coded value of 5s value,
representing the time span before the end of a lease timeout in
which the current owner gets to renew its own lease, is not
sufficient. When the time taken by ProcessRecords is higher
than 5s, the lease gets lost and the shard may end up to another
worker.

This commit adds a new configuration value, that defaults to 5s,
to let the user set this value to its own needs.

Signed-off-by: Aurélien Rainone <aurelien.rainone@gmail.com>

* Slight code simplification

Or readability improvement

Signed-off-by: Aurélien Rainone <aurelien.rainone@gmail.com>
2021-12-20 21:21:15 -06:00
Tao Jiang
9ca9d901ca Fix error in puslishing cloud watch metrics (#55)
Reported at:
https://github.com/vmware/vmware-go-kcl/issues/54

The input params are not used to set monitor service in cloudwatch
Init function. The empty appName, streamName and workerID cause
PutMetricData failed with error string "Error in publishing
cloudwatch metrics. Error: InvalidParameter...".

Signed-off-by: Tao Jiang <taoj@vmware.com>
2021-12-20 21:21:15 -06:00
Aurélien Rainone
c9793728a3 Fix 'get records time' metric (#53)
The time sent to the `metrics.MonitoringService.RecordGetRecordsTime`'
was not the time taken by GetRecords, it was the time taken by
`GetRecords` and `ProcessRecords` additioned together.

Fixes #51

Signed-off-by: Aurélien Rainone <aurelien.rainone@gmail.com>
2021-12-20 21:21:15 -06:00