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.
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)
31
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 }
38
"pkg/asset/installconfig/clustername.go" 53 lines --50%--
Version-Release number of the following components:
4.3.0-0.nightly-2019-12-24-014531
How reproducible:
100%
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
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
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.
https://access.redhat.com/errata/RHBA-2020:0581
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) 31 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 } 38 "pkg/asset/installconfig/clustername.go" 53 lines --50%-- Version-Release number of the following components: 4.3.0-0.nightly-2019-12-24-014531 How reproducible: 100% 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