Skip to content
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

Merged
merged 2 commits into from
Aug 16, 2015

Conversation

graingert
Copy link
Contributor

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"

@Tarrasch
Copy link
Contributor

Hmm, can you elaborate more on what this is and who would use it and why? Is this only related to the luigi server?

@graingert
Copy link
Contributor Author

@Tarrasch the discussion is in #1118

@erikbern
Copy link
Contributor

lgtm

@graingert graingert force-pushed the support-unix-sockets branch 2 times, most recently from 829be55 to 654387d Compare August 13, 2015 16:48
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')
Copy link
Contributor

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?

Copy link
Contributor Author

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

@graingert graingert force-pushed the support-unix-sockets branch 2 times, most recently from 36cf189 to 152ef30 Compare August 14, 2015 11:24
@graingert
Copy link
Contributor Author

@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, why multiplicative?

@Tarrasch
Copy link
Contributor

Starting to look better, but I want to make sure that this part of the code hold high quality as it's so central. :)

@graingert
Copy link
Contributor Author

@Tarrasch thanks!

@Tarrasch
Copy link
Contributor

Looks good to me now :)

port=self._port,
prefix=self._url_prefix,
url=url)
full_url = self._url + url
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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
@Tarrasch
Copy link
Contributor

Ok, can somebody else give a somewhat careful review and then we can merge? Maybe you can add some documentation @graingert?

@graingert
Copy link
Contributor Author

@Tarrasch docs added

@erikbern
Copy link
Contributor

LGTM

Tarrasch added a commit that referenced this pull request Aug 16, 2015
@Tarrasch Tarrasch merged commit 0a37979 into spotify:master Aug 16, 2015
@Tarrasch
Copy link
Contributor

Cool, let's see how this does in the wild now :)

@graingert graingert deleted the support-unix-sockets branch August 16, 2015 21:10
@graingert
Copy link
Contributor Author

@Tarrasch do you know when the next release might be? Is there an official release schedule?

@Tarrasch
Copy link
Contributor

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
Copy link
Contributor

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('/')

Copy link
Contributor

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. :)

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tarrasch here you go:
#1147

@geowurster
Copy link
Contributor

@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 bdutil 1.3.1 (latest) to configure and deploy a hadoop cluster on Google Compute Engine. After installing the latest commit on master my workers are not able to connect to the scheduler:

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?

commits_ _spotify_luigi

@graingert
Copy link
Contributor Author

@geowurster what's the "original_exc" from the worker?

@geowurster
Copy link
Contributor

@graingert HTTP Error 404: Not Found. The log stream contains the IP and port, which I can navigate to in a browser without issue and see the task visualizer.

@graingert
Copy link
Contributor Author

that's odd

@Tarrasch
Copy link
Contributor

@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?

Tarrasch added a commit to Tarrasch/luigi that referenced this pull request Sep 13, 2015
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants