1503700: Updates to the job polling frequency #103
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After this update destination threads will poll for job status in the following
way.
The first job status check is made 15 seconds after submitting the job.
All subsequent job status checks that do not indicate the job is finished, cancelled or failed
result in a wait time of 30 seconds.
If during any job check an HTTP code 429 is returned including a 'Retry-After' header with a
value parsable as an integer, that value is used as the number of seconds to wait before the
next job check.
As soon as any job check returns success no more polling is done for that job.
This does not change the behavior of oneshot (still exits on 429 or other exception).
A fun way to test this is to use mitmproxy to fake 429s with different headers coming back.
deploy CP locally with test data
start mitmproxy (if you don't have it you should be able to install using pip
pip install mitmproxy
mitmproxy --insecure --port 12345
Configure mitmproxy's intercept filter:
a) press 'i'
b) enter the following (without quotes) as the filter expression:
~bs [jJ]ob ~m GET
run virt-who from the checkout:
./virt-who -d
watch mitmproxy as requests come in. It should highlight and intercept any job status calls.
Move down to the intercepted call using the arrow keys and press enter
Press tab to go to the response
Press 'e' and then 'o' to edit the response code, delete the value already there and replace with 429 and press enter
Press 'e' and then 'h' to edit the headers
Move down to the last header by using the arrow keys and press 'a' to add a new one
Add the header 'Retry-After', press tab, type your desired wait time and press enter
press 'q' a few times to get back to the main screen of mitmproxy, then press 'a' to allow the modified response to be delivered to virt-who
Profit!! (and by this I mean, watch for virt-who to wait to retry the polling for the number of seconds you specified as the Retry-After header in step 12)
(with any luck this will serve as a useful mini-tutorial for someone)