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

RFC: Blocking queries index param #89

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

damoxc
Copy link
Contributor

@damoxc damoxc commented Jan 24, 2019

I've tried to implement this in a backwards compatible way, without adjusting the return value from API calls, so using a dictionary to essentially pass the index parameter by reference rather than value making it possible to update.

Interested in your thoughts on it.

@codecov-io
Copy link

codecov-io commented Jan 24, 2019

Codecov Report

Merging #89 into master will decrease coverage by 0.14%.
The diff coverage is 96.49%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #89      +/-   ##
==========================================
- Coverage   91.23%   91.09%   -0.15%     
==========================================
  Files          26       26              
  Lines        1038     1044       +6     
==========================================
+ Hits          947      951       +4     
- Misses         91       93       +2
Impacted Files Coverage Δ
nomad/api/nodes.py 88.37% <100%> (ø) ⬆️
nomad/api/evaluation.py 100% <100%> (ø) ⬆️
nomad/api/namespaces.py 57.5% <100%> (ø) ⬆️
nomad/api/allocations.py 100% <100%> (ø) ⬆️
nomad/api/jobs.py 89.58% <100%> (ø) ⬆️
nomad/api/sentinel.py 85.71% <100%> (ø) ⬆️
nomad/api/deployment.py 93.33% <100%> (ø) ⬆️
nomad/api/node.py 84.61% <100%> (ø) ⬆️
nomad/api/evaluations.py 92.3% <100%> (ø) ⬆️
nomad/api/allocation.py 100% <100%> (ø) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 03557e3...ff27bc9. Read the comment docs.

@@ -10,12 +10,13 @@ class Requester(object):

ENDPOINT = ""

def __init__(self, address=None, uri='http://127.0.0.1', port=4646, namespace=None, token=None, timeout=5, version='v1', verify=False, cert=(), region=None, **kwargs):
def __init__(self, address=None, uri='http://127.0.0.1', port=4646, namespace=None, token=None, timeout=5, blocking_timeout=360, version='v1', verify=False, cert=(), region=None, **kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would we want to add this to nomad/__init__.py to pass this when creating all the endpoint objects so the blocking_timeout could be adjusted on the constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we would! That was purely an oversight on my behalf after setting a default which was usable for my purposes.

Copy link
Collaborator

@jonathanrcross jonathanrcross left a comment

Choose a reason for hiding this comment

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

This looks great @damoxc! Just the one question about customizing the blockout time and if you would have any recommendations on the endpoints that do support blocking to test that on an integration level? We could totally do unit as well.

@damoxc
Copy link
Contributor Author

damoxc commented Jan 30, 2019

Regarding the timeouts, the blocking endpoints also support a wait parameter which is a Golang parseable duration . Docs are:

In addition to index, endpoints that support blocking will also honor a wait parameter specifying a maximum duration for the blocking request. This is limited to 10 minutes. If not set, the wait time defaults to 5 minutes. This value can be specified in the form of "10s" or "5m" (i.e., 10 seconds or 5 minutes, respectively). A small random amount of additional wait time is added to the supplied maximum wait time to spread out the wake up time of any concurrent requests. This adds up to wait / 16 additional time to the maximum duration.

So I think from our side we would want to enforce the blocking_timeout to be at least wait + (wait / 16) to avoid requests raising a connection timeout. Feels like we should support wait for completeness.

Testing wise I imagine the only thing possible to test would be that we correctly calculate the blocking_timeout, from my understanding when a blocking request returns it may or may not have changes making it tricky to assert something. If it's possible to start a blocking call then alter the object in question via another client instance we could then check our blocking client also returns?

@jonathanrcross
Copy link
Collaborator

jonathanrcross commented Feb 5, 2019

Hey @damoxc, so I was trying around the wait querystring parameter against the Nomad API. It doesn't look like it the input is enforced.

I can give it a number beyond its limit of 10m, but will still return at the 10 minute mark. I'm not sure if we need to enforce that detail other than just providing the wait parameter for the constructor. Also sorry for the delayed responses i'll try to be better about response time.

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.

3 participants