Bug 1786268 - Move GCP cluster name validation ahead of subdomain name validation
Summary: Move GCP cluster name validation ahead of subdomain name validation
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Installer
Version: 4.3.0
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
: 4.4.0
Assignee: Aditya Narayanaswamy
QA Contact: Yang Yang
Depends On:
TreeView+ depends on / blocked
Reported: 2019-12-24 07:04 UTC by Yang Yang
Modified: 2020-05-04 11:21 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: The validation for cluster names is done by openshift installer first and after which GCP validation is done, causing the error message to be thrown first by instead of the GCP error. Consequence: The error message suggests the installer does not allow symbols at the end of the names but GCP's validation error message would be preferred as GCP does not allow it and the user should know before creating a cluster. Fix: Changed the order of checking where now the GCP validation is done first. Result: If such a scenario occurs now, the error message printed will be that of a GCP origin.
Clone Of:
Last Closed: 2020-05-04 11:21:22 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Priority Status Summary Last Updated
Github openshift installer pull 2949 None closed Bug 1786268: Set GCP validation to precede domain validation. 2020-04-20 12:01:34 UTC
Red Hat Product Errata RHBA-2020:0581 None None None 2020-05-04 11:21:47 UTC

Description Yang Yang 2019-12-24 07:04:21 UTC
Description of problem:

When the cluster name matches neither cluster name rule nor domain rule, the error message is confused cause subdomain validation is ahead of cluster name validation in below function. As the gcp cluster name rule is subset of domain rule. For better user experience, I suggest to move gcp cluster name validation ahead of subdomain validation. Please check out below code

 27 func (a *clusterName) Generate(parents asset.Parents) error {
 28         bd := &baseDomain{}
 29         platform := &platform{}
 30         parents.Get(bd, platform)
 32         validator := survey.ComposeValidators(survey.Required, func(ans interface{}) error     {
 33                 return validate.DomainName(validation.ClusterDomain(bd.BaseDomain, ans.(str    ing)), false)
 34         })
 35         if platform.GCP != nil {
 36                 validator = survey.ComposeValidators(validator, func(ans interface{}) error     { 
                    return gcpvalidation.ValidateClusterName(ans.(string)) })
 37         }
"pkg/asset/installconfig/clustername.go" 53 lines --50%-- 

Version-Release number of the following components:


How reproducible:

Steps to Reproduce:

# openshift-install create install-config --dir=test
? Platform gcp
? Cluster Name [? for help] a123-

Actual results:

X Sorry, your reply was invalid: a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

Expected results:

X Sorry, your reply was invalid: GCP requires cluster name to match regular expression (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)

Additional info:
Please attach logs from ansible-playbook with the -vvv flag

Comment 2 Yang Yang 2020-02-03 02:54:07 UTC
Verified with openshift-install-linux-4.4.0-0.nightly-2020-02-03-021633

Steps of verification are as below:
# openshift-install create install-config --dir=bz
? SSH Public Key /root/.ssh/id_rsa.pub
? Platform gcp
INFO Credentials loaded from file "/root/.gcp/osServiceAccount.json" 
? Project ID openshift-qe
? Region us-central1
? Base Domain qe.gcp.devcluster.openshift.com
? Cluster Name [? for help] a123-
X Sorry, your reply was invalid: GCP requires cluster name to match regular expression (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)

The test results are as expected, so move it to verified status

Comment 4 errata-xmlrpc 2020-05-04 11:21:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.