Skip to content

Commit

Permalink
Merge branch 'tkt827-minexpires' into release-2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
ahelsing committed May 20, 2015
2 parents 6ed6cf0 + d4787c1 commit 6a01465
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ gcf 2.9:
at once on Windows. (#824)
* Define default initial sliver expirations for other Utah/PG AMs (Apt, Cloudlab, stitch). (#826)
* Allow defining new such AMs in the omni config `omni_defaults` -> `utah_am_urns` (CSV).
* When calculating `expires` time to request, don't exceed the slice expiration,
and don't request less than some # of hours - 6 for APIv2, 3 for v3+. (#827)

* Scripts
* Initial commit of `examples/renewSliceAndSlivers.py`. (#798)
Expand Down
14 changes: 13 additions & 1 deletion src/gcf/omnilib/stitch/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,9 +957,10 @@ def __init__(self, logger, opts):
self.slicecred = _load_cred(MyHandler(self.logger, opts), opts.slicecredfile)
sliceexp = get_cred_exp(self.logger, self.slicecred)
sliceExpFromNow = naiveUTC(sliceexp) - now
minDays = sliceExpFromNow.days
minDays = max(sliceExpFromNow.days, 1) # Start out going for 1 day from now at least
newExpires = naiveUTC(sliceexp)
self.logger.debug("Starting newExpires at slice expiration %s, so init minDays to %d", sliceexp, minDays)
#self.logger.debug("now=%s", now)

# Singleton for getting the default sliver expirations by AM type, that knows about values
# from the omni_config
Expand Down Expand Up @@ -1043,6 +1044,17 @@ def __init__(self, logger, opts):
# End loop over AMs on path
# End loop over paths

minHours = 6
if self.api_version > 2:
minHours = allocHours
if naiveUTC(newExpires) - naiveUTC(now) < datetime.timedelta(hours=minHours):
self.logger.debug("Calculated new expiration within %d hour(s): reset to %d hour(s) from now", minHours, minHours)
newExpires = naiveUTC(now) + datetime.timedelta(hours=minHours)

if naiveUTC(sliceexp) < naiveUTC(newExpires):
self.logger.debug("Calculated new expiration after slice expiration: reset to slice expiration")
newExpires = sliceexp

# In APIv3+, this should be a temporary hold. So only request the resources for a few hours.
if self.api_version > 2:
shortExpires = now + datetime.timedelta(hours=allocHours)
Expand Down

0 comments on commit 6a01465

Please sign in to comment.