New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 672729 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
OoO until Feb 4th
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

git cl upload to Gerrit error under proxy

Reported by xiangze....@intel.com, Dec 9 2016

Issue description

I met an issue that git cl upload cannot complete after skia review changed from Rietveld to Gerrit. git cl upload --rietveld works well.

My environment needs proxy to connect to Internet. Seems the script does not respect http_proxy/https_proxy environment variables at some point.


Error log:

xiangze@xiangze-desktop:~/skia$ git cl upload -v
Using 50% similarity for rename/copy detection. Override with --similarity.
Running presubmit upload checks ...
Running /home/xiangze/skia/PRESUBMIT.py
INFO:PRESUBMIT:Skipping pylint: no matching changes.

Presubmit checks passed.
 whitespace.txt | 1 -
 1 file changed, 1 deletion(-)
remote: Processing changes: new: 1, done    
remote: 
remote: New Changes:
remote:   https://skia-review.googlesource.com/5741 test
remote: 
To https://skia.googlesource.com/skia.git
 * [new branch]      8ede2121113ba298856b8d249faa1687447b5075 -> refs/for/refs/heads/master%notify=NONE
Traceback (most recent call last):
  File "/home/xiangze/chromium/depot_tools/git_cl.py", line 5651, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/home/xiangze/chromium/depot_tools/git_cl.py", line 5633, in main
    return dispatcher.execute(OptionParser(), argv)
  File "/home/xiangze/chromium/depot_tools/subcommand.py", line 252, in execute
    return command(parser, args[1:])
  File "/home/xiangze/chromium/depot_tools/git_cl.py", line 4418, in CMDupload
    return cl.CMDUpload(options, args, orig_args)
  File "/home/xiangze/chromium/depot_tools/git_cl.py", line 1763, in CMDUpload
    ret = self.CMDUploadChange(options, git_diff_args, change)
  File "/home/xiangze/chromium/depot_tools/git_cl.py", line 3002, in CMDUploadChange
    self._GetGerritHost(), self.GetIssue(), cc, is_reviewer=False)
  File "/home/xiangze/chromium/depot_tools/gerrit_util.py", line 663, in AddReviewers
    conn = CreateHttpConn(host, path, reqtype='POST', body=body)
  File "/home/xiangze/chromium/depot_tools/gerrit_util.py", line 317, in CreateHttpConn
    conn.request(**conn.req_params)
  File "/usr/lib/python2.7/httplib.py", line 1057, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1097, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 1053, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 897, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 859, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 1270, in connect
    HTTPConnection.connect(self)
  File "/usr/lib/python2.7/httplib.py", line 836, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python2.7/socket.py", line 575, in create_connection
    raise err
socket.error: [Errno 101] Network is unreachable

 

Comment 1 by rmis...@google.com, Dec 9 2016

Cc: aga...@chromium.org rmis...@chromium.org tandrii@chromium.org
Labels: Proj-Gerrit-Migration
Note: "git cl upload" worked for the user under Rietveld but fails for Gerrit.
I have no idea how to fix test/this, but the relevant code is in gerrit_util.py method CreateHttpConn:

https://cs.chromium.org/chromium/tools/depot_tools/gerrit_util.py?q=depot_tools+gerrit_util&sq=package:chromium&dr=C&l=309

I'd be happy to review the patch though.
Rietveld's upload.py uses urllib2, and installs the urllib2.ProxyHandler() on the url opener, to ensure that the http_proxy and https_proxy environment variables are handled correctly.

gerrit_util.py uses httplib, which requires users to create the connection *to the proxy* and then call .set_tunnel() to specify the actual desired target host.

I have no idea why gerrit_util went backwards and decided to use the less powerful library for this, but that's how szager wrote it in the very first version.

I'm not sure whether its easier to bend over backwards to use httplib's terrible proxy api, or to upgrade the whole file to use urllib2 instead.
Labels: TE-NeedsTriageHelp
Labels: -TE-NeedsTriageHelp
Status: Available (was: Unconfirmed)
more on agable@'s comment 3:
 upload.py uses urllib2, but rietveld.py itself since May 2015 uses third_party.oauth2client.client, and not upload.py to transport. I have no idea if proxy is respected there :(

Comment 6 by aga...@chromium.org, Jan 11 2017

Labels: Milestone-Launch
Components: Infra>Codereview>Gerrit Infra>SDK
Cc: dpranke@chromium.org
 Issue 704201  has been merged into this issue.
Cc: alexis.m...@intel.com
alexis.menard@intel.com proposed a fix in  issue 704201 :
https://gist.github.com/darktears/8b5f248799d8c0310290ba136c1566b2


alexis.menard@ : Can you send us actual CL with "git cl upload" once you patch your depot_tools?  This will also prove that your CL behind a proxy :)
I've worked a bit more on the original patch and sent it for review: https://chromium-review.googlesource.com/c/458221
Project Member

Comment 11 by bugdroid1@chromium.org, Mar 23 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/tools/depot_tools/+/d75686454bb0ad8d4718ff6bf9613772ca8027b5

commit d75686454bb0ad8d4718ff6bf9613772ca8027b5
Author: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Date: Thu Mar 23 17:30:02 2017

gerrit_util: Use httplib2 for communication instead of httplib.

Retain the httplib import to continue using its constants, but actually make
the http(s) connections using httplib2. The latter has built-in support for
proxy settings, which then actually allows people behind proxies to interact
with Gerrit.

Compared to httplib, the biggest changes are:
- There's only one Http class instead of HTTPConnection and HTTPSConnection.
- Http.request() returns a tuple (response, contents).
- Http.request() expects a full URI instead of just a path, as Http's
  constructor does not take a host parameter.
- The response object inherits from dict.
- All headers in a response are lower-cased.

All in all, it is possible to see that httplib2 support was retro-fitted
into the code, but that should not worsen its readability overall.

Patch written in collaboration with Alexis Menard <alexis.menard@intel.com>.

BUG= 672729 
R=alexis.menard@intel.com,agable@chromium.org,tandrii@chromium.org

Change-Id: Ic40e804064e74e89bc2ad979572628f1bd78c19a
Reviewed-on: https://chromium-review.googlesource.com/458221
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>

[modify] https://crrev.com/d75686454bb0ad8d4718ff6bf9613772ca8027b5/gerrit_util.py

Labels: -Milestone-Launch
Owner: raphael....@intel.com
Status: Fixed (was: Available)
The commit above should fix the issue. If something weird comes up (or the non-proxy workflow is negatively affected), please let me or Alexis know.
Project Member

Comment 13 by bugdroid1@chromium.org, Mar 23 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/tools/depot_tools/+/25ab6a34c2d37ed806e49c334c8b79404d03c8f1

commit 25ab6a34c2d37ed806e49c334c8b79404d03c8f1
Author: Aaron Gable <agable@chromium.org>
Date: Thu Mar 23 17:34:15 2017

Revert "gerrit_util: Use httplib2 for communication instead of httplib."

This reverts commit d75686454bb0ad8d4718ff6bf9613772ca8027b5.

Reason for revert:
third_party.httplib2.ServerNotFoundError: Unable to find the server at metadata.google.internal

Original change's description:
> gerrit_util: Use httplib2 for communication instead of httplib.
> 
> Retain the httplib import to continue using its constants, but actually make
> the http(s) connections using httplib2. The latter has built-in support for
> proxy settings, which then actually allows people behind proxies to interact
> with Gerrit.
> 
> Compared to httplib, the biggest changes are:
> - There's only one Http class instead of HTTPConnection and HTTPSConnection.
> - Http.request() returns a tuple (response, contents).
> - Http.request() expects a full URI instead of just a path, as Http's
>   constructor does not take a host parameter.
> - The response object inherits from dict.
> - All headers in a response are lower-cased.
> 
> All in all, it is possible to see that httplib2 support was retro-fitted
> into the code, but that should not worsen its readability overall.
> 
> Patch written in collaboration with Alexis Menard <alexis.menard@intel.com>.
> 
> BUG= 672729 
> R=​alexis.menard@intel.com,agable@chromium.org,tandrii@chromium.org
> 
> Change-Id: Ic40e804064e74e89bc2ad979572628f1bd78c19a
> Reviewed-on: https://chromium-review.googlesource.com/458221
> Reviewed-by: Aaron Gable <agable@chromium.org>
> Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>
> 

TBR=agable@chromium.org,alexis.menard@intel.com,raphael.kubo.da.costa@intel.com,tandrii@chromium.org,chromium-reviews@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG= 672729 

Change-Id: Idfacd314b381232733bb92a02ec2fb85f016effd
Reviewed-on: https://chromium-review.googlesource.com/457792
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>

[modify] https://crrev.com/25ab6a34c2d37ed806e49c334c8b79404d03c8f1/gerrit_util.py

Status: Started (was: Fixed)
Looks like I was too optimistic :)
I had to revert the patch, unfortunately. Uploading gave me the following stack trace (and reverting locally fixed the issue):

± git cl upload
Using 50% similarity for rename/copy detection. Override with --similarity.
Traceback (most recent call last):
  File "/usr/local/google/home/agable/local/bin/depot_tools/git_cl.py", line 5687, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/usr/local/google/home/agable/local/bin/depot_tools/git_cl.py", line 5669, in main
    return dispatcher.execute(OptionParser(), argv)
  File "/work/infra/depot_tools/subcommand.py", line 252, in execute
    return command(parser, args[1:])
  File "/usr/local/google/home/agable/local/bin/depot_tools/git_cl.py", line 4655, in CMDupload
    return cl.CMDUpload(options, args, orig_args)
  File "/usr/local/google/home/agable/local/bin/depot_tools/git_cl.py", line 1542, in CMDUpload
    self._codereview_impl.EnsureAuthenticated(force=options.force)
  File "/usr/local/google/home/agable/local/bin/depot_tools/git_cl.py", line 2349, in EnsureAuthenticated
    if gerrit_util.GceAuthenticator.is_gce():
  File "/work/infra/depot_tools/gerrit_util.py", line 224, in is_gce
    cls._cache_is_gce = cls._test_is_gce()
  File "/work/infra/depot_tools/gerrit_util.py", line 231, in _test_is_gce
    resp, _ = cls._get(cls._INFO_URL)
  File "/work/infra/depot_tools/gerrit_util.py", line 250, in _get
    resp, contents = c.request(url, 'GET', **kwargs)
  File "/work/infra/depot_tools/third_party/httplib2/__init__.py", line 1609, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/work/infra/depot_tools/third_party/httplib2/__init__.py", line 1351, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/work/infra/depot_tools/third_party/httplib2/__init__.py", line 1278, in _conn_request
    raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
third_party.httplib2.ServerNotFoundError: Unable to find the server at metadata.google.internal
Ironically, I think I didn't catch this when working on the patch because my corporate proxy and DNS combination caused the request to metadata.google.internal not to fail at the DNS level...
https://chromium-review.googlesource.com/c/458480/ has a second attempt at fixing this bug.
Project Member

Comment 18 by bugdroid1@chromium.org, Mar 23 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/tools/depot_tools/+/89d04858c88d91acf491e259d293ba3206713357

commit 89d04858c88d91acf491e259d293ba3206713357
Author: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Date: Thu Mar 23 18:41:07 2017

gerrit_util: Use httplib2 for communication instead of httplib.

Retain the httplib import to continue using its constants, but actually make
the http(s) connections using httplib2. The latter has built-in support for
proxy settings, which then actually allows people behind proxies to interact
with Gerrit.

Compared to httplib, the biggest changes are:
- There's only one Http class instead of HTTPConnection and HTTPSConnection.
- Http.request() returns a tuple (response, contents).
- Http.request() expects a full URI instead of just a path, as Http's
  constructor does not take a host parameter.
- The response object inherits from dict.
- All headers in a response are lower-cased.

All in all, it is possible to see that httplib2 support was retro-fitted
into the code, but that should not worsen its readability.

Changes since https://chromium-review.googlesource.com/c/458221/:
- Catch httplib2.ServerNotFoundError exceptions in GceAuthenticator, as httplib2
  catches socket.gaierror (which was previously being used to detect when
  metadata.google.internal was not accessible) and throws a ServerNotFoundError
  exception instead.

Patch written in collaboration with Alexis Menard <alexis.menard@intel.com>.

BUG= 672729 
R=alexis.menard@intel.com,agable@chromium.org,tandrii@chromium.org

Change-Id: Iaefa9caf3d8c0bc6ff67f562cd0b6bd9fade2f24
Reviewed-on: https://chromium-review.googlesource.com/458480
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>

[modify] https://crrev.com/89d04858c88d91acf491e259d293ba3206713357/gerrit_util.py

Project Member

Comment 19 by bugdroid1@chromium.org, Mar 23 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/tools/depot_tools/+/89d04858c88d91acf491e259d293ba3206713357

commit 89d04858c88d91acf491e259d293ba3206713357
Author: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Date: Thu Mar 23 18:41:07 2017

gerrit_util: Use httplib2 for communication instead of httplib.

Retain the httplib import to continue using its constants, but actually make
the http(s) connections using httplib2. The latter has built-in support for
proxy settings, which then actually allows people behind proxies to interact
with Gerrit.

Compared to httplib, the biggest changes are:
- There's only one Http class instead of HTTPConnection and HTTPSConnection.
- Http.request() returns a tuple (response, contents).
- Http.request() expects a full URI instead of just a path, as Http's
  constructor does not take a host parameter.
- The response object inherits from dict.
- All headers in a response are lower-cased.

All in all, it is possible to see that httplib2 support was retro-fitted
into the code, but that should not worsen its readability.

Changes since https://chromium-review.googlesource.com/c/458221/:
- Catch httplib2.ServerNotFoundError exceptions in GceAuthenticator, as httplib2
  catches socket.gaierror (which was previously being used to detect when
  metadata.google.internal was not accessible) and throws a ServerNotFoundError
  exception instead.

Patch written in collaboration with Alexis Menard <alexis.menard@intel.com>.

BUG= 672729 
R=alexis.menard@intel.com,agable@chromium.org,tandrii@chromium.org

Change-Id: Iaefa9caf3d8c0bc6ff67f562cd0b6bd9fade2f24
Reviewed-on: https://chromium-review.googlesource.com/458480
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>

[modify] https://crrev.com/89d04858c88d91acf491e259d293ba3206713357/gerrit_util.py

Status: Fixed (was: Started)
Nothing seems to have exploded this time, so closing again.

Sign in to add a comment