openshift / router

Ingress controller for OpenShift
Apache License 2.0
68 stars 114 forks source link

[release-4.14] OCPBUGS-32634: Properly handle rewrite-target annotation #583

Closed gcs278 closed 3 months ago

gcs278 commented 4 months ago

This is an manual cherry-pick of https://github.com/openshift/router/pull/534

Process the haproxy.router.openshift.io/rewrite-target annotation value to prevent HaProxy configuration issues while maintaining API compatibility. Properly handle values with spaces, backslashes, and other special characters.

Add a new package, rewritetarget, to organize the functions that process the rewrite target annotation. Add a separate unit test package, rewritetarget_test, to enforce black-box testing principles.

openshift-ci-robot commented 4 months ago

@gcs278: This pull request references Jira Issue OCPBUGS-22739, which is invalid:

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to [this](https://github.com/openshift/router/pull/583): >This is an manual cherry-pick of https://github.com/openshift/router/pull/534 > >Process the `haproxy.router.openshift.io/rewrite-target` annotation value to prevent HaProxy configuration issues while maintaining API compatibility. Properly handle values with spaces, backslashes, and other special characters. > >Add a new package, rewritetarget, to organize the functions that process the rewrite target annotation. Add a separate unit test package, rewritetarget_test, to enforce black-box testing principles. Instructions for interacting with me using PR comments are available [here](https://prow.ci.openshift.org/command-help?repo=openshift%2Frouter). If you have questions or suggestions related to my behavior, please file an issue against the [openshift-eng/jira-lifecycle-plugin](https://github.com/openshift-eng/jira-lifecycle-plugin/issues/new) repository.
openshift-ci-robot commented 4 months ago

@gcs278: This pull request references Jira Issue OCPBUGS-32634, which is invalid:

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to [this](https://github.com/openshift/router/pull/583): >This is an manual cherry-pick of https://github.com/openshift/router/pull/534 > >Process the `haproxy.router.openshift.io/rewrite-target` annotation value to prevent HaProxy configuration issues while maintaining API compatibility. Properly handle values with spaces, backslashes, and other special characters. > >Add a new package, rewritetarget, to organize the functions that process the rewrite target annotation. Add a separate unit test package, rewritetarget_test, to enforce black-box testing principles. Instructions for interacting with me using PR comments are available [here](https://prow.ci.openshift.org/command-help?repo=openshift%2Frouter). If you have questions or suggestions related to my behavior, please file an issue against the [openshift-eng/jira-lifecycle-plugin](https://github.com/openshift-eng/jira-lifecycle-plugin/issues/new) repository.
gcs278 commented 4 months ago

/jira refresh

openshift-ci-robot commented 4 months ago

@gcs278: This pull request references Jira Issue OCPBUGS-32634, which is invalid:

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to [this](https://github.com/openshift/router/pull/583#issuecomment-2070162585): >/jira refresh Instructions for interacting with me using PR comments are available [here](https://prow.ci.openshift.org/command-help?repo=openshift%2Frouter). If you have questions or suggestions related to my behavior, please file an issue against the [openshift-eng/jira-lifecycle-plugin](https://github.com/openshift-eng/jira-lifecycle-plugin/issues/new) repository.
gcs278 commented 4 months ago

/jira refresh

openshift-ci-robot commented 4 months ago

@gcs278: This pull request references Jira Issue OCPBUGS-32634, which is valid. The bug has been moved to the POST state.

7 validation(s) were run on this bug * bug is open, matching expected state (open) * bug target version (4.14.z) matches configured target version for branch (4.14.z) * bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST) * release note text is set and does not match the template * dependent bug [Jira Issue OCPBUGS-31544](https://issues.redhat.com//browse/OCPBUGS-31544) is in the state Verified, which is one of the valid states (VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA)) * dependent [Jira Issue OCPBUGS-31544](https://issues.redhat.com//browse/OCPBUGS-31544) targets the "4.15.z" version, which is one of the valid target versions: 4.15.0, 4.15.z * bug has dependents

Requesting review from QA contact: /cc @ShudiLi

In response to [this](https://github.com/openshift/router/pull/583#issuecomment-2071372109): >/jira refresh Instructions for interacting with me using PR comments are available [here](https://prow.ci.openshift.org/command-help?repo=openshift%2Frouter). If you have questions or suggestions related to my behavior, please file an issue against the [openshift-eng/jira-lifecycle-plugin](https://github.com/openshift-eng/jira-lifecycle-plugin/issues/new) repository.
alebedev87 commented 4 months ago

/lgtm /approve

openshift-ci[bot] commented 4 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alebedev87

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: - ~~[OWNERS](https://github.com/openshift/router/blob/release-4.14/OWNERS)~~ [alebedev87] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
ShudiLi commented 4 months ago

/label qe-approved thanks

openshift-ci-robot commented 4 months ago

@gcs278: This pull request references Jira Issue OCPBUGS-32634, which is valid.

7 validation(s) were run on this bug * bug is open, matching expected state (open) * bug target version (4.14.z) matches configured target version for branch (4.14.z) * bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST) * release note text is set and does not match the template * dependent bug [Jira Issue OCPBUGS-31544](https://issues.redhat.com//browse/OCPBUGS-31544) is in the state Verified, which is one of the valid states (VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA)) * dependent [Jira Issue OCPBUGS-31544](https://issues.redhat.com//browse/OCPBUGS-31544) targets the "4.15.z" version, which is one of the valid target versions: 4.15.0, 4.15.z * bug has dependents

Requesting review from QA contact: /cc @ShudiLi

In response to [this](https://github.com/openshift/router/pull/583): >This is an manual cherry-pick of https://github.com/openshift/router/pull/534 > >Process the `haproxy.router.openshift.io/rewrite-target` annotation value to prevent HaProxy configuration issues while maintaining API compatibility. Properly handle values with spaces, backslashes, and other special characters. > >Add a new package, rewritetarget, to organize the functions that process the rewrite target annotation. Add a separate unit test package, rewritetarget_test, to enforce black-box testing principles. Instructions for interacting with me using PR comments are available [here](https://prow.ci.openshift.org/command-help?repo=openshift%2Frouter). If you have questions or suggestions related to my behavior, please file an issue against the [openshift-eng/jira-lifecycle-plugin](https://github.com/openshift-eng/jira-lifecycle-plugin/issues/new) repository.
candita commented 4 months ago

The backport introduces a change that prevents the router from crashing due to invalid rewrite-target annotations, so any risk is weighed against this benefit. Any remaining risk is eliminated because there is no change to valid rewrite-target annotations, only invalid rewrite-target annotations.

/label backport-risk-assessed

alebedev87 commented 4 months ago

/lgtm

ShudiLi commented 4 months ago

tested it with 4.14.0-0.ci.test-2024-05-17-033138-ci-ln-m43pm4t-latest

1.
% oc get clusterversion
NAME      VERSION                                                   AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.14.0-0.ci.test-2024-05-17-033138-ci-ln-m43pm4t-latest   True        False         24m     Cluster version is 4.14.0-0.ci.test-2024-05-17-033138-ci-ln-m43pm4t-latest

2.
% oc -n openshift-ingress rsh router-default-58d8855dfc-bj8nx
sh-4.4$ grep "http-request replace-path" haproxy-config.template
  http-request replace-path ^{{ $cfg.Path }}/?(.*)$ '{{ processRewriteTarget $pathRewriteTarget }}'
  http-request replace-path ^{{ $cfg.Path }}(.*)$ '{{ processRewriteTarget $pathRewriteTarget }}'
sh-4.4$ 

3.
%  oc annotate route/unsec-server3  haproxy.router.openshift.io/rewrite-target="/t t$%&*(){}[].,z#:\`_-|" --overwrite
route.route.openshift.io/unsec-server3 annotate

4.
% oc get route unsec-server3 -o=jsonpath="{.metadata.annotations.haproxy\.router\.openshift\.io/rewrite-target}"
/t t$%&*(){}[].,z#:`_-|%         
gcs278 commented 4 months ago

seems unrelated: /test e2e-upgrade

gcs278 commented 3 months ago

/retest-required

gcs278 commented 3 months ago

@ShudiLi Just checking on cherry-pick-approved label since it's been a couple weeks.

melvinjoseph86 commented 3 months ago

/label cherry-pick-approved

openshift-ci[bot] commented 3 months ago

@gcs278: The following test 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-metal-ipi-ovn-ipv6 a71e1a3a5f790be5f67d236478ac30508f416a25 link false /test e2e-metal-ipi-ovn-ipv6

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
gcs278 commented 3 months ago

Not related { OVNKubernetesResourceRetryFailure was at or above info for at least 56m48s on platformidentification.JobType{Release:"4.14", FromRelease:"", Platform:"aws", Architecture:"amd64", Network:"ovn", Topology:"ha"} (maxAllowed=0s): pending for 0s, firing for 56m48s: /test e2e-aws-serial

openshift-ci-robot commented 3 months ago

@gcs278: Jira Issue OCPBUGS-32634: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-32634 has been moved to the MODIFIED state.

In response to [this](https://github.com/openshift/router/pull/583): >This is an manual cherry-pick of https://github.com/openshift/router/pull/534 > >Process the `haproxy.router.openshift.io/rewrite-target` annotation value to prevent HaProxy configuration issues while maintaining API compatibility. Properly handle values with spaces, backslashes, and other special characters. > >Add a new package, rewritetarget, to organize the functions that process the rewrite target annotation. Add a separate unit test package, rewritetarget_test, to enforce black-box testing principles. Instructions for interacting with me using PR comments are available [here](https://prow.ci.openshift.org/command-help?repo=openshift%2Frouter). If you have questions or suggestions related to my behavior, please file an issue against the [openshift-eng/jira-lifecycle-plugin](https://github.com/openshift-eng/jira-lifecycle-plugin/issues/new) repository.
openshift-bot commented 3 months ago

[ART PR BUILD NOTIFIER]

This PR has been included in build ose-haproxy-router-base-container-v4.14.0-202405282308.p0.gc3a2430.assembly.stream.el8 for distgit ose-haproxy-router-base. All builds following this will include this PR.

openshift-merge-robot commented 3 months ago

Fix included in accepted release 4.14.0-0.nightly-2024-05-29-034539

gcs278 commented 3 months ago

/cherry-pick release-4.13

openshift-cherrypick-robot commented 3 months ago

@gcs278: new pull request created: #608

In response to [this](https://github.com/openshift/router/pull/583#issuecomment-2139684518): >/cherry-pick release-4.13 Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.