Skip to content

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
10 changes: 5 additions & 5 deletions apis/v1alpha1/ack-generate-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ack_generate_info:
build_date: "2025-05-13T17:53:20Z"
build_hash: 55bf57b2806c33a7fcd074be403f26ce3f8e58db
go_version: go1.24.2
version: v0.46.2
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
api_version: v1alpha1
aws_sdk_go_version: v1.32.6
generator_config_info:
file_checksum: 631d4b99d0839af4f2c0561d15f7da3c911786d7
file_checksum: 172877410214b442af4d618739f2222b3dfebb3b
original_file_name: generator.yaml
last_modification:
reason: API generation
6 changes: 6 additions & 0 deletions apis/v1alpha1/generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,14 @@ resources:
template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl
sdk_update_pre_build_request:
template_path: hooks/capacity_reservation/sdk_update_pre_build_request.go.tpl
sdk_update_post_build_request:
template_path: hooks/capacity_reservation/sdk_update_post_build_request.go.tpl
sdk_update_post_set_output:
template_path: hooks/capacity_reservation/sdk_update_post_set_output.go.tpl
post_set_resource_identifiers:
template_path: hooks/capacity_reservation/post_set_resource_identifiers.go.tpl
sdk_read_many_post_set_output:
template_path: hooks/capacity_reservation/sdk_read_many_post_set_output.go.tpl
DhcpOptions:
exceptions:
terminal_codes:
Expand Down
2 changes: 1 addition & 1 deletion config/controller/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ kind: Kustomization
images:
- name: controller
newName: public.ecr.aws/aws-controllers-k8s/ec2-controller
newTag: 1.4.4
newTag: 1.4.5
6 changes: 6 additions & 0 deletions generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,14 @@ resources:
template_path: hooks/capacity_reservation/sdk_create_post_build_request.go.tpl
sdk_update_pre_build_request:
template_path: hooks/capacity_reservation/sdk_update_pre_build_request.go.tpl
sdk_update_post_build_request:
template_path: hooks/capacity_reservation/sdk_update_post_build_request.go.tpl
sdk_update_post_set_output:
template_path: hooks/capacity_reservation/sdk_update_post_set_output.go.tpl
post_set_resource_identifiers:
template_path: hooks/capacity_reservation/post_set_resource_identifiers.go.tpl
sdk_read_many_post_set_output:
template_path: hooks/capacity_reservation/sdk_read_many_post_set_output.go.tpl
DhcpOptions:
exceptions:
terminal_codes:
Expand Down
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v1
name: ec2-chart
description: A Helm chart for the ACK service controller for Amazon Elastic Cloud Compute (EC2)
version: 1.4.4
appVersion: 1.4.4
version: 1.4.5
appVersion: 1.4.5
home: https://github.com/aws-controllers-k8s/ec2-controller
icon: https://raw.githubusercontent.com/aws/eks-charts/master/docs/logo/aws.png
sources:
Expand Down
2 changes: 1 addition & 1 deletion helm/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ .Chart.Name }} has been installed.
This chart deploys "public.ecr.aws/aws-controllers-k8s/ec2-controller:1.4.4".
This chart deploys "public.ecr.aws/aws-controllers-k8s/ec2-controller:1.4.5".

Check its status by running:
kubectl --namespace {{ .Release.Namespace }} get pods -l "app.kubernetes.io/instance={{ .Release.Name }}"
Expand Down
2 changes: 1 addition & 1 deletion helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

image:
repository: public.ecr.aws/aws-controllers-k8s/ec2-controller
tag: 1.4.4
tag: 1.4.5
pullPolicy: IfNotPresent
pullSecrets: []

Expand Down
25 changes: 25 additions & 0 deletions pkg/resource/capacity_reservation/resource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions pkg/resource/capacity_reservation/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

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
}

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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

// set the instance count in spec from the total instance count in status,
// without this there's no diff detected for this field in the desired object and latest state in aws
// causing update calls to have no effect at all
if ko.Status.TotalInstanceCount != nil {
ko.Spec.InstanceCount = ko.Status.TotalInstanceCount
}
Comment on lines +5 to +7
Copy link
Member

Choose a reason for hiding this comment

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

👍

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

// If additionalInfo field is being updated, other fields cannot be modified simultaneously,
// hence we reset them or else we run into InvalidParameterCombination error
if input.AdditionalInfo != nil {
input.InstanceCount = nil
input.EndDate = nil
input.EndDateType = ""
input.InstanceMatchCriteria = ""
}