selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🚀 Feature]: Subpath parameter for subpath ingress configurations

Open med502 opened this issue 3 years ago • 13 comments

Feature and motivation

Adding parameter for subpath configuration so inside container application can work on different path than root.

I've tested rewrite rules on ingress and they do not work correctly.

Usage example

Currently application works on http://localhost:4444 inside of the container, unfortunately in ingress implementation with reverse-proxy application will not respond correctly to ingress configuration where path is configured different than "/" New parameter would allow to change base URL of the application to work on http://localhost/selenium:4444 which will allow correct communication with ingress.

med502 avatar Jul 04 '22 14:07 med502

@med502, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] avatar Jul 04 '22 14:07 github-actions[bot]

Which app do you mean? The Grid UI?

diemol avatar Jul 04 '22 21:07 diemol

Which app do you mean? The Grid UI?

This is regarding hub component. I am implementing cluster of hub with few worker nodes for our tester chapter.

med502 avatar Jul 05 '22 05:07 med502

Still a bit lost. Can you describe where you use the URL for the app you mentioned?

diemol avatar Jul 05 '22 06:07 diemol

image

Using diagram above HUB component is accessible over kubernetes ingress wtih nginx class. Whenever I use subpath in ingress configuration so application will be on mydomain.com/selenium application is not accessible I can only use root path so I can set selenium to work only on mydomain.com

In that case various application require additional parameter to work on subpath which is different than root path of the URL example for grafana https://grafana.com/tutorials/run-grafana-behind-a-proxy/

med502 avatar Jul 05 '22 09:07 med502

I am still not understanding. Do you mean the user interface of the Grid, where you can see the running sessions and node stereotypes? Or do you mean the URL endpoint where you start sessions? Both live inside the Hub.

diemol avatar Jul 05 '22 09:07 diemol

Both interface and checking status with command below

curl -X GET https://mydomain.com/selenium/status

med502 avatar Jul 05 '22 09:07 med502

I see. It should actually work. Can you share the work you have done so we can try it as well? Maybe in a GitHub repository with instructions.

diemol avatar Jul 05 '22 10:07 diemol

I've deployed selenium from helm chart from this link https://github.com/pedrodotmc/docker-selenium/tree/selenium-grid-helm-chart/chart/selenium-grid and then I've updated ingress to look like this

apiVersion: v1
items:
- apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    annotations:
      kubernetes.io/publicEndpoints: ;[{"address":[""]."port":443,"protocol":"HTTPS","serviceName":"selenium:selenium-hub","ingressName":"selenium:selenium-ingress","hostname":"mydomain.com"."path":"/selenium","allNodes":false}]'
      kubernetes.io/ingress.classs: nginx
      nginx.ingress.kubernetes.io/add-base-url: "true"
      meta.helm.sh/release-name: selenium-grid
      meta.helm.sh/release-namespace: selenium
    name: slenium-ingress
    namespace: selenium  
  spec:
    rules:
    -   host: mydomain.com
        http:
          paths:
          - backend:
              serviceName: selenium-hub
              servicePort: 4444
            path: /selenium
            pathType: Prefix
    tls:
    - host:
      - mydomain.com
      secretName: mydomain-secret     

Problem occurs as our nginx ingress is behind AWS load balancer and reverse proxy. I've tried to add rewrite /$2 annotation but that deos not work as well

med502 avatar Jul 05 '22 10:07 med502

As discussed on slack, Even for me it's the case..

yashcho avatar Aug 10 '22 15:08 yashcho

Any update on this?

yashcho avatar Sep 01 '22 19:09 yashcho

If there were updates, they would have been posted here.

diemol avatar Sep 04 '22 00:09 diemol

Sorry to say but it seems the update is left from your end, @med502 have posted reproducing steps and plus this is case for docker based hub too, is there any flag which can run hub to subpath/context-path instead of root context?

yashcho avatar Sep 05 '22 12:09 yashcho

@diemol can you help me with what setting it will work as below URL : curl -X GET https://mydomain.com/selenium/ui/

yashcho avatar Oct 21 '22 17:10 yashcho

If someone wants to work on this, there are at least three places where changes need to be done:

There are some lines where a prefix/subpath is added, ideally one should be able to configure this subpath in the router configuration.

Probably the UI needs to be tested properly to double check it is still working. In addition, double check that requests reach the Node and other components, running a few tests should show if this works well.

diemol avatar Nov 15 '22 12:11 diemol

@diemol but for /ui it needs to be done at this point https://github.com/SeleniumHQ/selenium/blob/01bf373e006564840ef82747ef0d437b8f3b9665/java/src/org/openqa/selenium/grid/web/GridUiRoute.java#L51?

yashcho avatar Nov 15 '22 14:11 yashcho

@yashcho - Yes. Thats because the routing for the UI part is internally handled by GridUiRoute

krmahadevan avatar Nov 15 '22 14:11 krmahadevan

It could be done there or at the server startup, however the configuration of the UI needs to be tweaked to work under subpaths. Not sure how that can be done, would need to research that.

diemol avatar Nov 15 '22 15:11 diemol

What do you mean by server startup?

yashcho avatar Nov 15 '22 16:11 yashcho

What do you mean by server startup?

The three links I shared above.

diemol avatar Nov 15 '22 16:11 diemol

@diemol I got some basic hard coding to work for the UI endpoints... but am wondering as to what should be the expected behaviour for the new session endpoint as well as the endpoint that deals with existing session ?

For e.g., a test case would basically be doing a POST against http://ip:port/session which would reach a reverse proxy such as nginx. Now lets say nginx has been configured to route all traffic on 4444 port to /selenium sub-path which is where the Hub|Router is listening to. So this would mean that the URI that reaches the hub's handlers would now contain /selenium/session. I guess this means that we would need to ensure that all the /session && /session/{sessionId} endpoints also need to support the notion of sub-path no ?

krmahadevan avatar Nov 15 '22 16:11 krmahadevan

@krmahadevan not really, /wd/hub is a prefix that already works. So no need to ensure all that apart of running some tests.

diemol avatar Nov 15 '22 17:11 diemol

What is the method to test the changes, I mean how to verify if the changes are working?

For your information I am using GitPod to work on the changes.

yashcho avatar Nov 15 '22 18:11 yashcho

https://github.com/SeleniumHQ/selenium#common-build-targets is a good start for it.

diemol avatar Nov 15 '22 18:11 diemol

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Jan 15 '23 00:01 github-actions[bot]