-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Unix sockets #1118 #1129
Conversation
Hmm, can you elaborate more on what this is and who would use it and why? Is this only related to the luigi server? |
lgtm |
829be55
to
654387d
Compare
def fetch(self, full_url, body, timeout): | ||
try: | ||
body = urlencode(body).encode('utf-8') | ||
return urlopen(full_url, body, self._connect_timeout).read().decode('utf-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh this is scary. There's no such thing as a self._connect_timeout
in this context right? Is this code path really tested?
I know I've had to disable some tests on Travis. Can you make sure a normal tox -e py27-nonhdfs
passes before we merge this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah woops, looks like something depends on requests in your test dependencies. Will fix
36cf189
to
152ef30
Compare
@Tarrasch thanks for the review, I've made those changes. |
@@ -1,5 +1,5 @@ | |||
[tox] | |||
envlist = py{27,33,34}-{cdh,hdp,nonhdfs,gcloud,postgres}, pypy-scheduler, docs, pep8 | |||
envlist = py{27,33,34}-{cdh,hdp,nonhdfs,gcloud,postgres}{-unixsockets,}, pypy-scheduler, docs, pep8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, why multiplicative?
Starting to look better, but I want to make sure that this part of the code hold high quality as it's so central. :) |
@Tarrasch thanks! |
152ef30
to
f776f1c
Compare
Looks good to me now :) |
f776f1c
to
3b38b36
Compare
port=self._port, | ||
prefix=self._url_prefix, | ||
url=url) | ||
full_url = self._url + url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Erm, there's no way this line can be "right". Are the variable names extremely confusing? Or you actually string-concatenating two urls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full_url = self._url + url_suffix
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, that's much clearer.
This also adds support for TLS! Simply use https://exmaple.com/ for TLS or http+unix://%2Fvar%2Frun%2Fluigid%2Fluigid.sock/ for Unix sockets
3b38b36
to
ecc591b
Compare
Ok, can somebody else give a somewhat careful review and then we can merge? Maybe you can add some documentation @graingert? |
@Tarrasch docs added |
LGTM |
Add support for Unix sockets #1118
Cool, let's see how this does in the wild now :) |
@Tarrasch do you know when the next release might be? Is there an official release schedule? |
No, it'll take a while (month?) from now I think. Unless somebody really asks for it. I'll have to release a 2.0.0 since things have changed. |
|
||
self._url = url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If trailing /
is present on url
, fetcher gets lots of 404s for path //app/...
So it's better to do:
self._url = url.rstrip('/')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice if you could whip up a PR with testcase+fix. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was possible before with the url_prefix kwargument, so I did this intentionally. But yes the other behaviour makes way more sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@graingert I think I'm seeing this problem. Looking at the URLLibFetcher()
:
class URLLibFetcher(object):
def fetch(self, full_url, body, timeout):
try:
body = urlencode(body).encode('utf-8')
return urlopen(full_url, body, timeout).read().decode('utf-8')
except (URLError, socket.timeout) as e:
raise FetcherException(e)
For my task the full_url
is http://luigi-master:8082//api/add_task
, which has a double slash after the port. Changing that to a single slash seems to fix the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@graingert @Tarrasch @erikbern I think this PR may have broken something involving the worker-master communication, although it could be an issue with my cluster configuration. For reference, I'm using Google's ERROR:luigi-interface:Failed connecting to remote scheduler 'http://luigi-master:8082/'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/luigi/rpc.py", line 124, in _fetch
response = self._fetcher.fetch(full_url, body, self._connect_timeout)
File "/usr/local/lib/python2.7/dist-packages/luigi/rpc.py", line 71, in fetch
raise FetcherException(e)
FetcherException
WARNING: Failed pinging scheduler
WARNING:luigi-interface:Failed pinging scheduler I tried several different commits and I believe fb9a0a2 is the latest functional commit and 0a37979 introduced the change. The blame shows that the object raising this exception was added in a commit in this PR. The annotated screenshot might help to resolve the timeline. Is anyone else on GCE experiencing this behavior? |
@geowurster what's the "original_exc" from the worker? |
@graingert |
that's odd |
@graingert Can you commit to fixing this? I think it's pretty urgent if people can't rely on HEAD anymore! Is #1147 by @paxan related? |
This commit contains: * Removal of pretty much redundant tests in rpc_test * Moved tests from bin_test.py to server_test.py, as they were rendered useless after the refactoring in spotify#1129, probably forgotten since they were put in their own file in the first place. * Added test case 'test_with_cmdline' * Don't use any "random port", always use port 8083. Randomness like that leads to intermittent and irreproducible test failures. * Add a sanity check in INETURLLibServerTest that the HAS_REQUESTS mocking actually is meaningful. * Other small cleanups
This also adds support for TLS!
Simply use https://exmaple.com/ for TLS or http+unix://%2Fvar%2Frun%2Fluigid%2Fluigid.sock for Unix sockets
There doesn't seem to be any actual tests to see if the real fetch method works, as all the tests that cover RemoteScheduler patches "._fetch"