Skip to content

Conversation

@wking
Copy link
Member

@wking wking commented Jan 17, 2019

For folks who use multi-component cluster names like jliu-beta1.test20190117, this change avoids raising errors like:

ERROR Error: module.vpc.aws_lb.api_external: only alphanumeric characters and hyphens allowed in "name": "jliu-beta1.test20190117-ext"
ERROR
ERROR Error: module.vpc.aws_lb.api_internal: only alphanumeric characters and hyphens allowed in "name": "jliu-beta1.test20190117-int"
ERROR
ERROR Error: module.vpc.aws_lb_target_group.api_external: only alphanumeric characters and hyphens allowed in "name"
ERROR
ERROR Error: module.vpc.aws_lb_target_group.api_internal: only alphanumeric characters and hyphens allowed in "name"
ERROR
ERROR Error: module.vpc.aws_lb_target_group.services: only alphanumeric characters and hyphens allowed in "name"

I'm using HCL's replace function with a regular expression to replace everything except the characters the error message claims are supported. I've allowed both upper and lower case, because RFC 952 has:

A "name" (Net, Host, Gateway, or Domain name) is a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-), and period (.). Note that periods are only allowed when they serve to delimit components of "domain style names". (See RFC-921, "Domain Name System Implementation Schedule", for background). No blank or space characters are permitted as part of a name. No distinction is made between upper and lower case.

But I haven't checked IsDNS1123Subdomain to see how it handles case.

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 17, 2019
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 17, 2019
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we name this variable something else, like lb_base_name? Having a variable with the same name in var and local and using them both in places makes it difficult to know which one is the right one to use where.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we name this variable something else, like lb_base_name?

Done with 0615c32 -> 7c3a98b.

For folks who use multi-component cluster names like
jliu-beta1.test20190117, this change avoids raising errors like [1]:

  ERROR Error: module.vpc.aws_lb.api_external: only alphanumeric characters and hyphens allowed in "name": "jliu-beta1.test20190117-ext"
  ERROR
  ERROR Error: module.vpc.aws_lb.api_internal: only alphanumeric characters and hyphens allowed in "name": "jliu-beta1.test20190117-int"
  ERROR
  ERROR Error: module.vpc.aws_lb_target_group.api_external: only alphanumeric characters and hyphens allowed in "name"
  ERROR
  ERROR Error: module.vpc.aws_lb_target_group.api_internal: only alphanumeric characters and hyphens allowed in "name"
  ERROR
  ERROR Error: module.vpc.aws_lb_target_group.services: only alphanumeric characters and hyphens allowed in "name"

I'm using HCL's replace function [2] with a regular expression to
replace everything except the characters the error message claims are
supported.  I've allowed both upper and lower case, because [3] has:

  A "name" (Net, Host, Gateway, or Domain name) is a text string up to
  24 characters drawn from the alphabet (A-Z), digits (0-9), minus
  sign (-), and period (.).  Note that periods are only allowed when
  they serve to delimit components of "domain style names". (See
  RFC-921, "Domain Name System Implementation Schedule", for
  background).  No blank or space characters are permitted as part of
  a name.  No distinction is made between upper and lower case.

But I haven't checked IsDNS1123Subdomain to see how it handles case.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1666956#c0
[2]: https://www.terraform.io/docs/configuration/interpolation.html#replace-string-search-replace-
[3]: https://tools.ietf.org/html/rfc952
@wking wking force-pushed the cluster-names-with-dots branch from 0615c32 to 7c3a98b Compare January 17, 2019 20:34
@openshift-ci-robot
Copy link
Contributor

@wking: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/prow/e2e-aws 7c3a98b link /test e2e-aws

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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.


// Only reference data sources which are gauranteed to exist at any time (above) in this locals{} block
locals {
lb_base_name = "${replace(var.cluster_name, "/[^A-Za-z0-9-]/", "-")}"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Is that last hyphen in the regex necessary?

Copy link
Member Author

@wking wking Jan 17, 2019

Choose a reason for hiding this comment

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

No. As it stands, it is "replace all but {legal chars, including hyphens} with hyphens". Without the trailing -, it wold be replacing the input - with -. You'd want the trailing - if the replacement was an empty string, etc. Did you want me to change it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, duh. Ignore me.

@crawford
Copy link
Contributor

/approve
/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 17, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: crawford, wking

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

The pull request process is described here

Details 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

@abhinavdahiya
Copy link
Contributor

we depend on predictive nature of some AWS resources, like IAM roles, subnets. SO rather than doing this for LB in terraform, Can we do this in Go? Maybe create a sanitized cluster-name that we can use in all our resources that we think are sensitive to these kind of things..

@wking
Copy link
Member Author

wking commented Jan 17, 2019

Can we do this in Go?

Can we punt on that until we need Go to reference a sanitized name?

@abhinavdahiya
Copy link
Contributor

Can we do this in Go?

Can we punt on that until we need Go to reference a sanitized name?

IMO i don't want any new addition to terraform codebase wrt changes like sanitization... but i'm okay punting if others think we can fix it later, no strong opinions ;)

@wking
Copy link
Member Author

wking commented Jan 18, 2019

IMO i don't want any new addition to terraform codebase wrt changes like sanitization...

Cheap compromise would be dropping cluster-name from those entries like we did for buckets in #489 ;). My issue with plumbing back into Go before we have a consumer is that I don't know how far back to take it. Just to pkg/tfvars? All the way back to pkg/assets/installconfig (although obviously not into InstallConfig?

Personally, I don't see a lot of maintenance space between ${var.cluster_name}-int and ${replace(var.cluster_name, "/[^A-Za-z0-9-]/", "-")}-int in Terraform. Both are "tweak the user-provided cluster name a bit in Terraform to generate a name for this resource".

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 23, 2019
@openshift-ci-robot
Copy link
Contributor

@wking: PR needs rebase.

Details

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.

@wking
Copy link
Member Author

wking commented Feb 26, 2019

Addressed by a37a4eb (#1280).

@wking wking closed this Feb 26, 2019
@wking wking deleted the cluster-names-with-dots branch February 26, 2019 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. platform/aws size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants