aerokube / ggr

A lightweight load balancer used to create big Selenium clusters
https://aerokube.com/ggr/latest/
Apache License 2.0
314 stars 74 forks source link

401 authorized error when connect ggr to run in distributed systems #176

Closed liulirun closed 6 years ago

liulirun commented 6 years ago

When I run selenium tests against ggr. I got

An error occurred while loading ./spec/store/regression/purchase_path/instant_preview_purchase/C1145928_spec.rb.
Failure/Error: Capybara.current_session.driver.browser.manage.window.resize_to(1440, 1000)

Selenium::WebDriver::Error::WebDriverError:
  unexpected response, code=401, content-type="text/plain"
  401 Unauthorized
# /var/lib/gems/2.3.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/http/common.rb:88:in `create_response'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/http/default.rb:104:in `request'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/bridge.rb:164:in `execute'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/bridge.rb:97:in `create_session'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/bridge.rb:53:in `handshake'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/driver.rb:37:in `initialize'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/common/driver.rb:56:in `new'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/common/driver.rb:56:in `for'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver.rb:84:in `for'
# /var/lib/gems/2.3.0/gems/capybara-2.17.0/lib/capybara/selenium/driver.rb:23:in `browser'
# ./spec/helpers/store_spec_helper.rb:66:in `<top (required)>'
(required)>'
No examples found.

To compare, if I run the case against selenoid server( .232, .235 box) itself, success. So I am pretty convinced the problem goes with the configuration of ggr box in my box.

=========================================== some conf: IP: 172.24.23.231, ggr server. ggr is latest version. Ubuntu 16.3 LTS . This is also act like a Jenkins slave node. But I do not think that would be the matter.

user: griduser in /etc/grid-router/, I have users.htpasswd , it looks like below, have griduser configed griduser:$apr1$9qdedDks$I1ADq.aQ.f3a7sEMlfiZn2

in /etc/grid-router/quota, I have griduser.xml,

<qa:browsers xmlns:qa="urn:config.gridrouter.qatools.ru">
<browser name="chrome" defaultVersion="64.0">
    <version number="64.0">
        <region name="1">
            <host name="172.24.23.232" port="4444" count="8" username="griduser" password="blah"/>
            <host name="172.24.23.235" port="4444" count="6"/>
        </region>
    </version>
</browser>
</qa:browsers>

hitting http://172.24.23.231:4444/quota returns

[{"Name":"chrome","DefaultVersion":"64.0","Versions":[{"Number":"64.0","Regions":[{"Name":"1","Hosts":[{"Name":"172.24.23.232","Port":4444,"Count":8,"Username":"griduser","Password":"blah","VNC":"","Scheme":""},{"Name":"172.24.23.235","Port":4444,"Count":6,"Username":"","Password":"","VNC":"","Scheme":""}]}]}]}]

I have a another Linux ( 16.3 LTS ) as selenoid docker server IP: 172.24.23.232, selenoid container server. latest version. Ubuntu 16.3 LTS. user: griduser

the browsers.conf looks like:

{
    "chrome": {
        "default": "64.0",
        "versions": {
            "64.0": {
                "image": "selenoid/vnc:chrome_64.0",
                "port": "4444",
                "path": "/",
                "tmpfs": {"/tmp": "size=512m"},
                "env" : ["SCREEN_RESOLUTION=1920x1680x24"]
            }
        }
    }
}

and it is started, so hitting http://172.24.23.232:4444/status returns {"total":10,"used":0,"queued":0,"pending":0,"browsers":{"chrome":{"64.0":{}}}}

though hitting http://172.24.23.232:4444 or http://172.24.23.232:4444/wd/hub always get 404 page not found.-- which should be fine

======================

another Linux ( 16.3 LTS ) as selenoid docker server IP: 172.24.23.235 settings are more or less the same

======================

Sadly I did not find any similiar error in the old bug, also I am pretty sure must be somewhere in my configuration cause the problem, but need some directions how to dive deeper. Thank you!

vania-pooh commented 6 years ago

@liulirun could you show me an example Selenium URL when going through Ggr? Should be something like:

http://griduser:<password>@your-ggr-host.example.com:4444/wd/hub
liulirun commented 6 years ago

Thank you so much for your reply. http://griduser:@your-ggr-host.example.com:4444/wd/hub looks like ( I have replaced the password with correct one )

image

liulirun commented 6 years ago

http://griduser:@your-ggr-host.example.com:4444 also looks like image

liulirun commented 6 years ago

ggr docker logs looks like:

2018/03/01 17:03:01 [17] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 17:03:01 [18] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 17:03:01 [19] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 17:03:01 [20] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 17:03:01 [21] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 17:03:01 [22] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 17:03:02 [23] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 17:03:02 [24] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 17:03:02 [25] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 17:03:02 [26] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 17:03:02 [27] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 17:03:03 [28] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 19:19:55 [29] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-] 2018/03/01 23:36:47 [30] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-]

liulirun commented 6 years ago

I am using cmd to start docker run -d --name ggr -v /etc/grid-router/:/etc/grid-router:ro --net host aerokube/ggr:latest-release

docker ps shows:

CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS               NAMES
7cd6139ab9f5        aerokube/ggr:latest-release   "/usr/bin/ggr -liste…"   7 hours ago         Up 7 hours                              ggr
vania-pooh commented 6 years ago

@liulirun I see that according to your logs authentication is working correctly when you do requests to /quota API.

2018/03/01 23:36:47 [30] [-] [QUOTA_INFO_REQUESTED] [griduser] [172.22.9.113] [-] [-] [-] [-] [-]

However there are no requests for new sessions. Please check that your password for /quota API is the same that in tests.

liulirun commented 6 years ago

I think I know where the problem is :

  1. the screenshot I took is from other computers, with browser. So http://griduser:password@your-ggr-host.example.com:4444/quota looks good -- that's not count.

  2. If I tried from ggr server itself, I can not vnc to it, thought it is ubuntu 16.3 LTS. So I could not open browser on ggr server itself.

if I run curl http://172.24.23.231:4444/quota, I will get 401 Unauthorized as a result.

My real password contains some special character like , ! etc, say password is "blah!" when I run curl http://griduser:blah*!@172.24.23.231:4444/quota , I will get -bash: !@172.24.23.231: event not found as a result.

If I try: curl http://griduser:<blah*!>@172.24.23.231:4444/quota I will get -bash: !@172.24.23.231: event not found as a result.

I think somehow this how bash treat special characters, trying to find if I could fix it. But your suggestion would also be very welcomed.

liulirun commented 6 years ago

ok, using character skipping works here. So I change the command to http://griduser:blah\*\!@172.24.23.231:4444/quota from ggr linux server, I got correct quota:

[{"Name":"chrome","DefaultVersion":"64.0","Versions":[{"Number":"64.0","Regions":[{"Name":"1","Hosts":[{"Name":"172.24.23.232","Port":4444,"Count":8,"Username":"griduser","Password":"blah*!","VNC":"","Scheme":""},{"Name":"172.24.23.235","Port":4444,"Count":6,"Username":"","Password":"","VNC":"","Scheme":""}]}]}]}]
vania-pooh commented 6 years ago

@liulirun does it then works for tests with the same password?

liulirun commented 6 years ago

It works as expected. perfect, thank you so much for the help! I will close this issue

vania-pooh commented 6 years ago

Glad to hear!

upenbendre commented 4 years ago

I am facing the exact same issue as https://github.com/aerokube/ggr/issues/176, but it could not be resolved using the same fix. I get a 401 Unauthorized, when running the test: "http://test:testpassword@:4444/wd/hub" as you can see my password does not contain any special characters.

if I enter http://test:testpassword@10.222.26.74:4444/quota on the browser , it still prompts me for a username and password. If I enter the same credentials, it still gives me a '401 Unauthorized"

there are no messages in the ggr container log. All I have is: 2019/11/20 12:37:56 [-] [-] [INIT] [-] [-] [-] [-] [-] [-] [Users file is "/etc/grid-router/users.htpasswd"] 2019/11/20 12:37:56 [-] [-] [INIT] [-] [-] [-] [-] [-] [-] [Loading configuration files from "/etc/grid-router/quota"]

My quota file is /etc/grid-router/quota/test.xml

The UI URL at port 8080 correctly shows this ggr linked to all the selenoid hosts, and the total quota count.