SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.7k stars 8.19k forks source link

[🐛 Bug]: selenium-manager fails if /etc/resolve.conf contains "options ndots:5" #13625

Closed kimata closed 8 months ago

kimata commented 8 months ago

What happened?

selenium-manager --browser chrome --debug --language-binding python --output json fails with the following message.

    {
      "level": "ERROR",
      "timestamp": 1708749565,
      "message": "error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json): error trying to connect: dns error: failed to lookup address information: Name does not resolve"
    }

It looks like a problem with the Rust reqwest::Client library used by selenium-manager, but I can't read Rust, so I'm not sure.

How can we reproduce the issue?

Add the following lines to /etc/resolve.conf

search svc.cluster.local cluster.local 
options ndots:5

Adding the above will cause an error; removing the ndots specification will not.


### Relevant log output

```shell
{                                                                                                                                                                                                         
  "logs": [                                                                                                                                                                                               
    {                                                                                                                                                                                                     
      "level": "DEBUG",                                                                                                                                                                                   
      "timestamp": 1708749565,                                                                                                                                                                            
      "message": "Sending stats to Plausible: Props { browser: \"chrome\", browser_version: \"\", os: \"linux\", arch: \"x86_64\", lang: \"python\", selenium_version: \"4.18\" }"                        
    },                                                                                                                                                                                                    
    {                                                                                                                                                                                                     
      "level": "DEBUG",                                                                                                                                                                                   
      "timestamp": 1708749565,                                                                                                                                                                            
      "message": "chromedriver not found in PATH"                                                                                                                                                         
    },                                                                                                                                                                                                    
    {                                                                                                                                                                                                     
      "level": "DEBUG",                                                                                                                                                                                   
      "timestamp": 1708749565,
      "message": "Found chromium-browser in PATH: /usr/bin/chromium-browser"
    },
    { 
      "level": "DEBUG",
      "timestamp": 1708749565,
      "message": "Running command: /usr/bin/chromium-browser --version"
    },
    { 
      "level": "DEBUG",
      "timestamp": 1708749565,
      "message": "Output: \"Chromium 122.0.6261.57 snap\""
    },
    { 
      "level": "DEBUG",
      "timestamp": 1708749565,
      "message": "Detected browser: chrome 122.0.6261.57"
    },
    {                                                                                                                                                                                                    
      "level": "DEBUG",       
      "timestamp": 1708749565,                                                                                                                                                                       
      "message": "Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json"                                                               
    },                        
    {                                                                                                                                                                                                    
      "level": "ERROR",                           
      "timestamp": 1708749565,
      "message": "error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json): error trying to connect: dns error: failed to lookup addr
ess information: Name does not resolve"                                                        
    }                 
  ],                                                                                                                                                                                                     
  "result": {                                     
    "code": 65,                                   
    "message": "error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json): error trying to connect: dns error: failed to lookup addres
s information: Name does not resolve",                                                                                                                                                               
    "driver_path": "",                            
    "browser_path": ""                            
  }                                                                                                                                                                                                      
}

Operating System

Ubuntu

Selenium version

Python 4.18.1

What are the browser(s) and version(s) where you see this issue?

Chrome 122.0.6261.57

What are the browser driver(s) and version(s) where you see this issue?

None

Are you using Selenium Grid?

No response

github-actions[bot] commented 8 months ago

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

kimata commented 8 months ago

Supplemental information.

Even in the environment where the problem occurs (ndots is listed in resolve.conf), name resolution by dig is working, and cURL "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json" can be obtained without any problem.

diemol commented 8 months ago

Why is this a Selenium Manager issue? We do not do anything with the network, the request is simply sent. After reading about options ndots:5, you change how your host resolves names. From that perspective, the tooling is doing what you are asking for.

If you are running tests inside Kubernetes, a better approach would be to configure the image so the driver is ready, and you can avoid those network calls. See more at https://www.selenium.dev/documentation/selenium_manager/

diemol commented 8 months ago

If you have more questions, please use the links below.

kimata commented 8 months ago

My understanding is that "ndots" is used when you want to treat a given name not only as an FQDN, but also as a hostname. See below for details.

Resolver queries having fewer than ndots dots (default is 1) in them will be attempted usingeach component of the search path in turn until a match is found. https://man7.org/linux/man-pages/man5/resolv.conf.5.html

Thus, if ndots:5 is specified, it is expected that the name "googlechromelabs.github.io" is treated as hostname before it is treated as FQDN. And, finally "googlechromelabs.github.io" is treated as FQDN.

Other tools such as cURL and Wget are able to resolve "googlechromelabs.github.io" without problems in the same environment.

Therefore, I think the above behavior is a bug in Selenium Manager. (I believe the problem is probably related to the libraries used by Selenium Manager.)

diemol commented 8 months ago

It is not a bug in Selenium Manager but likely in the HTTP library. I think we use https://github.com/seanmonstar/reqwest.

Can you please create an issue over there?

(@bonigarcia is that the correct library?)

bonigarcia commented 8 months ago

(@bonigarcia is that the correct library?)

Yes, that is correct.

@kimata I've looked into your problem. I believe the problem is a connectivity issue at your end, not a bug. I found a similar issue in another Rust-based tool:

https://github.com/codota/TabNine/issues/319

They solved the problem by setting the proxy settings.

See more info about proxies in Selenium here:

https://www.selenium.dev/documentation/selenium_manager/#connectivity-issues https://www.selenium.dev/documentation/webdriver/drivers/options/#proxy

kimata commented 8 months ago

Thanks for your comment.

However, the problem is occurring in an environment where no proxy is required, and I have not set the environment variable HTTPS?_PROXY, so I believe it is different from the source of the link you mentioned.

I should probably talk to the reqwest maintainer, but I can't read Rust at the moment, so I'll leave it to someone who knows Rust.

Thank you.

github-actions[bot] commented 7 months ago

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