Docker-selenium: Selenium fails on OpenShift

Created on 12 Jul 2017  路  16Comments  路  Source: SeleniumHQ/docker-selenium

Meta -

Image(s):
selenium/hub:3.4.0

Expected Behavior -

Selenium Hub started.

Actual Behavior -

/opt/bin/entry_point.sh: line 6: /opt/selenium/config.json: Permission denied
starting selenium hub with configuration:
{
  "host": null,
  "port": 4444,
  "role": "hub",
  "maxSession": ,
  "newSessionWaitTimeout": ,
  "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
  "throwOnCapabilityNotPresent": ,
  "jettyMaxThreads": ,
  "cleanUpCycle": ,
  "browserTimeout": ,
  "timeout": ,
  "debug": 
}
Exception in thread "main" 
org.openqa.grid.common.exception.GridConfigurationException: Wrong format for 
the JSON input : com.google.gson.stream.MalformedJsonException: Unexpected value 
at line 1 column 65 path $.maxSession

Why do you run RUN sudo /opt/bin/generate_config > /opt/selenium/config.json in the Dockerfile?

Just a simple RUN /opt/bin/generate_config > /opt/selenium/config.json should be sufficient, or it can be left out altogether because of the same call in entry_point.sh.

The Docker Container is run as USER seluser, so of course the subsequent call in entry_point.sh /opt/bin/generate_config >$CONF will fail with Permission denied, causing the configuration being invalid. (because $CONF was created as root by the sudo call).

D-defect E-easy I-hub S-in-progress

Most helpful comment

I can fix that in a fork and offer a pull request. I need to deploy Selenium anyway.

All 16 comments

could this have already been fixed by https://github.com/SeleniumHQ/docker-selenium/commit/45304b7867098725c5e68b362ad126c21a89ef20 ? note this commit was not released yet.

I think he means this one (since he refers to the Hub) https://github.com/SeleniumHQ/docker-selenium/blob/master/Hub/Dockerfile.txt

ah yes. that shouldnt be there. @devent would you like to contribute and try your hand at a pr? if not, we'll take care of that sudo call

@ddavison
But now there is no possibility to use environment variables to change the configuration with https://github.com/SeleniumHQ/docker-selenium/commit/45304b7867098725c5e68b362ad126c21a89ef20 I have created an OpenShift template configuration where the user can set environment variables that are then used to create the configuration by the docker entry_point.sh.

are you perhaps using my ddavison/selenium-openshift-templates? if so, those should work just fine 馃

@ddavison
Yes, I was using them, but changed them to use a DeploymentConfig. With what version did you tested? Our cloud is restricted, it doesn't allow contains run as root. But since the container is run as user seluser it should be fine. But it fails with Permission Denied of course because the config file is created by root.
https://github.com/SeleniumHQ/docker-selenium/blob/master/Hub/Dockerfile#L39

those images are actually pretty old, and for OpenShift enterprise, however sans a couple new environment variables we're able to pass, they should still be fine to use.

yea several issues like this have been rectified, but i see more to come.

Did you want to try your hand at a Pull Request to fix this? or would you like us to take care of it @devent ?

I can fix that in a fork and offer a pull request. I need to deploy Selenium anyway.

The workaround for this is to create a serviceaccount named seluser .

And then oadm policy add-scc-to-user anyuid -z seluser while inside the namespace ..

Lastly, ensure that your selenium deployment configs has spec.template.spec.serviceAccount: seluser

Hi,
I don't know if this information is important, but :
Using OpenShift I had the same issue, with versions :
selenium/hub:3.4.0-dysprosium

/opt/bin/entry_point.sh: line 6: /opt/selenium/config.json: Permission denied
starting selenium hub with configuration:
{
  "host": null,
  "port": 4444,
  "role": "hub",
  "maxSession": ,
  "newSessionWaitTimeout": ,
  "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
  "throwOnCapabilityNotPresent": ,
  "jettyMaxThreads": ,
  "cleanUpCycle": ,
  "browserTimeout": ,
  "timeout": ,
  "debug":
}
Exception in thread "main" org.openqa.grid.common.exception.GridConfigurationException: Wrong format for the JSON input : com.google.gson.stream.MalformedJsonException: Unexpected value at line 1 column 65 path $.maxSession
[...]

selenium/hub:3.4.0-einsteinium

opt/bin/entry_point.sh: line 6: /opt/selenium/config.json: Permission denied
Exception in thread "main" org.openqa.grid.common.exception.GridConfigurationException: Wrong format for the JSON input : com.google.gson.stream.MalformedJsonException: Unexpected value at line 1 column 65 path $.maxSession
[...]

So I rolled back to selenium/hub:3.4.0-chromium, which works with my OpenShift instance (even though the permission denied error is still here)

@devent , i think a few people are waiting on this change. i offer you this warning, only for the sake of you being able to contribute to selenium. if you are going to fix this, please create a pull request by friday. if not, then i'll go ahead and put it in. i'm going to push a new release tomorrow, so if it's not in by then, i'll do it 馃槣

@ddavison You can go ahead and close it. I needed a lot of changes to the Image and I don't think it will be of benefit to you. Thank you for your support.

@ddavison .. I have tried with the latest images available on the Docker Hub and facing the same issue in OpenShift cloud. Could you please help?

@rakeshnambiar try with the most recent release of 3.5.3-boron

What is the supported version on openshift 3.6 3.5.3-boron is not working.

I'm using 3.4.0, and I also got this problem.
I didn't figure out how to fix this from the threads.

My template is as following:

apiVersion: v1
kind: Template
metadata:
  name: selenium-hub 
objects:
- apiVersion: v1
  kind: Route
  metadata:
    name: ${SELENIUM_HUB_NAME}-route
  spec:
    host: ${SELENIUM_HUB_NAME}.openshift.url.com
    to:
      kind: Service
      name: ${SELENIUM_HUB_NAME}-service
    port:
      targetPort: web
- apiVersion: v1
  kind: DeploymentConfig
  metadata: 
    name: ${SELENIUM_HUB_NAME}
  spec:
     replica: 1
     strategy:
       type: Recreate
     triggers:
       - type: ConfigChange
     template:
       metadata:
         name: ${SELENIUM_HUB_NAME} 
         labels:
           service: ${SELENIUM_HUB_NAME}
       spec:
         restartPolicy: Always
         containers:
         - image: selenium/hub:${SELENIUM_VERSION}
           name: ${SELENIUM_HUB_NAME}
           env:
           - name: JAVA_OPTS
             value: -Xmx512m
           - name: POOL_MAX
             value: "30000"
           - name: GRID_NEW_SESSION_WAIT_TIMEOUT
             value: "30"
           - name: GRID_JETTY_MAX_THREADS
             value: "100"
           - name: GRID_NODE_POLLING
             value: "150"
           - name: GRID_CLEAN_UP_CYCLE
             value: "300"
           - name: GRID_TIMEOUT
             value: "300"
           - name: GRID_BROWSER_TIMEOUT
             value: "60"
           - name: GRID_MAX_SESSION
             value: "4"
           - name: GRID_UNREGISTER_IF_STILL_DOWN_AFTER
             value: "500"
           ports:
           - containerPort: 4444
             protocol: TCP
           livenessProbe:
             failureThreshold: 3
             httpGet:
               path: /
               port: 4444
               scheme: HTTP
             periodSeconds: 10
             successThreshold: 1
             timeoutSeconds: 5
             initialDelaySeconds: 15
           readinessProbe:
             failureThreshold: 3
             httpGet:
               path: /
               port: 4444
               scheme: HTTP
             periodSeconds: 10
             successThreshold: 1
             timeoutSeconds: 5
             initialDelaySeconds: 15
- apiVersion: v1
  kind: Service
  metadata:
    labels:
      service: ${SELENIUM_HUB_NAME}
    name: ${SELENIUM_HUB_NAME}-service
  spec:
    selector:
      service: ${SELENIUM_HUB_NAME}
    type: ClusterIP
    ports:
    - name: web
      port: 4444
      targetPort: 4444
      protocol: TCP
    - name: node
      port: 5555
      targetPort: 5555
      protocol: TCP
parameters:
- description: Specific name of the Selenium hub application
  displayName: Selenium Hub Service Name
  name: SELENIUM_HUB_NAME
  value: selenium-hub-sandbox
  required: true
- description: Version of Selenium Hub
  displayName: Version of Selenium Hub
  name: SELENIUM_VERSION
  value: 3.4.0
  required: true

Was this page helpful?
0 / 5 - 0 ratings