-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
CORS-3917: Add install config validation for service endpoints #9517
base: main
Are you sure you want to change the base?
Conversation
@barbacbd: This pull request references CORS-3917 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 story to target the "4.19.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. |
** check whether the user provided endpoints are reachable or not.
@barbacbd: 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-sigs/prow repository. I understand the commands that are listed 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.
LGTM, just some comments. Sorry for too many nits 😅
continue | ||
} | ||
if _, err := url.Parse(serviceEndpoint.URL); err != nil { | ||
allErrs = append(allErrs, field.Invalid(fieldPath.Child("serviceEndpoint").Index(id), serviceEndpoint.URL, err.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.
allErrs = append(allErrs, field.Invalid(fieldPath.Child("serviceEndpoint").Index(id), serviceEndpoint.URL, err.Error())) | |
allErrs = append(allErrs, field.Invalid(fieldPath.Child("serviceEndpoints").Index(id), serviceEndpoint.URL, err.Error())) |
nit: The field name is serviceEndpoints
, right?
if _, err := url.Parse(serviceEndpoint.URL); err != nil { | ||
allErrs = append(allErrs, field.Invalid(fieldPath.Child("serviceEndpoint").Index(id), serviceEndpoint.URL, err.Error())) | ||
} else if _, err := http.Head(serviceEndpoint.URL); err != nil { | ||
allErrs = append(allErrs, field.Invalid(fieldPath.Child("serviceEndpoint").Index(id), serviceEndpoint.URL, err.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.
allErrs = append(allErrs, field.Invalid(fieldPath.Child("serviceEndpoint").Index(id), serviceEndpoint.URL, err.Error())) | |
allErrs = append(allErrs, field.Invalid(fieldPath.Child("serviceEndpoints").Index(id), serviceEndpoint.URL, err.Error())) |
nit: The field name is serviceEndpoints
?
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.
/approve
By and large this looks good, just a few minor changes.
// Ignore e2e.local for unit tests. | ||
if serviceEndpoint.URL == "e2e.local" { | ||
logrus.Warnf("Skipping service endpoint validation for %s", serviceEndpoint.Name) | ||
continue | ||
} |
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.
I won't block on this, particularly as it is the same approach used for aws, but as a matter of principal it's not a good idea to adjust code specifically for unit tests. Instead, what we should have done for aws is essentially inject a mock http client.
logrus.Warnf("Skipping service endpoint validation for %s", serviceEndpoint.Name) | ||
continue | ||
} | ||
if _, err := url.Parse(serviceEndpoint.URL); 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.
technically this should probably go in pkg/types as static validation, but I'm fine leaving it here.
if _, err := url.Parse(serviceEndpoint.URL); err != nil { | ||
allErrs = append(allErrs, field.Invalid(fieldPath.Child("serviceEndpoint").Index(id), serviceEndpoint.URL, err.Error())) | ||
} else if _, err := http.Head(serviceEndpoint.URL); err != nil { | ||
allErrs = append(allErrs, field.Invalid(fieldPath.Child("serviceEndpoint").Index(id), serviceEndpoint.URL, err.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.
I think we probably want to wrap this error message with something like "error when connecting to endpoint:"
allErrs = append(allErrs, field.Invalid(fieldPath.Child("serviceEndpoint").Index(id), serviceEndpoint.URL, err.Error())) | |
allErrs = append(allErrs, field.Invalid(fieldPath.Child("serviceEndpoint").Index(id), serviceEndpoint.URL, fmt.Errorf("error when connecting to endpoint: %w", err.Error()))) |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: patrickdillon 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 |
** check whether the user provided endpoints are reachable or not.