Initial support for chronos 3.x for #33#35
Conversation
This is the initial draft I wrote for support of chronos >= 3.x It tries to play nice with versions < 3.x as well and it doesn't keep you from shooting yourself in the foot. I am undecided at which point you draw the line in the sand and only allow valid values sent. Tested vs chronos 2.4 and 3.0.x
|
I had to skirt around the testing environment because it is not so easy to change, however I came up with the following docker-compose.yml: Which allows you to spin up a chronos 2.4 on port 4402 and a chronos 3.0.2 on port 4403, then I could modify |
|
And of course travis build failed because the test env is not updated. I didn't want to mess with it but my idea would be to default to test everything in docker under travis via docker-compose https://docs.travis-ci.com/user/docker/ and run the same tests vs either port, depending which version of chronos you want to test (the docker-compose port bits would need updating as well) what do you think @Rob-Johnson ? |
|
How about just append the You could do docker compose, we use it in https://github.com/thefactory/marathon-python. I recommend avoiding the complexity if you can. |
|
The whole test setup right now relies on debian packages being available so
chronos can be installed. Mesosphere stopped building packages in v3.0 and
only provide docker images, so that test infrastructure is a no-go from now
on. However they have been providing docker images for quite some time,
meaning we can just move the whole thing over to use docker images. Not
saying it is the best way to go, but seems like options are limited (unless
we wanna start building chronos debian packages ourselves)
…--
~kad
On Tue, Mar 7, 2017 at 9:52 PM, Kyle Anderson ***@***.***> wrote:
How about just append the env to include a new CHRONOSVERSION and travis
will matrix it out? Why *not* mess with it? This to me seems like the
most direct way to test this, and only requires one line added to the
.travis.yaml file.
You could do docker compose, we use it in https://github.com/thefactory/
marathon-python. I recommend avoiding the complexity if you can.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#35 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC1Vl-9bbfw8RKvtLCqnL3uAXU-Cu4vks5rjiXngaJpZM4MV0ki>
.
|
|
Oh right, no debs from upstream. We'll docker it is I guess. Again the marathon-python does have some "ok" prior art. |
Which is pretty fantastic
Now it is a matter of passing the appropriate docker node defined in the docker-compose.yml file. All chronos nodes will expose chronos on port 4400 so all client calls will be done to localhost port 4400. No need to figure out magically which port docker-compose is exposing or anything (at least in theory)
Instead of on various files
| else: | ||
| if scheduler_version not in SCHEDULER_VERSIONS: | ||
| raise ChronosAPIError('Wrong scheduler_version provided') | ||
| self._prefix = "/%s" % (scheduler_version,) |
There was a problem hiding this comment.
I think you need to add empty-string '' to list list of acceptable SCHEDULER_VERSIONS, or allow None so people can keep using < 3
| raise MissingFieldError("missing required field %s" % k) | ||
|
|
||
| # Chronos v3.x rejects job names with spaces in them | ||
| regex = re.compile(r'^[\w.-]+$') |
There was a problem hiding this comment.
what about < 3 though? this isn't really allowing for backwards compatibility - if I were you I'd let this happen and have clients deal with the failure (hopefully chronos spits out a reasonably informative error message?)
|
|
||
| class ChronosJob(object): | ||
| fields = [ | ||
| "async", |
There was a problem hiding this comment.
same comment re < 3. You're not really allowing for backwards compat here.
This reverts commit 538d9bb.
This way we'll properly raise an exception when the API returns a non OK status code.
This way we can test on multiple versions again
This way we can support more than 1 version
|
@Rob-Johnson So I worked out most of the compatibility issues, but I seem to have tripped the py.test tests with da54db4, I am raising an ChronosAPIError when the chronos api, well, returns an error. However: These 3 tests make me think not raising an error on chronos api errors was actually intentional, do you still think that's a valid route and I should revert the exception raising? or should the tests be reworked? |
|
those tests are more for handling Chronos not consistently returning JSON in failure modes. Happy for you to rework them as you see fit, so long as we keep similar behaviour: that is, the client handles non-json responses appropriately. |
Also the payload message might be too long as is
And also since we're throwing exceptions, make sure to catch them properly
|
@Rob-Johnson let me know what you think re: 1ba92a9 also I fixed the build and it now passes with 2.4.0 and 3.0.2 with both python 2.7 and 3.5. |
Rob-Johnson
left a comment
There was a problem hiding this comment.
one last thing, but otherwise this looks good to me. want to take a glance over it @solarkennedy? one action point for us at Yelp is going to be adding api_version=None to our calls to create a Chronos client until we get our fork inline with upstream.
| except ImportError: | ||
| from urllib.parse import quote | ||
|
|
||
| SCHEDULER_VERSIONS = ('v1',) |
There was a problem hiding this comment.
can we rename this (and all mentions of scheduler_version) to be API_VERSION instead? it just makes it a little clearer what this actually does.
There was a problem hiding this comment.
@Rob-Johnson I thought about this, but since chronos appears to have multiple APIs and they are only versioning /scheduler/* (they don't prefix /metrics, for example) that's why I decided to use this variable. Happy to change it to whatever name makes the most sense, naming is hard 😊
There was a problem hiding this comment.
how about.... scheduler_api_version?
There was a problem hiding this comment.
😲 see this is exactly why you get paid the big bucks @ yelp, gonna do that.
|
thanks @thekad ! |
This is the initial draft I wrote for support of chronos >= 3.x
It tries to play nice with versions < 3.x as well and it doesn't keep you from
shooting yourself in the foot. I am undecided at which point you draw the line
in the sand and only allow valid values sent.
Tested vs chronos 2.4 and 3.0.x