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

fix: higher routing path match priority for longer pathnames #1709

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

dkwon17
Copy link
Contributor

@dkwon17 dkwon17 commented Jun 19, 2023

What does this PR do?

Updates priorities according to the PathPrefix length to the routing pathprefix rule for the traefik config.

If no priority is set, longer rule length results in a higher priority by default: https://doc.traefik.io/traefik/routing/routers/#priority, but since priority is set to 100 today (see here, here), rule length is not being considered. To mitigate this, this PR takes the rule length (in this case, PathPrefix length) into account for the priority.

Before & after example in the Che traefik config for the workspace:

      routers:
        workspace0d368dea85dc49aa:
          middlewares:
          - workspace0d368dea85dc49aa-strip-prefix
          - workspace0d368dea85dc49aa-header-rewrite
          - workspace0d368dea85dc49aa-auth
          - workspace0d368dea85dc49aa-headers
          - workspace0d368dea85dc49aa-errors
          - workspace0d368dea85dc49aa-retry
-         priority: 100
+         priority: 133
          rule: PathPrefix(`/cluster-admin/python-hello-world`)
          service: workspace0d368dea85dc49aa
        workspace0d368dea85dc49aa-3100-healthz:
          middlewares:
          - workspace0d368dea85dc49aa-strip-prefix
          - workspace0d368dea85dc49aa-header-rewrite
-         priority: 101
+         priority: 134
          rule: Path(`/cluster-admin/python-hello-world/3100/healthz`)
          service: workspace0d368dea85dc49aa

Image: quay.io/dkwon17/che-operator:routing-priority

Screenshot/screencast of this PR

What issues does this PR fix or reference?

Fixes eclipse-che/che#22288

How to test this PR?

To test on OpenShift,

  1. Install che next version chectl server:deploy -p openshift
  2. After installation start a Python sample workspace
  3. After the workspace starts, stop the workspace
  4. Create a new Python sample workspace
  5. When the dashboard displays the following message, press Create a new workspace
    image
  6. Repeat steps 3-5 until you can reproduce On dogfooding, sometimes cannot open workspace, redirected to dashboard instead che#22288
  7. Stop all workspaces
  8. Update che-operator image to quay.io/dkwon17/che-operator:routing-priority by editing the Che CSV
$ oc get csv

NAME                                   DISPLAY                 VERSION                 REPLACES   PHASE
devworkspace-operator.v0.22.0-dev.17   DevWorkspace Operator   0.22.0-dev.17+05519ae              Succeeded
eclipse-che.v7.68.0-798.next           Eclipse Che             7.68.0-798.next                    Succeeded

$ CSV=eclipse-che.v7.68.0-798.next 
$ oc patch ClusterServiceVersion $CSV -n openshift-operators --type='json' -p='[{"op": "replace", "path": "/metadata/annotations/containerImage", "value":"quay.io/dkwon17/che-operator:routing-priority"},{"op": "replace", "path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/image", "value":"quay.io/dkwon17/che-operator:routing-priority"}]'
  1. Wait a couple of minutes for the new che-operator pod to be created.

  2. Confirm that On dogfooding, sometimes cannot open workspace, redirected to dashboard instead che#22288 cannot be reproduced

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

@codecov
Copy link

codecov bot commented Jun 19, 2023

Codecov Report

Merging #1709 (56f9196) into main (94934bf) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1709      +/-   ##
==========================================
+ Coverage   60.22%   60.24%   +0.01%     
==========================================
  Files          71       71              
  Lines        8438     8441       +3     
==========================================
+ Hits         5082     5085       +3     
  Misses       3008     3008              
  Partials      348      348              
Impacted Files Coverage Δ
controllers/devworkspace/solver/che_routing.go 78.54% <100.00%> (+0.10%) ⬆️

@l0rd
Copy link
Contributor

l0rd commented Jun 20, 2023

@dkwon17 great catch! I have one question for my understanding: why can't we set priority= 0 (in the documentation that you shared it's mentioned that when it's set to zero then "the default rules length sorting is used")?

@dkwon17
Copy link
Contributor Author

dkwon17 commented Jun 20, 2023

@l0rd, thank you, I considered it, setting priority = 0 to use the default priority could still cause eclipse-che/che#22288 for existing workspaces when updating Che, since the traefik config for a workspace is updated when starting that workspace.

For example, in today's Che, if we have these workspaces

quarkus-api-example       (rule priority = 100)
quarkus-api-example-abc2  (rule priority = 100)

we may have trouble opening the quarkus-api-example-abc2 workspace due to the problem described in eclipse-che/che#22288 (comment)

If Che is updated to use default priorities for workspaces, and if we try to start quarkus-api-example-abc2 again, the priority for that workspace is updated:

quarkus-api-example       (rule priority = 100)
quarkus-api-example-abc2  (rule priority can be < 100)

and we can still have the problem since the rule for quarkus-api-example can still have a higher priority. The priority for quarkus-api-example is not updated yet since that workspace has not been started yet

@dkwon17
Copy link
Contributor Author

dkwon17 commented Jun 20, 2023

Oops, I had to make a few edits in the comment above

@ibuziuk ibuziuk requested a review from dmytro-ndp June 21, 2023 14:08
Copy link
Member

@ibuziuk ibuziuk left a comment

Choose a reason for hiding this comment

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

@dmytro-ndp @dkwon17 folks, once merged we need to backport for 3.7 since it is the last fix for the friendly routes blocker

@dmytro-ndp
Copy link
Contributor

dmytro-ndp commented Jun 22, 2023

@dkwon17 : how many times do you think it's needed to repeat steps 3-5 from PR description to make sure the issue is fixed in quay.io/dkwon17/che-operator:routing-priority ?

I had successfully started 6 Python workspaces in Eclipse Che Next with quay.io/dkwon17/che-operator:routing-priority aboard not facing eclipse-che/che#22288 issue.
Would it be enough to say the issue is fixed properly?

@dkwon17
Copy link
Contributor Author

dkwon17 commented Jun 22, 2023

Thank you @dmytro-ndp , I would say 6 workspaces are enough to verify this PR

@openshift-ci
Copy link

openshift-ci bot commented Jun 22, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dkwon17, dmytro-ndp, ibuziuk, tolusha

The full list of commands accepted by this bot can be found 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

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.8 :: get-sources-rhpkg-container-build_3.x/3529: FAILURE

devspaces-operator-bundle : 3.x :: Failed in 53504017 : BREW:BUILD/STATUS:UNKNOWN
FAILURE:; copied to quay

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.8 :: get-sources-rhpkg-container-build_3.x/3575: FAILURE

devspaces-operator-bundle : 3.x :: Failed in 53609179 : BREW:BUILD/STATUS:UNKNOWN
FAILURE:; copied to quay

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.8 :: copyIIBsToQuay/1501: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.8 :: sync-to-downstream_3.x/3731: SUCCESS

Build container: devspaces-operator-bundle synced; /DS_CI/get-sources-rhpkg-container-build_3.x/3576 triggered; /job/DS_CI/job/dsc_3.x triggered;

@devstudio-release
Copy link

Build 3.8 :: operator-bundle_3.x/1564: SUCCESS

Upstream sync done; /DS_CI/sync-to-downstream_3.x/3731 triggered

@devstudio-release
Copy link

Build 3.8 :: dsc_3.x/1036: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.8 :: dsc_3.x/1037: Console, Changes, Git Data

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.8 :: copyIIBsToQuay/1502: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.8 :: sync-to-downstream_3.x/3732: SUCCESS

Build container: devspaces-operator-bundle synced; /DS_CI/get-sources-rhpkg-container-build_3.x/3577 triggered; /job/DS_CI/job/dsc_3.x triggered;

@devstudio-release
Copy link

Build 3.8 :: operator-bundle_3.x/1565: SUCCESS

Upstream sync done; /DS_CI/sync-to-downstream_3.x/3732 triggered

@devstudio-release
Copy link

Build 3.8 :: dsc_3.x/1038: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.8 :: copyIIBsToQuay/1502: SUCCESS

3.8
arches = x86_64, s390x, ppc64le;
  * LATEST DS OPERATOR BUNDLE = <a href=https://quay.io/repository/devspaces/devspaces-operator-bundle?tab=tags>registry-proxy.engineering.redhat.com/rh-osbs/devspaces-operator-bundle:3.8-28
  * LATEST DWO OPERATOR BUNDLE = <a href=https://quay.io/repository/devworkspace/devworkspace-operator-bundle?tab=tags>registry-proxy.engineering.redhat.com/rh-osbs/devworkspace-operator-bundle:???
+ s390x-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.8-v4.14-526886-s390x
  + quay.io/devspaces/iib:3.8-v4.14-s390x
  + quay.io/devspaces/iib:next-v4.14-s390x
  + quay.io/devspaces/iib:3.8-v4.13-526881-s390x
  + quay.io/devspaces/iib:3.8-v4.13-s390x
  + quay.io/devspaces/iib:next-v4.13-s390x
  + quay.io/devspaces/iib:3.8-v4.12-526921-s390x
  + quay.io/devspaces/iib:3.8-v4.12-s390x
  + quay.io/devspaces/iib:next-v4.12-s390x
  + quay.io/devspaces/iib:3.8-v4.11-526916-s390x
  + quay.io/devspaces/iib:3.8-v4.11-s390x
  + quay.io/devspaces/iib:next-v4.11-s390x
  + quay.io/devspaces/iib:3.8-v4.10-526914-s390x
  + quay.io/devspaces/iib:3.8-v4.10-s390x
  + quay.io/devspaces/iib:next-v4.10-s390x
+ ppc64le-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.8-v4.14-526886-ppc64le
  + quay.io/devspaces/iib:3.8-v4.14-ppc64le
  + quay.io/devspaces/iib:next-v4.14-ppc64le
  + quay.io/devspaces/iib:3.8-v4.13-526881-ppc64le
  + quay.io/devspaces/iib:3.8-v4.13-ppc64le
  + quay.io/devspaces/iib:next-v4.13-ppc64le
  + quay.io/devspaces/iib:3.8-v4.12-526921-ppc64le
  + quay.io/devspaces/iib:3.8-v4.12-ppc64le
  + quay.io/devspaces/iib:next-v4.12-ppc64le
  + quay.io/devspaces/iib:3.8-v4.11-526916-ppc64le
  + quay.io/devspaces/iib:3.8-v4.11-ppc64le
  + quay.io/devspaces/iib:next-v4.11-ppc64le
  + quay.io/devspaces/iib:3.8-v4.10-526914-ppc64le
  + quay.io/devspaces/iib:3.8-v4.10-ppc64le
  + quay.io/devspaces/iib:next-v4.10-ppc64le
+ x86_64-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.8-v4.14-526886-x86_64
  + quay.io/devspaces/iib:3.8-v4.14-x86_64
  + quay.io/devspaces/iib:next-v4.14-x86_64
  + quay.io/devspaces/iib:3.8-v4.13-526924-x86_64
  + quay.io/devspaces/iib:3.8-v4.13-x86_64
  + quay.io/devspaces/iib:next-v4.13-x86_64
  + quay.io/devspaces/iib:3.8-v4.12-526921-x86_64
  + quay.io/devspaces/iib:3.8-v4.12-x86_64
  + quay.io/devspaces/iib:next-v4.12-x86_64
  + quay.io/devspaces/iib:3.8-v4.11-526916-x86_64
  + quay.io/devspaces/iib:3.8-v4.11-x86_64
  + quay.io/devspaces/iib:next-v4.11-x86_64
  + quay.io/devspaces/iib:3.8-v4.10-526914-x86_64
  + quay.io/devspaces/iib:3.8-v4.10-x86_64
  + quay.io/devspaces/iib:next-v4.10-x86_64

@devstudio-release
Copy link

Build 3.8 :: copyIIBsToQuay/1506: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.8 :: copyIIBsToQuay/1506: SUCCESS

3.8
arches = x86_64, s390x, ppc64le;
  * LATEST DS OPERATOR BUNDLE = <a href=https://quay.io/repository/devspaces/devspaces-operator-bundle?tab=tags>registry-proxy.engineering.redhat.com/rh-osbs/devspaces-operator-bundle:3.8-28
  * LATEST DWO OPERATOR BUNDLE = <a href=https://quay.io/repository/devworkspace/devworkspace-operator-bundle?tab=tags>registry-proxy.engineering.redhat.com/rh-osbs/devworkspace-operator-bundle:0.21-2
+ s390x-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.8-v4.14-526928-509979-s390x
  + quay.io/devspaces/iib:3.8-v4.14-s390x
  + quay.io/devspaces/iib:next-v4.14-s390x
  + quay.io/devspaces/iib:3.8-v4.13-526924-509973-s390x
  + quay.io/devspaces/iib:3.8-v4.13-s390x
  + quay.io/devspaces/iib:next-v4.13-s390x
  + quay.io/devspaces/iib:3.8-v4.12-526921-509970-s390x
  + quay.io/devspaces/iib:3.8-v4.12-s390x
  + quay.io/devspaces/iib:next-v4.12-s390x
  + quay.io/devspaces/iib:3.8-v4.11-526916-509961-s390x
  + quay.io/devspaces/iib:3.8-v4.11-s390x
  + quay.io/devspaces/iib:next-v4.11-s390x
  + quay.io/devspaces/iib:3.8-v4.10-526914-509957-s390x
  + quay.io/devspaces/iib:3.8-v4.10-s390x
  + quay.io/devspaces/iib:next-v4.10-s390x
+ ppc64le-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.8-v4.14-526928-509979-ppc64le
  + quay.io/devspaces/iib:3.8-v4.14-ppc64le
  + quay.io/devspaces/iib:next-v4.14-ppc64le
  + quay.io/devspaces/iib:3.8-v4.13-526924-509973-ppc64le
  + quay.io/devspaces/iib:3.8-v4.13-ppc64le
  + quay.io/devspaces/iib:next-v4.13-ppc64le
  + quay.io/devspaces/iib:3.8-v4.12-526921-509970-ppc64le
  + quay.io/devspaces/iib:3.8-v4.12-ppc64le
  + quay.io/devspaces/iib:next-v4.12-ppc64le
  + quay.io/devspaces/iib:3.8-v4.11-526916-509961-ppc64le
  + quay.io/devspaces/iib:3.8-v4.11-ppc64le
  + quay.io/devspaces/iib:next-v4.11-ppc64le
  + quay.io/devspaces/iib:3.8-v4.10-526914-509957-ppc64le
  + quay.io/devspaces/iib:3.8-v4.10-ppc64le
  + quay.io/devspaces/iib:next-v4.10-ppc64le
+ x86_64-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.8-v4.14-526928-509979-x86_64
  + quay.io/devspaces/iib:3.8-v4.14-x86_64
  + quay.io/devspaces/iib:next-v4.14-x86_64
  + quay.io/devspaces/iib:3.8-v4.13-526924-509973-x86_64
  + quay.io/devspaces/iib:3.8-v4.13-x86_64
  + quay.io/devspaces/iib:next-v4.13-x86_64
  + quay.io/devspaces/iib:3.8-v4.12-526921-509970-x86_64
  + quay.io/devspaces/iib:3.8-v4.12-x86_64
  + quay.io/devspaces/iib:next-v4.12-x86_64
  + quay.io/devspaces/iib:3.8-v4.11-526916-509961-x86_64
  + quay.io/devspaces/iib:3.8-v4.11-x86_64
  + quay.io/devspaces/iib:next-v4.11-x86_64
  + quay.io/devspaces/iib:3.8-v4.10-526914-509957-x86_64
  + quay.io/devspaces/iib:3.8-v4.10-x86_64
  + quay.io/devspaces/iib:next-v4.10-x86_64

@devstudio-release
Copy link

Build 3.8 :: operator_3.x/255: Console, Changes, Git Data

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.8 :: get-sources-rhpkg-container-build_3.x/3584: FAILURE

devspaces-operator : 3.x ::
; copied to quay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On dogfooding, sometimes cannot open workspace, redirected to dashboard instead
6 participants