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

1503700: Updates to the job polling frequency #103

Merged
merged 1 commit into from Oct 19, 2017
Merged

Conversation

cnsnyder
Copy link
Member

@cnsnyder cnsnyder commented Oct 19, 2017

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.

  1. Here is a libvirt config I used for testing this a bit (put this in a .conf file in /etc/virt-who.d):
[LOCAL_LIBVIRT]
type=libvirt
server=qemu:///system
owner=admin
env=admin
rhsm_hostname=localhost
rhsm_port=8443
rhsm_username=admin
rhsm_password=admin
rhsm_prefix=/candlepin
rhsm_proxy_hostname=localhost
rhsm_proxy_port=12345
#filter_hosts=d5b15581-5440-11cb-930e-b5dfde6103bc
hypervisor_id=hostname
  1. deploy CP locally with test data

  2. start mitmproxy (if you don't have it you should be able to install using pip pip install mitmproxy
    mitmproxy --insecure --port 12345

  3. Configure mitmproxy's intercept filter:
    a) press 'i'
    b) enter the following (without quotes) as the filter expression: ~bs [jJ]ob ~m GET

  4. run virt-who from the checkout: ./virt-who -d

  5. watch mitmproxy as requests come in. It should highlight and intercept any job status calls.

  6. Move down to the intercepted call using the arrow keys and press enter

  7. Press tab to go to the response

  8. Press 'e' and then 'o' to edit the response code, delete the value already there and replace with 429 and press enter

  9. Press 'e' and then 'h' to edit the headers

  10. Move down to the last header by using the arrow keys and press 'a' to add a new one

  11. Add the header 'Retry-After', press tab, type your desired wait time and press enter

  12. 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

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

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).
@cnsnyder
Copy link
Member Author

@wottop
Copy link
Member

wottop commented Oct 19, 2017

ack

@wottop wottop merged commit 1dc5196 into master Oct 19, 2017
@wottop wottop deleted the csnyder/1503700 branch October 19, 2017 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants