Skip to content
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

fix: Avoid launch template creation loop when switching from launch config and failing #346

Merged
merged 3 commits into from
Feb 11, 2022
Merged
Changes from all 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
6 changes: 4 additions & 2 deletions controllers/provisioners/eks/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ func (ctx *EksInstanceGroupContext) CloudDiscovery() error {
if spec.IsLaunchConfiguration() {

state.ScalingConfiguration, err = scaling.NewLaunchConfiguration(instanceGroup.NamespacedName(), ctx.AwsWorker, &scaling.DiscoverConfigurationInput{
ScalingGroup: targetScalingGroup,
ScalingGroup: targetScalingGroup,
TargetConfigName: state.ScalingConfiguration.Name(),
})
if err != nil {
return errors.Wrap(err, "failed to discover launch configurations")
Expand All @@ -238,7 +239,8 @@ func (ctx *EksInstanceGroupContext) CloudDiscovery() error {

if spec.IsLaunchTemplate() {
state.ScalingConfiguration, err = scaling.NewLaunchTemplate(instanceGroup.NamespacedName(), ctx.AwsWorker, &scaling.DiscoverConfigurationInput{
ScalingGroup: targetScalingGroup,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the current implementation discovers the active launch template by the scaling group name, can you look inside NewLaunchTemplate and see if there is a reason this is not happening?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we are not setting TargetConfigName inside Discover:
https://github.com/sahilbadla/instance-manager/blob/58ad1a253a80900c2a1047c5809ca1d94e300d00/controllers/provisioners/eks/scaling/launchtemplate.go#L58

Can you try that instead?
That way we don't rely on status field, but rather discover the active Launch Template name each time from the scaling group name.

ScalingGroup: targetScalingGroup,
TargetConfigName: state.ScalingConfiguration.Name(),
})
if err != nil {
return errors.Wrap(err, "failed to discover launch templates")
Expand Down