-
Notifications
You must be signed in to change notification settings - Fork 54
Fix AdoptedResources functionality for CapacityReservations #268
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
base: main
Are you sure you want to change the base?
Fix AdoptedResources functionality for CapacityReservations #268
Conversation
… for CapacityReservations
… for CapacityReservations
… for CapacityReservations
Hi @fizashaikh. Thanks for your PR. I'm waiting for a aws-controllers-k8s member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fizashaikh The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…ionalInfo field is passed
build_date: "2025-05-26T04:21:07Z" | ||
build_hash: b57010693b861c793703028023ae75209a6af343 | ||
go_version: go1.24.0 | ||
version: v0.43.2-26-gb570106-dirty | ||
api_directory_checksum: 3df6921566512e42abdabd564c80aea5311d410a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are currently on v 47.2
for code-gen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @fizashaikh , Thank you for your contribution!
I see that that the code-generator
version you are using is v0.43.2 dirty
, can you update it to the latest version and regenerate the controller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @fizashaikh
left a few comments..
Also would you like to try out https://aws-controllers-k8s.github.io/community/docs/user-docs/features/#resourceadoption?
if instanceCount, ok := identifier.AdditionalKeys["instanceCount"]; ok { | ||
parsedInstanceCount, err := strconv.ParseInt(instanceCount, 10, 64) | ||
if err != nil { | ||
return fmt.Errorf("failed to parse instanceCount: %v", err) | ||
} | ||
r.ko.Spec.InstanceCount = &parsedInstanceCount | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having an sdk_read_many_post_set_output.go would be enough instead of adding this one?
if instancePlatform, ok := identifier.AdditionalKeys["instancePlatform"]; ok { | ||
r.ko.Spec.InstancePlatform = &instancePlatform | ||
} | ||
|
||
if instanceType, ok := identifier.AdditionalKeys["instanceType"]; ok { | ||
r.ko.Spec.InstanceType = &instanceType | ||
} | ||
|
||
if availabilityZone, ok := identifier.AdditionalKeys["availabilityZone"]; ok { | ||
r.ko.Spec.AvailabilityZone = &availabilityZone | ||
} | ||
|
||
if availabilityZoneID, ok := identifier.AdditionalKeys["availabilityZoneID"]; ok { | ||
r.ko.Spec.AvailabilityZoneID = &availabilityZoneID | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these fields seem to already be set in sdkFind..why set them again?
if ko.Status.TotalInstanceCount != nil { | ||
ko.Spec.InstanceCount = ko.Status.TotalInstanceCount | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if input.AdditionalInfo != nil { | ||
input.InstanceCount = nil | ||
input.EndDate = nil | ||
input.EndDateType = "" | ||
input.InstanceMatchCriteria = "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with this change, AdditionalInfo may never be nil...would this be better?
if input.AdditionalInfo != nil { | |
input.InstanceCount = nil | |
input.EndDate = nil | |
input.EndDateType = "" | |
input.InstanceMatchCriteria = "" | |
} | |
if delta.DifferentAt("Spec.AdditionalInfo") { | |
input.InstanceCount = nil | |
input.EndDate = nil | |
input.EndDateType = "" | |
input.InstanceMatchCriteria = "" | |
} else { | |
input.AdditionalInfo = nil | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also depends on which field would we prioritize to update..
Issue #, if available: aws-controllers-k8s/community#2485
Description of changes:
This PR adds the following hooks for CapacityReservations.
post_set_resource_identifiers
- This hook is needed to set additional fields required for successfully adopting existing reservation.sdk_read_many_post_set_output
- This hook is required to correctly update instance count for reservations after they are adopted.sdk_update_post_build_request
- This hook is needed to add support to update/modify capacity reservations using theadditionalInfo
reserved field.The new AdoptedResource config looks like follows,
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.