Conversation
Contributor
|
Preview deployment ready! Preview URL: https://pr-9080.d18coufmbnnaag.amplifyapp.com Built from commit |
…uptible field lo.Ternary eagerly evaluates all arguments in Go, so lo.Ternary(cr.Interruptible == nil, false, *cr.Interruptible) dereferences *cr.Interruptible unconditionally, panicking when the pointer is nil. This is the default for all standard ODCRs and capacity blocks returned by the EC2 API. Replace with lo.FromPtrOr which safely returns the default value when the pointer is nil. Also adds a test case with nil Interruptible to prevent regression. Fixes aws#9079
c5a8ae7 to
e7bc7f3
Compare
ryan-mist
reviewed
Apr 13, 2026
Contributor
Author
|
Thank you! |
ryan-mist
pushed a commit
to ryan-mist/karpenter-provider-aws
that referenced
this pull request
Apr 13, 2026
3 tasks
ryan-mist
pushed a commit
to ryan-mist/karpenter-provider-aws
that referenced
this pull request
Apr 13, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #9079
lo.Ternaryeagerly evaluates all arguments in Go, so:dereferences
*cr.Interruptibleunconditionally, panicking when the pointer is nil. TheInterruptiblefield may be absent from the EC2 API response depending on partition/region — when absent, the Go SDK deserializes the*boolasnil, triggering the panic.Any user configuring
capacityReservationSelectorTermson an EC2NodeClass will hit this panic if any matched reservation has a nilInterruptiblefield.Changes
lo.Ternary(cr.Interruptible == nil, false, *cr.Interruptible)withlo.FromPtrOr(cr.Interruptible, false)which safely returns the default when nilInterruptibleand a regression test tocapacityreservation_test.goHow was this change tested?
Interruptiblefield (nil pointer). The existing test fixtures all setInterruptible: lo.ToPtr(false), which is why this bug was not caught.Interruptible. Before fix: continuous panic. After fix: all reservations discovered successfully.