mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 11:10:21 -07:00
spot instance request stay opened when module exit with timeout (#51535)
Fixes: #51534 * set valid_until equal to current time + spot_wait_timeout * add setting ValidUntil to value * add changelog fragment * fix shebang issue
This commit is contained in:
parent
890394aeed
commit
d40f0313e2
2 changed files with 12 additions and 0 deletions
|
@ -540,6 +540,7 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
import time
|
||||
import datetime
|
||||
import traceback
|
||||
from ast import literal_eval
|
||||
from distutils.version import LooseVersion
|
||||
|
@ -1191,6 +1192,15 @@ def create_instances(module, ec2, vpc, override_count=None):
|
|||
count=count_remaining,
|
||||
type=spot_type,
|
||||
))
|
||||
|
||||
# Set spot ValidUntil
|
||||
# ValidUntil -> (timestamp). The end date of the request, in
|
||||
# UTC format (for example, YYYY -MM -DD T*HH* :MM :SS Z).
|
||||
utc_valid_until = (
|
||||
datetime.datetime.utcnow()
|
||||
+ datetime.timedelta(seconds=spot_wait_timeout))
|
||||
params['valid_until'] = utc_valid_until.strftime('%Y-%m-%dT%H:%M:%S.000Z')
|
||||
|
||||
res = ec2.request_spot_instances(spot_price, **params)
|
||||
|
||||
# Now we have to do the intermediate waiting
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue