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

OpenStack: add clusterOSImage validations #3964

Merged
merged 2 commits into from Oct 15, 2020

Conversation

Fedosin
Copy link
Contributor

@Fedosin Fedosin commented Jul 27, 2020

This commit adds validations that custom Glance image specified by clusterOSImage config parameter exists and has Active status.

@Fedosin
Copy link
Contributor Author

Fedosin commented Jul 27, 2020

/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 Jul 27, 2020
@Fedosin
Copy link
Contributor Author

Fedosin commented Jul 27, 2020

/test unit

@Fedosin
Copy link
Contributor Author

Fedosin commented Jul 28, 2020

/label platform/openstack

@Fedosin
Copy link
Contributor Author

Fedosin commented Jul 30, 2020

/retest

@Fedosin
Copy link
Contributor Author

Fedosin commented Jul 30, 2020

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 30, 2020
@Fedosin
Copy link
Contributor Author

Fedosin commented Jul 30, 2020

/test e2e-openstack

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 3, 2020

func (ci *CloudInfo) getImage(imageName string) (*images.Image, error) {
if imageName == "" {
return &images.Image{}, nil
Copy link
Member

Choose a reason for hiding this comment

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

Question: Why do you return a pointer to an empty image? I expected to see return nil nil here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an absolutely useless check and should be removed. when we call getImage we check that the image name is non-empty.
Thank you for pointing at this!

@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 9, 2020
@jstuever
Copy link
Contributor

jstuever commented Oct 9, 2020

/uncc

@openshift-ci-robot openshift-ci-robot removed the request for review from jstuever October 9, 2020 16:43
@iamemilio
Copy link

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 9, 2020
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Oct 9, 2020

@Fedosin: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-aws-workers-rhel7 1734b5d link /test e2e-aws-workers-rhel7
ci/prow/e2e-metal-ipi 1734b5d link /test e2e-metal-ipi
ci/prow/e2e-ovirt 1734b5d link /test e2e-ovirt
ci/prow/e2e-libvirt 1734b5d link /test e2e-libvirt

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

@Fedosin
Copy link
Contributor Author

Fedosin commented Oct 12, 2020

/test e2e-aws

imagePtr := ic.OpenStack.ClusterOSImage
if imagePtr != "" {
if _, err := url.ParseRequestURI(imagePtr); err != nil {
ci.OSImage, err = ci.getImage(imagePtr)
Copy link
Contributor

Choose a reason for hiding this comment

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

this err here is not handled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh... my bad :( thanks for noticing!

Comment on lines 142 to 143
// If the user input is an http address, then skip the validation
if _, err := url.ParseRequestURI(p.ClusterOSImage); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

this comment does not match what is being done here, it's checking for a valid URI which includes any scheme not just http.

if you support http and https only, add validation for that here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, agree. but we also support 'file' to get images from the local file system.

return
}

// Image should exist
Copy link
Contributor

Choose a reason for hiding this comment

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

can you expand here why image should exist or where it should exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


// Image should be active
if ci.OSImage.Status != images.ImageStatusActive {
allErrs = append(allErrs, field.Invalid(fldPath.Child("clusterOSImage"), p.ClusterOSImage, "image is not active"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
allErrs = append(allErrs, field.Invalid(fldPath.Child("clusterOSImage"), p.ClusterOSImage, "image is not active"))
allErrs = append(allErrs, field.Invalid(fldPath.Child("clusterOSImage"), p.ClusterOSImage, "image must be active but it was %s"))

Copy link
Contributor

Choose a reason for hiding this comment

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

provide details on the failed image.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

expectedError bool
expectedErrMsg string // NOTE: this is a REGEXP
Copy link
Contributor

Choose a reason for hiding this comment

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

expectedError bool is just duplication of the requirement from expectedErrMsg string, if expectedErrMsg is not empty the error must match that regex else when empty there should be no error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed it

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 14, 2020
switch uri.Scheme {
case "http", "https", "file":
default:
allErrs = append(allErrs, field.Invalid(fldPath.Child("clusterOSImage"), p.ClusterOSImage, fmt.Sprintf("URL scheme should be either http(s) or file but it is '%v'", uri.Scheme)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Go has fmt directive %q which will quote the string


// Image should have "active" status
if ci.OSImage.Status != images.ImageStatusActive {
allErrs = append(allErrs, field.Invalid(fldPath.Child("clusterOSImage"), p.ClusterOSImage, fmt.Sprintf("OS image must be active but its status is '%s'", ci.OSImage.Status)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Go has fmt directive %q which will quote the string

@abhinavdahiya
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya

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-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 14, 2020
@openshift-merge-robot
Copy link
Contributor

@Fedosin: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-crc 58e8e6e link /test e2e-crc
ci/prow/e2e-metal-ipi 58e8e6e link /test e2e-metal-ipi
ci/prow/e2e-libvirt 58e8e6e link /test e2e-libvirt

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

@iamemilio
Copy link

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 15, 2020
@openshift-merge-robot openshift-merge-robot merged commit 0dfd15c into openshift:master Oct 15, 2020
Fedosin added a commit to Fedosin/installer that referenced this pull request Oct 16, 2020
Previously we validate overriden Glance images during generation
of tfvars variables. This is not a correct place to do it, so we
implemented the check in the "validation" module:
openshift#3964

To prevent code duplication we should remove the legacy code.
Fedosin added a commit to Fedosin/installer that referenced this pull request Oct 17, 2020
Previously we validate overriden Glance images during generation
of tfvars variables. This is not a correct place to do it, so we
implemented the check in the "validation" module:
openshift#3964

To prevent code duplication we should remove the legacy code.
kwoodson pushed a commit to kwoodson/installer that referenced this pull request Nov 30, 2020
Previously we validate overriden Glance images during generation
of tfvars variables. This is not a correct place to do it, so we
implemented the check in the "validation" module:
openshift#3964

To prevent code duplication we should remove the legacy code.
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. platform/openstack
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants