Skip to content

new resource ec2launch template and test caes #151

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

Closed

Conversation

rkurduka
Copy link

Issue #, if available:
1841

Description of changes:

New resource added - LaunchTemplate
Test cases added.

Features:

  1. Create new EC2 launch template
  2. Delete existing EC2 launch template

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 jljaco September 20, 2023 14:48
@ack-prow ack-prow bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 20, 2023
@ack-prow
Copy link

ack-prow bot commented Sep 20, 2023

Hi @rkurduka. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@a-hilaly
Copy link
Member

/ok-to-test

@ack-prow ack-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 20, 2023
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.

Good stuff, thank you @rkurduka ! I left few comments in-line

# Validate LaunchTemplate
launch_template = ec2_validator.get_launch_template(resource_id)
assert launch_template["LaunchTemplateId"] == resource_id

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 also add an update test?

Copy link
Author

Choose a reason for hiding this comment

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

To update launch template only one parameter is supported in "ModifyLaunchTemplate" SDK API call.

  1. DefaultVersionNumber -- for this to test , there has to be multiple "launchtemplateversions" must be available and "launchtemplateversion" is separate resource in EC2. So once we have that , so we can add update test case here for it.

Note:
update tags is not supported "ModifyLaunchTemplate" SDK API call , which is used in SDKUPDATE function, hence not added update test case yet .

Copy link
Member

Choose a reason for hiding this comment

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

Great, thanks for the clearance! We could support add some hooks to call CreateTags/UpdateTags for the Spec.Tags field?
If i understand well, this funciton can be used with any ec2 resource? https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateTags.html

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Yes , looking into this

Copy link
Author

Choose a reason for hiding this comment

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

added tags -creation/update logic , including test cases for it as well .

@rkurduka rkurduka closed this Sep 25, 2023
@rkurduka rkurduka force-pushed the ec2-template_without_version branch from 29f48f7 to dc920e9 Compare September 25, 2023 13:03
@rkurduka
Copy link
Author

fixed - conflicts

@rkurduka rkurduka reopened this Sep 25, 2023
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.

Very nice!! Thank you @rkurduka !

I have few comments/questions bellow.

func (rm *resourceManager) setDefaultTemplateVersion(r *resource, input *svcsdk.ModifyLaunchTemplateInput) error {

if r.ko.Spec.DefaultVersionNumber != nil {
input.SetDefaultVersion(strconv.Itoa(int(*r.ko.Spec.DefaultVersionNumber)))
Copy link
Member

Choose a reason for hiding this comment

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

So the API accept an int the create but a string in the update... wow

Copy link
Author

Choose a reason for hiding this comment

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

In "CreateLaunchTemplate" we dont need to provide "DefaultTemplateVersion" - but once it is created. In "DescribeLaunchTemplateOutput" Its *int64 , So while modifying same attribute in ModifyLaunchTemplate its *string , hence conversion is require

# Validate LaunchTemplate
launch_template = ec2_validator.get_launch_template(resource_id)
assert launch_template["LaunchTemplateId"] == resource_id

Copy link
Member

Choose a reason for hiding this comment

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

Great, thanks for the clearance! We could support add some hooks to call CreateTags/UpdateTags for the Spec.Tags field?
If i understand well, this funciton can be used with any ec2 resource? https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateTags.html

# Check LaunchTemplate no longer exists in AWS
ec2_validator.assert_launch_template(resource_id, exists=False)

def test_terminal_condition_invalid_parameter_value(self):
Copy link
Member

Choose a reason for hiding this comment

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

Awesome!

# Validate LaunchTemplate
launch_template = ec2_validator.get_launch_template(resource_id)
assert launch_template["LaunchTemplateId"] == resource_id

Copy link
Member

Choose a reason for hiding this comment

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

@ack-bot
Copy link
Collaborator

ack-bot commented Mar 29, 2024

Issues go stale after 180d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 60d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://github.com/aws-controllers-k8s/community.
/lifecycle stale

@ack-prow ack-prow bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 29, 2024
@a-hilaly a-hilaly removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 15, 2024
@kejne
Copy link
Contributor

kejne commented Jun 27, 2024

Is there anything particular blocking this PR from being merged, other than having a merge conflict after having been stale for 6m?

@kejne
Copy link
Contributor

kejne commented Jun 28, 2024

@rkurduka ok if i cherry pick your changes to keep working on the changes you started so we can get this functionality in?

@a-hilaly
Copy link
Member

a-hilaly commented Jul 2, 2024

@kejne please go for it :)

@a-hilaly
Copy link
Member

a-hilaly commented Sep 5, 2024

@kejne are you still thinking of picking up this PR?

@kejne
Copy link
Contributor

kejne commented Sep 5, 2024

I'm afraid other projects fit our use case better, so haven't looked further into it.

@a-hilaly
Copy link
Member

a-hilaly commented Sep 5, 2024

@kejne no worries :) may I ask what projects are you using to workaround this and manage launch templates?

@kejne
Copy link
Contributor

kejne commented Sep 5, 2024

It wasn't really just about Launch Templates, but more of the whole. For example, since we will be leveraging multiple cloud providers we are leaning more towards Crossplane atm.

@cedricmckinnie
Copy link

cedricmckinnie commented Dec 23, 2024

Hi everyone. This is a rather critical feature of ACK imo as it's a showstopper for customizing managed EKS nodes. Any chance we could revisit this PR?

@cedricmckinnie
Copy link

I will also add that the Services Page in the ACK docs indicates that the ec2-controller is GA but lacking the ability to create and maintain a fundamental feature like LaunchTemplates seems like a significant enough gap in it's functionality to consider it GA. This might be worth a little bit more attention.

My comment from related PR #155 (comment)

Copy link
Member

@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.

Hey @rkurduka, thanks for this PR! I left a few inline comments

Also I was thinking, would it be best to call the CreateTemplateVersion api during an update? We do something similar to resources that have Versions..https://github.com/aws-controllers-k8s/iam-controller/blob/6828e1c2e8fbc0b8f8cc1886eee38ba43ad1df71/pkg/resource/policy/hooks.go#L233-L266

We also released sdk-go-v2, so the hooks need few changes

generator.yaml Outdated
path: Status.LaunchTemplateID
name: LaunchTemplateID
DefaultVersionNumber:
type: int
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 need to make this an int? I saw the API accepts it as a string

Copy link
Author

Choose a reason for hiding this comment

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

@michaelhtm - yes Create and Modify APIs accept string , but describe API returns value as Int. And "DefaultVersionNumber" we will need in "Spec" as well for users to modify . So to make it consistent everywhere changed type as "int' . let me know your thoughts on this as well

Copy link
Member

Choose a reason for hiding this comment

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

I believe we should keep the type the same as the Create operation. But if this work too it should be okay with me!

Copy link
Member

Choose a reason for hiding this comment

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

is this removed by accident?

Copy link
Author

Choose a reason for hiding this comment

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

@michaelhtm - yes its added back now

Comment on lines 110 to 118
# Only user tags should be present in Spec
resource = k8s.get_resource(ref)
assert len(resource["spec"]["tags"]) == 1
assert resource["spec"]["tags"][0]["key"] == "newtagkey"
assert resource["spec"]["tags"][0]["value"] == "newtagvalue"

# Check user and ack tags on aws
launch_template = ec2_validator.get_launch_template(resource_id)
assert len(launch_template['Tags']) == 3
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

hi @michaelhtm - Made changes here as you suggested , let me know anything else is require

@rkurduka rkurduka force-pushed the ec2-template_without_version branch from 5b42f5f to cb1452a Compare February 27, 2025 14:17
Copy link

ack-prow bot commented Feb 27, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rkurduka
Once this PR has been reviewed and has the lgtm label, please assign jlbutler for approval by writing /assign @jlbutler in a comment. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rkurduka
Copy link
Author

Hey @rkurduka, thanks for this PR! I left a few inline comments

Also I was thinking, would it be best to call the CreateTemplateVersion api during an update? We do something similar to resources that have Versions..https://github.com/aws-controllers-k8s/iam-controller/blob/6828e1c2e8fbc0b8f8cc1886eee38ba43ad1df71/pkg/resource/policy/hooks.go#L233-L266

We also released sdk-go-v2, so the hooks need few changes

@michaelhtm - CreateTemplateVersion is separate resource in EC2 , there is PR opened for that as well . So only change in update is allow to change defaultVersion of template . And NewVersion can be created separately and users can provide sourcetemplate to get values from to create new version as well. Let me know your thoughts.

Also generated Ec2-Controller again with latest code generator and made all require changes in hooks. Let me know if anything else require

@michaelhtm
Copy link
Member

michaelhtm commented Feb 27, 2025

@michaelhtm - CreateTemplateVersion is separate resource in EC2 , there is PR opened for that as well . So only change in update is allow to change defaultVersion of template . And NewVersion can be created separately and users can provide sourcetemplate to get values from to create new version as well. Let me know your thoughts.

Also generated Ec2-Controller again with latest code generator and made all require changes in hooks. Let me know if anything else require

I see that. In the example I sent and here we have been calling CreateVersion as part of the update, so that ACK handles only one version of a resource.

This IAM PR has some explanation of the decision making>
aws-controllers-k8s/iam-controller#21

@rkurduka rkurduka force-pushed the ec2-template_without_version branch from cb1452a to 2d26a0c Compare March 3, 2025 07:18
@rkurduka rkurduka force-pushed the ec2-template_without_version branch from 03a142a to e7a3297 Compare March 25, 2025 16:52
Copy link

ack-prow bot commented Mar 25, 2025

@rkurduka: The following tests 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 e7a3297 link false /test ec2-verify-attribution
ec2-kind-e2e e7a3297 link true /test ec2-kind-e2e

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 a-hilaly closed this Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants