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]: Video Live Streaming of Node Test Executions runs to a blank page on Kubernetes #1991

Closed
kherath17 opened this issue Nov 2, 2023 · 17 comments

Comments

@kherath17
Copy link

What happened?

I have setup Selenium Hub (selenium/hub:latest) and unable to view the live execution happening on the node , runs into a blank page

image

Command used to start Selenium Grid with Docker

Started through kubernetes , following is my deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: selenium-hub
  labels:
    app: selenium-hub
spec:
  replicas: 1
  selector:
    matchLabels:
      app: selenium-hub
  template:
    metadata:
      labels:
        app: selenium-hub
    spec:
      containers:
      - name: selenium-hub
        #image: selenium/hub:4.13.0-20231004 #4.1,4.13
        image: selenium/hub:latest
        ports:
          - containerPort: 4444
          - containerPort: 4443
          - containerPort: 4442
        resources:
          limits:
            memory: "4000Mi"
            cpu: "2"
          requests:
            memory: "4000Mi"
            cpu: "2"  
        livenessProbe:
          httpGet:
            path: /wd/hub/status
            port: 4444
          initialDelaySeconds: 30
          timeoutSeconds: 5
        readinessProbe:
          httpGet:
            path: /wd/hub/status
            port: 4444
          initialDelaySeconds: 30
          timeoutSeconds: 5

I have also setup the respective SVCs and Ingress Rules

Relevant log output

NA

Operating System

Windows 11

Docker Selenium version (tag)

4.14.1

Copy link

github-actions bot commented Nov 2, 2023

@kherath17, 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!

@VietND96
Copy link
Member

VietND96 commented Nov 2, 2023

Hi @kherath17, did you start the grid setup using helm chart selenium-grid? Or have you created your own K8s manifest files for deployment?

@kherath17
Copy link
Author

@VietND96 Its my own deployment files I have used

@VietND96
Copy link
Member

VietND96 commented Nov 2, 2023

Oh, so could you please also share the deployment file of the browser node for reference?

@kherath17
Copy link
Author

kherath17 commented Nov 2, 2023

@VietND96 FYI I have used a POD as below

apiVersion: v1
kind: Pod
metadata:
name: selenium-node-chrome
labels:
name: selenium-node-chrome
app: selenium-node-chrome
spec:
volumes:
- name: dshm
emptyDir:
medium: Memory
containers:
- name: selenium-node-chrome
image: selenium/node-chrome:4.13.0-20231004
ports:
- containerPort: 5555
#- containerPort: 7900
volumeMounts:
- mountPath: /dev/shm
name: dshm
env:
- name: SE_EVENT_BUS_HOST
value: "selenium-hub"
- name: SE_EVENT_BUS_SUBSCRIBE_PORT
value: "4443"
- name: SE_EVENT_BUS_PUBLISH_PORT
value: "4442"
- name: SE_NODE_MAX_SESSIONS
value: "2"
resources:
limits:
memory: "1000Mi"
cpu: ".5"

@VietND96
Copy link
Member

VietND96 commented Nov 2, 2023

reproduce.txt
Based on your input, I created a simple file with hub (deploy, svc) and node deploy. Then deployed it via kubectl apply, and started a test execution, I could see the video stream properly.
Can you try the next step checking pod logs of the browser node, is there any error logs related to "start-novnc"?
Moreover, I saw you mentioned above that "ingress rules" is configured. Can you check the ingress handles vnc request properly also?
image

@kherath17
Copy link
Author

@VietND96 appreciate your effort looking into this , since it works on your end I doubt if its the ingress , would you be able to share me the ingress file you have used

@VietND96
Copy link
Member

VietND96 commented Nov 2, 2023

Actually, I didn't apply ingress in above case, only 3 components as .txt that I shared. I access the grid view inside cluster via ClusterIP only. So if your end is using ingress and facing that issue, can you share your ingress, so I can take a look?

@kherath17
Copy link
Author

kherath17 commented Nov 2, 2023

@VietND96 here is my ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: qlabv2-ingress
namespace: qlabv2
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: nginx
rules:

  • http:
    paths:
    • backend:
      service:
      name: selenium-hub-service
      port:
      number: 80
      path: /qlabv2(/|$)(.*)
      pathType: ImplementationSpecific

@kherath17
Copy link
Author

HI @VietND96 do you see any misconfigurations in my ingress?

@VietND96
Copy link
Member

VietND96 commented Nov 3, 2023

Hi @kherath17 , it looks like ingress using path prefix and rewrite-target with regexp caused the issue. Some URL after redirected is incorrect. e.g
When goto http://hostname/qlabv2, it should redirect to http://hostname/qlabv2/ui, but actually it was http://hostname/ui
Similarly, when opening video stream page, vnc request should call ws://hostname/qlabv2/session/79c652bc117b51a5fefda5b4be0c4854/se/vnc but it was ws://hostname/session/79c652bc117b51a5fefda5b4be0c4854/se/vnc - 404 not found, and no video stream on page

Currently, I only can suggest you use path: / - it works on my end.
For the case path prefix with rewrite-target using regexp. I'll let you know if I am able to find a configuration-snippet can handle it.

@kherath17
Copy link
Author

Thank You @VietND96 for clarifying the root cause , but unfortunately I'm unable to use path: / since there's an already running ingress for that path , hence I will need to use some other path to route it

@diemol
Copy link
Member

diemol commented Nov 3, 2023

Thank you for troubleshooting, @VietND96! Are you in the Selenium Slack workspace?

@VietND96
Copy link
Member

VietND96 commented Nov 3, 2023

Hi @diemol , I was just aware and joined the Selenium Slack workspace.

@VietND96
Copy link
Member

VietND96 commented Nov 3, 2023

Hi @kherath17 , I suggest a workaround for prefix path config
Below sample with selenium grid runs on http://hostname/qlabv2
By using SE_SUB_PATH. In the hub deploy, add ENV for hub container

          env:
            - name: SE_SUB_PATH
              value: /qlabv2

Now, without ingress, grid view can be accessed via http://ClusterIP:4444/qlabv2/
The ingress configs would be

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: selenium-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/app-root: /qlabv2
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/use-regex: "true"
spec:
  rules:
    - http:
        paths:
          - path: /qlabv2(/|$)(.*)
            pathType: Prefix
            backend:
              service:
                name: selenium-hub
                port:
                  number: 4444
          - path: /(/?)(session/.*/se/vnc)
            pathType: Prefix
            backend:
              service:
                name: selenium-hub
                port:
                  number: 4444

With this config it will resolve redirect issue we mentioned above

  • http://hostname/qlabv2 -> http://hostname/qlabv2/ui - 200 OK
  • ws://hostname/session/79c652bc117b51a5fefda5b4be0c4854/se/vnc -> ws://hostname/qlabv2/session/79c652bc117b51a5fefda5b4be0c4854/se/vnc - 101 Switching Protocols

Deployment file for your reference - workaround.txt


Hi @diemol , I also have a doubt here, even we set SE_SUB_PATH but url of session vnc does not contain the sub path.
I also try to set in node this ENV

        - name: SE_NODE_GRID_URL
          value: "http://selenium-hub:4444/qlabv2"

but in node Capabilities, the URL still not have sub path

  "se:vnc": "ws://selenium-hub:4444/session/623cb93cd9438c195578b7edc5b0b534/se/vnc",
  "se:vncEnabled": true,

I saw the same issue discussed in SeleniumHQ/selenium#9980, and there was a commit fixed SeleniumHQ/selenium@ca9b451 by you. Do you know this? @diemol

@kherath17
Copy link
Author

Hi @VietND96 the workaround has successfully resolved my issue, thank you and appreciate your effort and time. :)

Copy link

github-actions bot commented Dec 9, 2023

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 github-actions bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants