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

bug 1960378: Relax the imageContentSource validation #5346

Merged
merged 1 commit into from Nov 17, 2021
Merged

bug 1960378: Relax the imageContentSource validation #5346

merged 1 commit into from Nov 17, 2021

Conversation

kirankt
Copy link
Contributor

@kirankt kirankt commented Nov 1, 2021

Relax the imageContentSource validation to allow for mirroring root registry.

This is a follow up to a previous attempt: #5297 which didn't quite fix the issue. The use of url.Parse does not work as expected. This PR utilized validate.Host function to check for a valid host name/IP when the canonical check fails.

@kirankt kirankt changed the title Relax the imageContentSource validation bug 1960378: Relax the imageContentSource validation Nov 1, 2021
@kirankt
Copy link
Contributor Author

kirankt commented Nov 1, 2021

/bugzilla refresh

@openshift-ci openshift-ci bot added the bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. label Nov 1, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 1, 2021

@kirankt: This pull request references Bugzilla bug 1960378, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

No GitHub users were found matching the public email listed for the QA contact in Bugzilla (gpei@redhat.com), skipping review request.

In response to this:

/bugzilla refresh

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.

@openshift-ci openshift-ci bot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Nov 1, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 1, 2021

@kirankt: An error was encountered querying GitHub for users with public email (gpei@redhat.com) for bug 1960378 on the Bugzilla server at https://bugzilla.redhat.com. No known errors were detected, please see the full error message for details.

Full error message. non-200 OK status code: 403 Forbidden body: "{\n \"documentation_url\": \"https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#secondary-rate-limits\",\n \"message\": \"You have exceeded a secondary rate limit. Please wait a few minutes before you try again.\"\n}\n"

Please contact an administrator to resolve this issue, then request a bug refresh with /bugzilla refresh.

In response to this:

bug 1960378: Relax the imageContentSource validation

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.

@kirankt
Copy link
Contributor Author

kirankt commented Nov 3, 2021

/retest

Copy link
Contributor

@patrickdillon patrickdillon left a comment

Choose a reason for hiding this comment

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

Can you provide some more context as how the QE test case was not covered by the previous solution? I think that might help determine the best solution.

pkg/types/validation/installconfig.go Outdated Show resolved Hide resolved
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 5, 2021

@kirankt: This pull request references Bugzilla bug 1960378, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

No GitHub users were found matching the public email listed for the QA contact in Bugzilla (gpei@redhat.com), skipping review request.

In response to this:

bug 1960378: Relax the imageContentSource validation

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.

@jhixson74
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 8, 2021
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 11, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 11, 2021

@kirankt: This pull request references Bugzilla bug 1960378, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

No GitHub users were found matching the public email listed for the QA contact in Bugzilla (gpei@redhat.com), skipping review request.

In response to this:

bug 1960378: Relax the imageContentSource validation

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.

if err != nil {
host = r
}
if err = validate.Host(host); err != nil {
return fmt.Errorf("the repository provided is invalid")
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's wrap around the error returned from validate.Host.

Suggested change
return fmt.Errorf("the repository provided is invalid")
return errors.Wrap(err, "the repository provided is invalid")

Copy link
Contributor Author

@kirankt kirankt Nov 11, 2021

Choose a reason for hiding this comment

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

Usually I like wrapping things but this one is unnecessarily verbose. This is what gets spit out:

Invalid value: "ocp/release-x.y": the repository provided is invalid: a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

So, I'm not sure about the wrapping. Let me know what you think.

Copy link
Contributor

Choose a reason for hiding this comment

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

I personally prefer the more verbose error rather than a statement that the repository is invalid without any details about how it is invalid.

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.
Just so that you know, I was cursing at you while escaping the regex in the validation. 😄

Copy link
Contributor

@staebler staebler Nov 17, 2021

Choose a reason for hiding this comment

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

Fair enough. For what it's worth, I would have happily accepted .* for the majority of the error message or omitting the end and the $.

pkg/types/validation/installconfig.go Show resolved Hide resolved
…eck fails

Return a more verbose invalid response for a bad host value
Copy link
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.

/lgtm

@@ -566,9 +566,14 @@ func validateNamedRepository(r string) error {
// in an error. Instead we will check whether the input is
// a valid hostname as a workaround.
if err == dockerref.ErrNameNotCanonical {
_, err := url.ParseRequestURI(r)
// If the hostname string contains a port, lets attempt
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
// If the hostname string contains a port, lets attempt
// If the hostname string contains a port, let's attempt

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 17, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 17, 2021

[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

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 Nov 17, 2021
@openshift-bot
Copy link
Contributor

/retest-required

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

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 17, 2021

@kirankt: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-crc 550364c link false /test e2e-crc
ci/prow/e2e-metal-single-node-live-iso 550364c link false /test e2e-metal-single-node-live-iso
ci/prow/okd-e2e-aws-upgrade 550364c link false /test okd-e2e-aws-upgrade
ci/prow/e2e-aws-single-node 550364c link false /test e2e-aws-single-node
ci/prow/e2e-aws-workers-rhel7 550364c link false /test e2e-aws-workers-rhel7

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.

@openshift-bot
Copy link
Contributor

/retest-required

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

1 similar comment
@openshift-bot
Copy link
Contributor

/retest-required

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

@openshift-merge-robot openshift-merge-robot merged commit 02c23e6 into openshift:master Nov 17, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 17, 2021

@kirankt: All pull requests linked via external trackers have merged:

Bugzilla bug 1960378 has been moved to the MODIFIED state.

In response to this:

bug 1960378: Relax the imageContentSource validation

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.

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. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants