Skip to content

vsphere: Validate vcenter user input to match RFC standards#4708

Merged
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
rna-afk:vsphere_vcenter_validation
Mar 8, 2021
Merged

vsphere: Validate vcenter user input to match RFC standards#4708
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
rna-afk:vsphere_vcenter_validation

Conversation

@rna-afk
Copy link
Copy Markdown
Contributor

@rna-afk rna-afk commented Mar 3, 2021

Vcenter input must always only be the hostname yet it is possible
for the user to provide other types of input like URLs. URLs would
cause an error to occur only during the time of cluster creation
as connection to the vcenter would succeed.

Adding a validation check for the user input for the vcenter value
so that it conforms to the RFC-1035 standard and forces the user
to re-enter the value rather than throw an error during cluster
creation.

@rna-afk
Copy link
Copy Markdown
Contributor Author

rna-afk commented Mar 3, 2021

/assign @staebler

@rna-afk
Copy link
Copy Markdown
Contributor Author

rna-afk commented Mar 3, 2021

/test e2e-vsphere

@rna-afk
Copy link
Copy Markdown
Contributor Author

rna-afk commented Mar 3, 2021

/retest

1 similar comment
@rna-afk
Copy link
Copy Markdown
Contributor Author

rna-afk commented Mar 3, 2021

/retest

@patrickdillon
Copy link
Copy Markdown
Contributor

/cc jstuever

This validation is only being applied to survey. It should also be applied to the install config.

@rna-afk rna-afk force-pushed the vsphere_vcenter_validation branch 3 times, most recently from 8d598fd to 7096efc Compare March 4, 2021 15:11
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This check is not quite what we need.

  1. It is valid for the vCenter hostname to be an IP address.
  2. We should not validate the length of the hostname.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think that we need to show this much detail in the error here. The user is not picking a hostname: The user is inputting what should be an existing hostname. This error should say something simpler like

must be the hostname of the vCenter

Comment thread pkg/validate/validate_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding this test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Was using that function and it didn't have a test so thought I'd add it.

@rna-afk rna-afk force-pushed the vsphere_vcenter_validation branch 3 times, most recently from a9206b4 to 3be360e Compare March 5, 2021 14:58
@rna-afk
Copy link
Copy Markdown
Contributor Author

rna-afk commented Mar 5, 2021

/test e2e-vsphere

@rna-afk
Copy link
Copy Markdown
Contributor Author

rna-afk commented Mar 5, 2021

/retest

Comment thread pkg/validate/validate.go Outdated
Comment thread pkg/types/vsphere/validation/platform.go Outdated
Comment thread pkg/asset/installconfig/vsphere/vsphere.go Outdated
@rna-afk rna-afk force-pushed the vsphere_vcenter_validation branch 2 times, most recently from c35d506 to b4662da Compare March 5, 2021 19:09
Copy link
Copy Markdown
Contributor

@staebler staebler left a comment

Choose a reason for hiding this comment

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

Looks good. Just two small nits.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For consistency,

Suggested change
Help: "The hostname or IP address of the vCenter to be used for installation.",
Help: "The domain name or IP address of the vCenter to be used for installation.",

Comment thread pkg/validate/validate.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Host validates that a given string is either a valid URI host.
// Host validates that a given string is a valid URI host.

Comment thread pkg/validate/validate.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return errors.New("cluster name must begin with a lower-case letter")
return errors.New("domain name must begin with a lower-case letter")

Vcenter input must always only be the hostname yet it is possible
for the user to provide other types of input like URLs. URLs would
cause an error to occur only during the time of cluster creation
as connection to the vcenter would succeed.

Adding a validation check for the user input for the vcenter value
so that it conforms to the RFC-1035 standard and forces the user
to re-enter the value rather than throw an error during cluster
creation.
@rna-afk rna-afk force-pushed the vsphere_vcenter_validation branch from b4662da to 7c98e02 Compare March 8, 2021 04:40
@rna-afk
Copy link
Copy Markdown
Contributor Author

rna-afk commented Mar 8, 2021

/test e2e-vsphere

@staebler
Copy link
Copy Markdown
Contributor

staebler commented Mar 8, 2021

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 8, 2021
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: staebler

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 8, 2021
@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

7 similar comments
@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Mar 8, 2021

@rna-afk: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-aws-workers-rhel7 7c98e02 link /test e2e-aws-workers-rhel7

Full PR test history. Your PR dashboard.

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.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

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. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants