Skip to content

standalone-chrome-debug hangs because DBUS_SESSION_BUS_ADDRESS is lost with sudo #358

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

Closed
Sovetnikov opened this issue Dec 27, 2016 · 15 comments

Comments

@Sovetnikov
Copy link

Sovetnikov commented Dec 27, 2016

When selenium is started via "sudo -E -i seluser" on -debug standalone, DBUS_SESSION_BUS_ADDRESS=/dev/null variable is lost and chrome hangs periodically on startup.

Just test it:
root:# docker run --rm selenium/standalone-chrome-debug env | grep DBUS
DBUS_SESSION_BUS_ADDRESS=/dev/null
root:# docker run --rm selenium/standalone-chrome-debug sudo -E -i -u seluser env | grep DBUS

Please fix this in entry_point.sh by adding "sudo -E -i seluser DBUS_SESSION_BUS_ADDRESS=/dev/null"
It's very annoying bug.

https://github.com/SeleniumHQ/docker-selenium/blob/aabd14c0b8bebdef1e492ffde927b7815ee2b19a/StandaloneDebug/entry_point.sh

@a-k-g
Copy link
Contributor

a-k-g commented Feb 6, 2017

+1 for this issue. I was hitting #87 repeatedly even after the fix seemed to have been merged. Thanks @Sovetnikov for finding the root cause. I've made an attempt to fix this issue in #381.

ddavison added a commit that referenced this issue Feb 20, 2017
Add DBUS_SESSION_BUS_ADDRESS to /etc/environment (Fixes #358)
camiller2 added a commit to camiller2/docker-selenium that referenced this issue Feb 23, 2017
…rsion args WIP on firefox-: 46: 46: Updated makefile, generate.sh scripts, and Dockerfile.txt so that maintianer is supplied in one place. Updated config to be 2x compatible. Updated Makefile with new name of fl-selenium Updated generate to take namespace as argument. Changed firefox version to 46.0.1 and selenium version to 2.53.1 3 hours ago Added selenium version args updated usage example 12 hours ago Some fixes...sort of working Finished build scripts (for now) Improved build.sh Added build script Added selenium version args yesterday Merge pull request SeleniumHQ#394 from wheleph/master 2 days ago edit dockerfiletxt for SeleniumHQ#386 Merge pull request SeleniumHQ#386 from a-k-g/add-dbus-to-etc-environment update to selenium v3.1.0 4 days ago Add comment about time units used in environment variables 6 days ago Set proper GRID TIMEOUT value Add DBUS_SESSION_BUS_ADDRESS to /etc/environment (Fixes SeleniumHQ#358) a week ago update chromedriver/geckodriver. closes SeleniumHQ#384 Updated ChromeDriver to latest (2017-02-06; v2.27) Merge pull request SeleniumHQ#377 from alexgibson/firefox-51 2 weeks ago Update NodeFirefox to use 51.0.1 Merge pull request SeleniumHQ#374 from ryneeverett/tighten-readme Fix heading hierarchy consistency. Delete unnecessary code blocks. Merge branch 'master' of github.com:seleniumhq/docker-selenium 3 weeks ago add TZ to Base image to propegate to all. default timezone to UTC rather than US/Pacific. closes SeleniumHQ#70; fermium release Merge pull request SeleniumHQ#366 from atlassian/geckodriver-v0.13.0 erbium release ignore iml files Upgrade to firefox 50.1.0, geckodriver v0.13.0 Updated makefile, generate.sh scripts, and Dockerfile.txt so that maintianer is supplied in one place.
camiller2 added a commit to camiller2/docker-selenium that referenced this issue Feb 23, 2017
…n args WIP on firefox-: 46: 46: Updated makefile, generate.sh scripts, and Dockerfile.txt so that maintianer is supplied in one place. Updated config to be 2x compatible. Updated Makefile with new name of fl-selenium Updated generate to take namespace as argument. Changed firefox version to 46.0.1 and selenium version to 2.53.1 3 hours ago Added selenium version args updated usage example 12 hours ago Some fixes...sort of working Finished build scripts (for now) Improved build.sh Added build script Added selenium version args yesterday Merge pull request SeleniumHQ#394 from wheleph/master 2 days ago edit dockerfiletxt for SeleniumHQ#386 Merge pull request SeleniumHQ#386 from a-k-g/add-dbus-to-etc-environment update to selenium v3.1.0 4 days ago Add comment about time units used in environment variables 6 days ago Set proper GRID TIMEOUT value Add DBUS_SESSION_BUS_ADDRESS to /etc/environment (Fixes SeleniumHQ#358) a week ago update chromedriver/geckodriver. closes SeleniumHQ#384 Updated ChromeDriver to latest (2017-02-06; v2.27) Merge pull request SeleniumHQ#377 from alexgibson/firefox-51 2 weeks ago Update NodeFirefox to use 51.0.1 Merge pull request SeleniumHQ#374 from ryneeverett/tighten-readme Fix heading hierarchy consistency. Delete unnecessary code blocks. Merge branch 'master' of github.com:seleniumhq/docker-selenium 3 weeks ago add TZ to Base image to propegate to all. default timezone to UTC rather than US/Pacific. closes SeleniumHQ#70; fermium release Merge pull request SeleniumHQ#366 from atlassian/geckodriver-v0.13.0 erbium release ignore iml files Upgrade to firefox 50.1.0, geckodriver v0.13.0 Updated makefile, generate.sh scripts, and Dockerfile.txt so that maintianer is supplied in one place.
@Sovetnikov Sovetnikov changed the title standalone-chrome-debug hangs becouse DBUS_SESSION_BUS_ADDRESS is lost with sudo standalone-chrome-debug hangs because DBUS_SESSION_BUS_ADDRESS is lost with sudo Jun 28, 2017
@Sovetnikov
Copy link
Author

6 months later this issue still exists

@diemol
Copy link
Member

diemol commented Jun 28, 2017

How can we reproduce it with the latest images @Sovetnikov?

Can you please provide a script that we can use?

@Sovetnikov
Copy link
Author

As in initial issue description:
docker run --rm selenium/standalone-chrome-debug sudo -E -i -u seluser env | grep DBUS
or
docker run --rm selenium/standalone-chrome:3.4.0-dysprosium sudo -E -i -u seluser env | grep DBUS

Two weeks ago i made update to 3.4.0-dysprosium image and again getting timeouts on new selenium sessions.

@Sovetnikov
Copy link
Author

3.1.0-astatine works fine:
docker run --rm selenium/standalone-chrome:3.1.0-astatine sudo -E -i -u seluser env | grep DBUS
seems DBUS fix is lost somewhere between 3.1 and 3.4

@Sovetnikov
Copy link
Author

Two lines in custom Dockerfile fixed it for my:
RUN echo 'Defaults env_keep += "DBUS_SESSION_BUS_ADDRESS"' >> /etc/sudoers
RUN echo "DBUS_SESSION_BUS_ADDRESS=/dev/null" >> /etc/environment

@diemol
Copy link
Member

diemol commented Jun 28, 2017

If I do this: docker run --rm selenium/standalone-chrome:3.4.0-dysprosium sudo -E -i -u seluser env, I get this:

HOSTNAME=a301e6f6de32
TERM=unknown
SHELL=/bin/bash
USER=seluser
SUDO_USER=seluser
SUDO_UID=1000
USERNAME=seluser
MAIL=/var/mail/seluser
PATH=/home/seluser/bin:/home/seluser/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
PWD=/home/seluser
TZ=UTC
SHLVL=1
SUDO_COMMAND=/bin/bash -c env
HOME=/home/seluser
LOGNAME=seluser
SUDO_GID=1000
DISPLAY=:99.0
_=/usr/bin/env

But if I do this: docker run --rm selenium/standalone-chrome:3.4.0-dysprosium env (without the sudo and so on...), I get this:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=aec3922e49f2
DEBIAN_FRONTEND=noninteractive
DEBCONF_NONINTERACTIVE_SEEN=true
TZ=UTC
SCREEN_WIDTH=1360
SCREEN_HEIGHT=1020
SCREEN_DEPTH=24
DISPLAY=:99.0
NODE_MAX_INSTANCES=1
NODE_MAX_SESSION=1
NODE_PORT=5555
NODE_REGISTER_CYCLE=5000
NODE_POLLING=5000
NODE_UNREGISTER_IF_STILL_DOWN_AFTER=60000
NODE_DOWN_POLLING_LIMIT=2
NODE_APPLICATION_NAME=
DBUS_SESSION_BUS_ADDRESS=/dev/null
HOME=/home/seluser

The processes in the container are not running as root anymore, everything is running with seluser, maybe that's why you don't see the value with your command?

@Sovetnikov
Copy link
Author

Can you see DBUS_SESSION_BUS_ADDRESS in your output? I'm not ... this is a problem
This command shows that DBUS_SESSION_BUS_ADDRESS is in env: docker run --rm selenium/standalone-chrome:3.1.0-astatine sudo -E -i -u seluser env | grep DBUS

But this command shows that DBUS_SESSION_BUS_ADDRESS is NOT in env anymore with latest docker image: docker run --rm selenium/standalone-chrome sudo -E -i -u seluser env | grep DBUS

About root... you can see that i'm aware of seluser and running test with sudo -u seluser

@diemol
Copy link
Member

diemol commented Jun 28, 2017

The DBUS_SESSION_BUS_ADDRESS is set in the base node image under the seluser user. That is why I can just do env in the container and then see it.

When I do sudo -E -i -u seluser env, I don't see it. My question is, why do you need to use that command to check the env vars? I was checking and we are not running any of the commands in the container with sudo.

What I see for all containers is that the DBUS_SESSION_BUS_ADDRESS is set and present in the seluser. A few people also tested it and we didn't hit the issue again.

That is why I was asking for a script (Selenium code running a test), that I could execute and reproduce the issue of getting timeouts when asking for a new session. Perhaps we need to improve something else.

@Sovetnikov
Copy link
Author

This issue about debug image that runs selenium with sudo:
docker run --rm selenium/standalone-chrome-debug cat /opt/bin/entry_point.sh | grep sudo

Seems that initial issue was fixed in selenium/standalone-chrome image and it passed to debug image.
At now selenium/standalone-chrome has lost that fix and debug image as well.

@diemol
Copy link
Member

diemol commented Jun 28, 2017

I think I found the problem, but please help me check...

Try the same command you tried in the previous command, but using the tag 3.4.0-dysprosium.

I think we made a mistake when we put the tag to the most recent images. That is why you might see something different, I created #508

@Sovetnikov
Copy link
Author

this command returns empty result on clean server without pulled earlier selenium images: docker run --rm selenium/standalone-chrome:3.4.0-dysprosium sudo -E -i -u seluser env | grep DBUS

@diemol
Copy link
Member

diemol commented Jun 28, 2017

@Sovetnikov, for that, I wrote this comment.

So, maybe you can help us to reproduce the issue as I mentioned in the last part of the comment?

That is why I was asking for a script (Selenium code running a test), that I could execute and reproduce the issue of getting timeouts when asking for a new session. Perhaps we need to improve something else.

@Sovetnikov
Copy link
Author

Just read my first message about this issue, all as described there.
This bug was fixed, but fix is lost now.
This issue about selenium/standalone-chrome-debug image that runs selenium by sudo and then DBUS_SESSION_BUS_ADDRESS variable is lost.

Just add:
RUN echo 'Defaults env_keep += "DBUS_SESSION_BUS_ADDRESS"' >> /etc/sudoers
RUN echo "DBUS_SESSION_BUS_ADDRESS=/dev/null" >> /etc/environment
to Dockerfile of selenium/standalone-chrome-debug

@ddavison
Copy link
Member

@Sovetnikov if you want, try your hand at a pull request and we'll review!

@lock lock bot locked and limited conversation to collaborators Aug 14, 2019
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

4 participants