Bug 7567

Summary: distrodata/distro_check don't take into account proxies
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Aníbal Limón <anibal.limon>
Component: coreAssignee: Leonardo Sandoval Gonzalez <leonardo.sandoval.gonzalez>
Status: VERIFIED FIXED QA Contact: Bogdan Alexandru Voiculescu <bogdanx.a.voiculescu>
Severity: enhancement    
Priority: Medium CC: alexander.kanevskiy, anibal.limon, benjamin.esquivel, bogdanx.a.voiculescu, meta.mr.watcher, meta.watcher, ross.burton
Version: 1.9   
Target Milestone: 2.0   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Aníbal Limón 2015-04-03 18:27:25 UTC
When try to run distro_check it needs to manual specify proxy exports into local.conf.

It needs to do automatically like fetcher.
Comment 1 Leonardo Sandoval Gonzalez 2015-09-02 17:15:12 UTC
Patch sent to the OE mailing list.
Comment 2 Leonardo Sandoval Gonzalez 2015-09-21 16:15:47 UTC
patch already sent to the OE mailing list, just waiting for its revision/merge. Moving it to 2.0.
Comment 3 Alexander Kanevskiy 2015-09-30 15:01:32 UTC
any progress on patch after one week ?
Comment 4 Leonardo Sandoval Gonzalez 2015-10-07 13:44:40 UTC
Patch merged on master:
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=12cd705b28412c1342c1c022340c13b1ef2c8a71
Comment 5 Alexander Kanevskiy 2015-10-08 13:41:13 UTC
Is this code ever being tested in real environment where proxy is the only way out to internet ?

I'm observing where it still tries to connect directly, even if proxy variables are present.

$ netstat -tnap | grep SYN
tcp        0      1 10.xx.xx.xxx:56652     130.89.148.12:80        SYN_SENT    20862/python


After a bit more looking inside, it looks like problem is in argument that is passed to 
urllib.urlopen()


it passes dictionary like this:

{'HTTP_PROXY': None, 'ALL_PROXY': None, 'https_proxy': 'http://proxy-chain:911', 'NO_PROXY': None, 'all_proxy': None, 'http_proxy': 'http://proxy-chain:911', 'ftp_proxy': 'http://proxy-chain:911', 'HTTPS_PROXY': None, 'FTP_PROXY': None, 'FTPS_PROXY': None, 'ftps_proxy': None, 'no_proxy': 'localhost, 127.0.0.1'}

Where, in reality, urlopen() expects proxies dictionary in format:
proxies = {'http': 'http://www.someproxy.com:3128'}

https://docs.python.org/2/library/urllib.html#urllib.urlopen

function get_proxies(d) should be looking something like this to work correctly:

def get_proxies(d):
    proxies = {}
    for proto in [ 'http', 'https', 'ftp']:
        for key in [ proto+'_proxy', proto.upper()+'_PROXY']:
            proxy = d.getVar(key, True)
            if proxy:
               proxies[proto] = proxy
               break
    return proxies
Comment 6 Leonardo Sandoval Gonzalez 2015-10-08 13:50:47 UTC
(In reply to comment #5)
> Is this code ever being tested in real environment where proxy is the only
> way out to internet ?

I did test it. Let me check again and provide a patch if necessary.
Comment 7 Leonardo Sandoval Gonzalez 2015-10-08 14:06:52 UTC
(In reply to comment #5)
> Is this code ever being tested in real environment where proxy is the only
> way out to internet ?
> 
> I'm observing where it still tries to connect directly, even if proxy
> variables are present.
> 
> $ netstat -tnap | grep SYN
> tcp        0      1 10.xx.xx.xxx:56652     130.89.148.12:80        SYN_SENT 
> 20862/python
> 
> 
> After a bit more looking inside, it looks like problem is in argument that
> is passed to 
> urllib.urlopen()
> 
> 
> it passes dictionary like this:
> 
> {'HTTP_PROXY': None, 'ALL_PROXY': None, 'https_proxy':
> 'http://proxy-chain:911', 'NO_PROXY': None, 'all_proxy': None, 'http_proxy':
> 'http://proxy-chain:911', 'ftp_proxy': 'http://proxy-chain:911',
> 'HTTPS_PROXY': None, 'FTP_PROXY': None, 'FTPS_PROXY': None, 'ftps_proxy':
> None, 'no_proxy': 'localhost, 127.0.0.1'}
> 
> Where, in reality, urlopen() expects proxies dictionary in format:
> proxies = {'http': 'http://www.someproxy.com:3128'}
> 
> https://docs.python.org/2/library/urllib.html#urllib.urlopen
> 
> function get_proxies(d) should be looking something like this to work
> correctly:
> 
> def get_proxies(d):
>     proxies = {}
>     for proto in [ 'http', 'https', 'ftp']:
>         for key in [ proto+'_proxy', proto.upper()+'_PROXY']:
>             proxy = d.getVar(key, True)
>             if proxy:
>                proxies[proto] = proxy
>                break
>     return proxies

Alex,

you are right. If proxies are passed through the environment, then the variables end with '_proxies', if these are passed through a python dictionary, the keys do not have this world. Sending a fix today.
Comment 8 Leonardo Sandoval Gonzalez 2015-10-08 19:44:10 UTC
Patch sent to the ML:

http://lists.openembedded.org/pipermail/openembedded-core/2015-October/111390.html
Comment 9 Ross Burton 2015-11-05 16:27:38 UTC
Fixed in oe-core 92fb327b08e4f9cfb2400610c2983afe579b3592.
Comment 10 Bogdan Alexandru Voiculescu 2016-01-22 07:55:36 UTC
Verified on 8c8c4ede3ff5ac8ca739020d9efed91159acccc1

Tested on a network with proxy, adding 'INHERIT += "distrodata"' on local.conf
with the following commands

    for distrotask in distrodataall distro_checkall checklicenseall; do
        bitbake core-image-minimal -c $distrotask
    done