ansible-documentation icon indicating copy to clipboard operation
ansible-documentation copied to clipboard

Unable to build documentation in proxy-only network environments using nox

Open brlin-tw opened this issue 1 year ago • 5 comments

I am in a network environment where internet access is only possible via a forward proxy service, and I noticed that the documentation build will error in the following occasions including but not limited to:

Session checkers(docs-build):

../../hacking/build-ansible.py docs-build core -o rst                                                                    
--> Standard Error                                                                                                       
[WARNING]: You are running the development version of Ansible. You should only                                           
run Ansible from "devel" if you are modifying the Ansible engine, or trying out                                          
features under development. This is a rapidly changing source of code and can
become unstable at any point.
/home/brlin/Workarounds/bindfs/ansible-documentation/.nox/checkers-docs-build/lib/python3.12/site-packages/antsibull_core
/utils/http.py:85: UserWarning: aio_session.get('https://galaxy.ansible.com/api/', headers={'Accept': 'application/json'}
) failed with status code Cannot connect to host galaxy.ansible.com:443 ssl:default [Temporary failure in name resolution
], retrying...
  warnings.warn(
/home/brlin/Workarounds/bindfs/ansible-documentation/.nox/checkers-docs-build/lib/python3.12/site-packages/antsibull_core
/utils/http.py:85: UserWarning: aio_session.get('https://galaxy.ansible.com/api/', headers={'Accept': 'application/json'}
) failed with status code Cannot connect to host galaxy.ansible.com:443 ssl:default [Temporary failure in name resolution
], finally failed.
  warnings.warn(
Traceback (most recent call last):
  File "/tmp/docs-build-7s0cud__-sanity/docs/docsite/../../hacking/build-ansible.py", line 130, in <module>
    main()

../../hacking/build-ansible.py docs-build core -o rst:

../../hacking/build-ansible.py docs-build core -o rst                                                                    
/home/brlin/Workarounds/bindfs/ansible-documentation/.nox/make/lib/python3.12/site-packages/antsibull_core/utils/http.py:
85: UserWarning: aio_session.get('https://galaxy.ansible.com/api/', headers={'Accept': 'application/json'}) failed with s
tatus code Cannot connect to host galaxy.ansible.com:443 ssl:default [Temporary failure in name resolution], retrying...

I have set and exported the following proxy-related environment variables:

$ printenv | grep -i proxy
no_proxy=localhost
https_proxy=http://192.168.49.1:8228
NO_PROXY=localhost
HTTPS_PROXY=http://192.168.49.1:8228
HTTP_PROXY=http://192.168.49.1:8228
http_proxy=http://192.168.49.1:8228

and have the Docker daemon configured to use the proxy service:

{
  "proxies": {
    "http-proxy": "http://192.168.49.1:8228",
    "https-proxy": "http://192.168.49.1:8228",
    "no-proxy": "localhost,127.0.0.0/8"
  }
}

It would be great if these settings are fully honored so that the build can be completed without switching network environments. Thanks in advance!

brlin-tw avatar Sep 24 '24 14:09 brlin-tw

@felixfontein FYI, this one might be of interest to you as there are antsibull_core messages in logs. Although they might be coming from underlying packages.

oraNod avatar Oct 01 '24 16:10 oraNod

antsibull-core and antsibull-docs use aiohttp (https://pypi.org/project/aiohttp/) for network requests. It seems to be possible to configure proxy usage there: https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support I'm not sure if there's support for environment variables like the ones mentioned above, I guess not (otherwise it should have worked I guess).

felixfontein avatar Oct 01 '24 18:10 felixfontein

@felixfontein

I'm not sure if there's support for environment variables like the ones mentioned above, I guess not (otherwise it should have worked I guess).

It seems to be supported ~~by~~ but not enabled by default:

Screenshot of the relevant section that addresses the support

brlin-tw avatar Oct 01 '24 18:10 brlin-tw

trust_env=True sounds like something we could enable. @gotmax23 what do you think?

Edit: we could also make this configurable (with default True, or to be more conservative, with default False; I think True would be ok).

felixfontein avatar Oct 02 '24 05:10 felixfontein

trust_env=True sounds like something we could enable. @gotmax23 what do you think?

Yeah, I think it makes sense to have that as the default.

Edit: we could also make this configurable (with default True, or to be more conservative, with default False; I think True would be ok).

Unless there's a strong reason to add a config that I'm missing, I'd prefer to just keep this simple.

gotmax23 avatar Oct 04 '24 21:10 gotmax23

Coming from the Systems side of things, I'd expect applications to implicitly respect my proxy settings. So, defaulting to True for this seems like a perfectly reasonable solution. If we find any use-cases where this is problematic, we can always come back and add a configuration option (but leave it defaulted to True)

x1101 avatar Oct 08 '24 19:10 x1101

antsibull-docs 2.15.0 now supports env variables for proxy configuration. #1994 updates the dependencies for this repo to use this version.

felixfontein avatar Oct 09 '24 19:10 felixfontein

I have checked out the new code and can verify that the fix works, thanks!

brlin-tw avatar Oct 10 '24 07:10 brlin-tw

Great to hear! :)

felixfontein avatar Oct 10 '24 17:10 felixfontein