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

Add validation for k8s label length restrictions #261

Merged
merged 6 commits into from
Nov 25, 2021
Merged

Conversation

aidy
Copy link
Contributor

@aidy aidy commented Nov 3, 2021

connects #242

@cookpad cookpad deleted a comment from github-actions bot Nov 3, 2021
@cookpad cookpad deleted a comment from github-actions bot Nov 3, 2021
@aidy aidy force-pushed the label_length_error branch 5 times, most recently from 672b68e to ba52eca Compare November 4, 2021 11:30
@aidy aidy requested review from a team, ettiee and takanabe and removed request for a team November 9, 2021 11:09
@aidy aidy force-pushed the label_length_error branch 2 times, most recently from 5ca6b9a to 4eb049a Compare November 10, 2021 13:49
@ettiee
Copy link
Contributor

ettiee commented Nov 16, 2021

📝 upgrading the terraform version requirement to >=0.14 is a breaking change for users using <0.14, and as this is a bug fix we'd want to patch this back to 3 previous minor versions of the module. Looks like you needed to use variable validation for the fix so you had to upgrade to >=0.13. We should consider if we want to introduce breaking changes in patch releases

@ettiee ettiee removed the request for review from takanabe November 16, 2021 14:32
var.gpu ? { "nvidia.com/gpu" = "true" } : {},
var.labels,
)
}

data "assert_test" "node_group_label" {
test = length(local.node_group_label) < 64
throw = "node-group.k8s.cookpad.com/name label must be 63 characters or less"
Copy link
Contributor

Choose a reason for hiding this comment

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

This error message might not be intuitive to some users - maybe give some indication of what variable to change to not hit the error?
E.g. update name variable
maybe throw contents of node_group_label too so they can inspect

Copy link
Contributor Author

@aidy aidy Nov 19, 2021

Choose a reason for hiding this comment

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

Yeah, I had some conflict about what to do here - the general style of tf errors seems to be to just state the error, rather than suggested resolutions.

I think the tf philosophy is that it's not supposed to be a black box, and it's intended to be inspected, but you're probably right, and it's better to be more verbose, even if that's not in keeping with the style of other errors.

@@ -17,6 +17,11 @@ variable "name" {
type = string
default = ""
description = "An optional identifier for this node group"

validation {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe covered by https://github.com/cookpad/terraform-aws-eks/pull/261/files#r750337723 already (and vice versa). This validation is more intuitive to a user

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The vice versa doesn't apply, as if this isn't present, the label is calculated.

Although this is redundant, it seemed more user friendly to duplicate it here. Also, I think the native tf validation fail is nicer.

@ettiee
Copy link
Contributor

ettiee commented Nov 17, 2021

📝 upgrading the terraform version requirement to >=0.14 is a breaking change for users using <0.14, and as this is a bug fix we'd want to patch this back to 3 previous minor versions of the module. Looks like you needed to use variable validation for the fix so you had to upgrade to >=0.13. We should consider if we want to introduce breaking changes in patch releases

Discussed in person - this isn't really a bug fix to patch back to previous releases. If users hit this they won't have a successfully deployed cluster, so nobody would be patching this into a deployed cluster. It's an improvement we'll include in 1.20.0

@aidy aidy force-pushed the label_length_error branch 2 times, most recently from 0d86974 to 8990017 Compare November 19, 2021 15:48
Copy link
Contributor

@ettiee ettiee left a comment

Choose a reason for hiding this comment

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

🚢

The version of terratest we're using has some incompatibilities with the
output of later versions of terraform.

Upgrade to the latest version in preparation for tf upgrade.
Pin version of cluster/environment so that we don't break other tests,
as we persist that state file.
kubernetes labels have a 63 character limitation:
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set

As node-group label names may be calculated, they could exceed this
length, which results in bottlerocket configuration errors.
As the node-group name variable is used as a label for kubernetes, add
validation that it does not exceed the character limitation.
k8s labels should be 63 characters or less, or nodes may fail to launch
due to misconfiguration.
@aidy aidy merged commit cfe7b72 into main Nov 25, 2021
@aidy aidy deleted the label_length_error branch November 25, 2021 12:19
ettiee added a commit that referenced this pull request Dec 14, 2021
ettiee added a commit that referenced this pull request Dec 14, 2021
Fix UPGRADING.md with breaking change from #261
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants