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

USHIFT-1545: Full VM name validation #3672

Merged
merged 4 commits into from
Jul 29, 2024

Conversation

vanhalenar
Copy link
Contributor

No description provided.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jul 23, 2024

@vanhalenar: This pull request references USHIFT-1545 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.17.0" version, but no target version was set.

In response to this:

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 23, 2024
@openshift-ci openshift-ci bot requested review from ggiguash and pliurh July 23, 2024 12:30
@vanhalenar
Copy link
Contributor Author

/retest


if [ -z "${vm_name}" ]; then
error "VM hostname cannot be empty string"
record_junit "${vmname}" "vm_name_validation" "FAILED"
Copy link
Member

Choose a reason for hiding this comment

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

Similar thing in other places

Suggested change
record_junit "${vmname}" "vm_name_validation" "FAILED"
record_junit "${vm_name}" "vm_name_validation" "FAILED"

@@ -227,6 +269,8 @@ prepare_kickstart() {
local -r vm_hostname="${full_vmname/./-}"
local -r hostname=$(hostname)

validate_full_vm_name $full_vmname
Copy link
Member

Choose a reason for hiding this comment

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

I think we want to validate vm_hostname since it'll be used for hostname.

Suggested change
validate_full_vm_name $full_vmname
validate_full_vm_name "${vm_hostname}"

fi

# split by '.' and check every section separately
IFS='.' read -ra ARR <<< "$vm_name"
Copy link
Member

Choose a reason for hiding this comment

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

If we validate $vm_hostname instead of $full_vmname, then we can remove this loop and flatten and merge the checks.

Comment on lines 58 to 62
if [[ "${vm_name}" =~ ^\. ]]; then
error "VM hostname cannot start with '.'"
record_junit "${vm_name}" "vm_hostname_validation" "FAILED"
exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this check? I mean if the name starts from ., wouldn't the next check fail?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, however this check has explicit error message about what is wrong

Copy link
Member

Choose a reason for hiding this comment

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

On the other hand: before passing the hostname to this function, we replace all . with -, so this won't be executed unless we do some refactoring and mess up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I removed it

@ggiguash
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 29, 2024
Copy link
Contributor

openshift-ci bot commented Jul 29, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ggiguash, vanhalenar

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

The pull request process is described here

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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2024
Copy link
Contributor

openshift-ci bot commented Jul 29, 2024

@vanhalenar: all tests passed!

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 74d37f3 into openshift:main Jul 29, 2024
10 checks passed
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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants