-
Notifications
You must be signed in to change notification settings - Fork 194
vs manager wait_for_ready exception handling #869
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
vs manager wait_for_ready exception handling #869
Conversation
Comments are of course welcome. |
@allmightyspiff This solution will solve our problem, but I think we still need to add attempt :) Consider this case, if customer use 15 sec delay, 3600 sec total wait time, then if hit exception, the retry will be triggered 8 times. on 15, 30, 60, 120, 240, 480, 960... If this is a man made error, e.g. given incorrect VSI ID or even customer side Network outage on their site, this code will still running... |
|
Thanks for the input. specifying attemptsFor both of those situations I would expect the user to want to ctrl-c out of the script before it hits attempts. Since the exception catcher logs exceptions, I don't think its too much to ask that users monitor the logs to see if their script is working correctly. randomizationThis is a good point, I think I'll add a random 0-9s delay each exception in addition to multiplying by 2 exponential backoff
capped retrywait_for_ready will only run at most the time specified by limit, no matter how many exceptions are thrown. |
I agree with all the comments.. On the random side, I keep thinking maybe you can tie it to the current delay functionality but what you have is simple, and I do like the K.I.S.S. principle. This is a good place to start. |
Real testingimport SoftLayer
import logging
client = SoftLayer.Client()
vs_manager = SoftLayer.VSManager(client)
LOGGER = logging.getLogger()
LOGGER.addHandler(logging.StreamHandler())
LOGGER.setLevel(20)
ready = vs_manager.wait_for_ready(38614529, 5000, 10)
print(ready) Testing exception$ python wait_for_ready_test.py
POST https://api.softlayer.com/xmlrpc/v3.1/SoftLayer_Virtual_Guest
Exception: SoftLayerAPIError(SoftLayer_Exception_ObjectNotFound): Unable to find object with id of '309835167'.
Auto retry in 4 seconds
POST https://api.softlayer.com/xmlrpc/v3.1/SoftLayer_Virtual_Guest
Exception: SoftLayerAPIError(SoftLayer_Exception_ObjectNotFound): Unable to find object with id of '309835167'.
Auto retry in 17 seconds
POST https://api.softlayer.com/xmlrpc/v3.1/SoftLayer_Virtual_Guest
Exception: SoftLayerAPIError(SoftLayer_Exception_ObjectNotFound): Unable to find object with id of '309835167'.
Auto retry in 41 seconds
POST https://api.softlayer.com/xmlrpc/v3.1/SoftLayer_Virtual_Guest
Exception: SoftLayerAPIError(SoftLayer_Exception_ObjectNotFound): Unable to find object with id of '309835167'.
Auto retry in 36.471503496170044 seconds
POST https://api.softlayer.com/xmlrpc/v3.1/SoftLayer_Virtual_Guest
Exception: SoftLayerAPIError(SoftLayer_Exception_ObjectNotFound): Unable to find object with id of '309835167'.
False
(py36) Real VM being provisioned
|
Looking good :) |
Will allow wait_for_ready to gracefully handle exceptions, and raise the delay for each exception. Raised the default delay from 1s to 10s
def wait_for_ready(self, instance_id, limit, delay=10, pending=False):
When an exception is encountered, delay will be multiplied by 2.
Will still return False if a ready state was not encountered before limit is reached.