Skip to content

feat: new resource - LaunchTemplate #255

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

Merged

Conversation

michaelhtm
Copy link
Member

Issue #1841

Description of changes:
Adding support for LaunchTemplate.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from a-hilaly and jlbutler March 28, 2025 18:26
@ack-prow ack-prow bot added the approved label Mar 28, 2025
@michaelhtm michaelhtm force-pushed the newResource/LaunchTemplate branch 5 times, most recently from c42abc5 to c739883 Compare March 28, 2025 22:48
@michaelhtm
Copy link
Member Author

/retest

@michaelhtm michaelhtm force-pushed the newResource/LaunchTemplate branch 3 times, most recently from f7ac8eb to ac413db Compare March 29, 2025 01:07
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

Thanks @michaelhtm ! some comments inline

return err
}

for _, elem := range resp.LaunchTemplateVersions {
Copy link
Member

Choose a reason for hiding this comment

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

i think function can be generated using custom templates and sdk_file_end

Copy link
Member Author

Choose a reason for hiding this comment

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

putting setResourceForLaunchTemplateData there since that's the setter with the most LOC

}
var resp *svcsdk.DescribeLaunchTemplatesOutput
resp, err = rm.sdkapi.DescribeLaunchTemplates(ctx, input)
rm.metrics.RecordAPICall("READ_MANY", "DescribeLaunchTemplates", err)
Copy link
Member

Choose a reason for hiding this comment

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

Do we want make the DescribeLaunchVersion here instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

i'm not opposed to it..

Comment on lines +555 to +561
DefaultVersion:
from:
operation: ModifyLaunchTemplate
path: LaunchTemplate.DefaultVersionNumber
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this field a string instead? i like integer, but looks like the api takes a string, maybe cause they support non integer versions?

Copy link
Member Author

@michaelhtm michaelhtm Mar 31, 2025

Choose a reason for hiding this comment

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

There's only one use case where it's used as a string...the rest of the time it's a number..
The Create API returns a string, while the ModifyLaunchTemplate accepts a string

Comment on lines +728 to +129
// TODO (michaelhtm) Not sure if we should check if
// the defaultVersion is greater than latestVersion
//
// My proposal would be to return a terminal error
// since the launchTemplate's latestVersion will never
// increase intil we make updates...˘\\/(ヅ)\/˘˘
// if *desired.ko.Spec.DefaultVersion > *latest.ko.Status.LatestVersion {
// return ackerr.NewTerminalError(fmt.Errorf("desired version number is ahead of the latest version"))
// }
Copy link
Member

Choose a reason for hiding this comment

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

I like it.

@michaelhtm michaelhtm force-pushed the newResource/LaunchTemplate branch 5 times, most recently from 27c2335 to 3c8e066 Compare March 31, 2025 08:15
Copy link
Member Author

@michaelhtm michaelhtm left a comment

Choose a reason for hiding this comment

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

adding thoughts..

LatestVersion *int64 `json:"latestVersion,omitempty"`
// The entity that manages the launch template.
// +kubebuilder:validation:Optional
Operator *OperatorResponse `json:"operator,omitempty"`
Copy link
Member Author

Choose a reason for hiding this comment

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

I believe this field does not make sense for kubernetes..if another entity is managing this launchTemplate, we might encounter diffs whenever the entity makes changes

Copy link
Member

Choose a reason for hiding this comment

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

shall we remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's not affecting anything significant since it's in the status..so idk

// +kubebuilder:validation:Required
Data *RequestLaunchTemplateData `json:"data"`
// The version number of the default version of the launch template.
DefaultVersion *int64 `json:"defaultVersion,omitempty"`
Copy link
Member Author

@michaelhtm michaelhtm Mar 31, 2025

Choose a reason for hiding this comment

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

Having DefaultVersion in the spec is risky, and a one way decision. We need to discuss this before merging..

Currently, when a launchTemplate is created, and later updated, the DefaultVersion will no longer be matching the data in the spec. This may not be ideal IMO.

If we put the defaultVersion in the status, we can start ignoring the latestVersion there and combine them both into one field called Version.
This Version will reflect the data in the spec, and with every update, we can call the APIs necessary to Create a new version with the latest data, ensure that version is the defaultVersion, delete the older version.

Thoughts?

return err
}

for _, elem := range resp.LaunchTemplateVersions {
Copy link
Member Author

Choose a reason for hiding this comment

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

putting setResourceForLaunchTemplateData there since that's the setter with the most LOC

@michaelhtm michaelhtm force-pushed the newResource/LaunchTemplate branch 3 times, most recently from 5229cca to 5c88415 Compare March 31, 2025 17:41
@michaelhtm
Copy link
Member Author

/retest

Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

Thanks @michaelhtm ! i left a couple questions below

Comment on lines +122 to +123
assert default_version == cr['spec']['defaultVersion']
assert latest_version == cr['status']['latestVersion']
Copy link
Member

Choose a reason for hiding this comment

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

So even if the user doesn't specific a default version, we patch one back to the CR? do we want that behaviour?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, at least after the create Operation...or would it make sense to put it in status?

@michaelhtm michaelhtm force-pushed the newResource/LaunchTemplate branch from 5c88415 to 77bc52a Compare March 31, 2025 21:25
LatestVersion *int64 `json:"latestVersion,omitempty"`
// The entity that manages the launch template.
// +kubebuilder:validation:Optional
Operator *OperatorResponse `json:"operator,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

shall we remove it?

Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

👍

@michaelhtm michaelhtm force-pushed the newResource/LaunchTemplate branch 2 times, most recently from 39b8a4c to f1b371f Compare March 31, 2025 23:43
@michaelhtm
Copy link
Member Author

/retest

Adding support for LaunchTemplate.

Co-Authored-By: Rohit Kurdukar - Amazon <[email protected]>
@michaelhtm michaelhtm force-pushed the newResource/LaunchTemplate branch from f1b371f to d71330d Compare April 1, 2025 00:27
@michaelhtm
Copy link
Member Author

/test ec2-kind-e2e

@michaelhtm
Copy link
Member Author

/retest

@a-hilaly
Copy link
Member

a-hilaly commented Apr 1, 2025

Mmmm ... the test failures seem unrelated to the changes

@michaelhtm
Copy link
Member Author

/retest

1 similar comment
@michaelhtm
Copy link
Member Author

/retest

Copy link

ack-prow bot commented Apr 1, 2025

@michaelhtm: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ec2-verify-attribution d71330d link false /test ec2-verify-attribution

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@a-hilaly
Copy link
Member

a-hilaly commented Apr 1, 2025

/lgtm

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Apr 1, 2025
@a-hilaly
Copy link
Member

a-hilaly commented Apr 1, 2025

/lgtm cancel

@ack-prow ack-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 1, 2025
@a-hilaly
Copy link
Member

a-hilaly commented Apr 1, 2025

/lgtm

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Apr 1, 2025
Copy link

ack-prow bot commented Apr 1, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a-hilaly, michaelhtm

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [a-hilaly,michaelhtm]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow bot merged commit 298fc7d into aws-controllers-k8s:main Apr 1, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants