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
OpenStack: add clusterOSImage validations #3964
Conversation
/hold |
/test unit |
/label platform/openstack |
/retest |
/hold cancel |
/test e2e-openstack |
|
||
func (ci *CloudInfo) getImage(imageName string) (*images.Image, error) { | ||
if imageName == "" { | ||
return &images.Image{}, nil |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
00e4728
to
1734b5d
Compare
/uncc |
/lgtm |
@Fedosin: The following tests failed, say
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. |
/test e2e-aws |
imagePtr := ic.OpenStack.ClusterOSImage | ||
if imagePtr != "" { | ||
if _, err := url.ParseRequestURI(imagePtr); err != nil { | ||
ci.OSImage, err = ci.getImage(imagePtr) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
// If the user input is an http address, then skip the validation | ||
if _, err := url.ParseRequestURI(p.ClusterOSImage); err == nil { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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")) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed it
1734b5d
to
58e8e6e
Compare
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))) |
There was a problem hiding this comment.
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))) |
There was a problem hiding this comment.
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
/approve |
[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 |
@Fedosin: The following tests failed, say
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. |
/lgtm |
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.
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.
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.
This commit adds validations that custom Glance image specified by
clusterOSImage
config parameter exists and has Active status.