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

fix(cmd): Out of Bounds int32 Check in AWS Lambda Autoscale #238

Merged
merged 4 commits into from
Sep 30, 2024

Conversation

andrew-kline
Copy link
Contributor

Description

Motivation and Context

Solves potential overflow issue if the Kinesis downscale and upscale datapoints values are outside the upper bound for int32. This occurs in init - failure should occur pre-runtime if the env var(s) are set incorrectly.

How Has This Been Tested?

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@andrew-kline andrew-kline requested a review from a team as a code owner September 30, 2024 18:20
@jshlbrd jshlbrd self-assigned this Sep 30, 2024
cmd/aws/lambda/autoscale/main.go Outdated Show resolved Hide resolved
@@ -63,7 +63,11 @@ func init() {
panic(err)
}

kinesisDownscaleDatapoints = int32(dps)
if dps <= 360 && dps >= 1 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The max value can be any integer, so I think borrowing this logic from your first commit may work better:

if dps <= math.MaxInt32 && dps >= 1 {

Same for the other line, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good, adjusted - i was basing off of the readme-defined maxes

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that README might have been accurate at one time, but not anymore. It could use an update.

@andrew-kline andrew-kline merged commit bcc8108 into main Sep 30, 2024
7 checks passed
@andrew-kline andrew-kline deleted the akline/fix/integer-conversion branch September 30, 2024 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants