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 allow several instance types #54

Merged
merged 6 commits into from
Mar 1, 2021
Merged

Fix allow several instance types #54

merged 6 commits into from
Mar 1, 2021

Conversation

patrickjahns
Copy link
Contributor

what

  • Allow to specify more than a single instance_types for eks node groups
  • Possible to pass more than a single item in the list since the the introduction of capacity_type see upstream pr

why

  • For utilising SPOT instances it is a good practice to specify more than a single instance type

references

With the introduction of SPOT instances for managed node groups
it is also now possible to specify more than a single instance_type
@patrickjahns patrickjahns requested review from a team as code owners January 20, 2021 11:08
@patrickjahns patrickjahns requested review from jamengual and joe-niland and removed request for a team January 20, 2021 11:08
@patrickjahns patrickjahns requested a review from a team as a code owner January 20, 2021 11:09
@SweetOps SweetOps added the patch A minor, backward compatible change label Jan 21, 2021
@SweetOps
Copy link
Contributor

/test all

@patrickjahns
Copy link
Contributor Author

I'll take a look later at fixing the tests - seems to be that they expect the validation message to be in a certain format.
Anything else I should consider ?

@SweetOps
Copy link
Contributor

Anything else I should consider ?

fix of validation message should be enough

patrickjahns and others added 2 commits January 21, 2021 18:23
Signed-off-by: Patrick Jahns <github@patrickjahns.de>
@patrickjahns
Copy link
Contributor Author

/test all

🤞 - hope this works

Nuru
Nuru previously requested changes Jan 21, 2021
Copy link
Contributor

@Nuru Nuru left a comment

Choose a reason for hiding this comment

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

@osterman @aknysh We need to discuss how to support this feature moving forward.

One problem is that supporting this feature requires AWS Terraform provider >= 3.20 and I do not know if we want to push that requirement on our customers. At a minimum, though, we need to make that change in versions.tf as part of this PR.

A bigger problem is that AWS is currently split on how they support this, which brings us a split in how we can support it. I would prefer to defer support until AWS resolves their split, but I can see where our customers would get upset about that.

According to the AWS documentation:

If you specify launchTemplate, then you can specify zero or one instance type in your launch template or you can specify 0-20 instance types for instanceTypes.

The problem for us with this module is that there are a set of features only available by specifying the launch template: See

features_require_launch_template = local.enabled ? length(var.resources_to_tag) > 0 || local.need_userdata || local.features_require_ami : false

This module automatically creates a launch template if the requested configuration requires it, which means that it is not obvious whether or not you can specify more than one instance type, and makes error messages confusing. (I think the test for whether or not we can have more than once instance type is more complex than allowed in a custom validation. If I am wrong about that, then I guess a custom validation with appropriate explanation would be they way to move forward.)

@patrickjahns
Copy link
Contributor Author

@Nuru

One problem is that supporting this feature requires AWS Terraform provider >= 3.20 and I do not know if we want to push that requirement on our customers. At a minimum, though, we need to make that change in versions.tf as part of this PR.

The support for capacity_type was already added in #45 - so my assumption was, that this requirement for the provider version was already "approved"

Regarding:

If you specify launchTemplate, then you can specify zero or one instance type in your launch template or you can specify 0-20 instance types for instanceTypes.

The next sentences from the AWS documentation clarified it the launch template situation for me

If however, you specify an instance type in your launch template and specify any instanceTypes, the node group deployment will fail

So I understood this, as that you are limited to 0-1 instance-types when you specify it via the launch template - but if you specify the instance types via the instance_types in the aws_eks_node_group resource it should not be a problem.

For users of the module, it is probably good to raise awareness, that when they use a custom launch template they shall rather omit the instance_type in the launch template to be able to specify more than a single type for a node group

@patrickjahns
Copy link
Contributor Author

Anything I can do here to move forward with this PR?

@mergify
Copy link

mergify bot commented Feb 5, 2021

This pull request is now in conflict. Could you fix it @patrickjahns? 🙏

@mergify mergify bot dismissed Nuru’s stale review February 23, 2021 22:34

This Pull Request has been updated, so we're dismissing all reviews.

variables.tf Outdated
EOT
validation {
condition = (
length(var.instance_types) == 1
length(var.instance_types) > 20
Copy link
Contributor

Choose a reason for hiding this comment

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

The condition argument is an expression that must use the value of the variable to return true if the value is valid, or false if it is invalid.

Suggested change
length(var.instance_types) > 20
length(var.instance_types) >= 1 && length(var.instance_types) <= 20

@Nuru
Copy link
Contributor

Nuru commented Feb 24, 2021

One remaining issue is that this module creates launch templates implicitly for the user to enable certain features. We now need to update the module so that the launch template does NOT specify instance types and ensure that the aws_eks_node_group ALWAYS specifies instance types.

@patrickjahns patrickjahns requested a review from a team as a code owner March 1, 2021 02:55
@Nuru Nuru added enhancement New feature or request and removed patch A minor, backward compatible change labels Mar 1, 2021
@Nuru
Copy link
Contributor

Nuru commented Mar 1, 2021

/test all

@Nuru Nuru merged commit 61ac930 into cloudposse:master Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants