#define SEPARATORS ",\n"
#define RENEWAL_START_FRACTION 0.75 /* XXX */
-#define RENEWAL_CLOCK_SKEW (5 * 60)
#define RENEWAL_MIN_LIFETIME (15 * 60)
extern char *repository;
static time_t
get_delta(time_t current_time, time_t start_time, time_t end_time)
{
- time_t length, lifetime;
+ time_t remaining_life;
+ time_t life_to_lose;
+ time_t limit;
time_t delta;
- int condor_tested = 0;
- lifetime = end_time - start_time;
- delta = 0;
- while (1) {
- if (end_time - current_time <= RENEWAL_MIN_LIFETIME)
- /* if the proxy is too short, renew it as soon as possible */
- return RENEWAL_CLOCK_SKEW;
-
- /* renewal starts at 3/4 of lifetime */
- length = end_time - (start_time + delta);
- delta += length * RENEWAL_START_FRACTION;
-
- if (!condor_tested && delta > lifetime - condor_limit) {
- /* Condor requires the proxies to be renewed a specified time interval
- before the proxies have expired (see the
- GRIDMANAGER_MINIMUM_PROXY_TIME variable). We must ensure that
- renewal takes place before Condor does this check */
- if (current_time > end_time - condor_limit) {
- edg_wlpr_Log(LOG_ERR, "Proxy lifetime exceeded value of the Condor limit!");
- }
- else
- delta = lifetime - condor_limit - RENEWAL_CLOCK_SKEW;
- condor_tested = 1;
- }
+ if (RENEWAL_MIN_LIFETIME > condor_limit) {
+ limit = RENEWAL_MIN_LIFETIME;
+ } else {
+ limit = condor_limit;
+ }
- if (abs(current_time - (start_time + delta)) < RENEWAL_CLOCK_SKEW)
- continue;
-
- return (start_time + delta) - current_time;
- };
+ limit += RENEWAL_CLOCK_SKEW;
- /* not reachable */
- return 0;
+ if (current_time + limit >= end_time) {
+ /* if the proxy is too short, renew it as soon as possible */
+
+ if (current_time + condor_limit > end_time ) {
+ edg_wlpr_Log(LOG_ERR, "Remaining proxy lifetime fell below the value of the Condor limit!");
+ }
+
+ return 0;
+ }
+
+ remaining_life = end_time - current_time;
+
+ /* renewal should gain the jobs an extra lifetime of
+ RENEWAL_START_FRACTION (default 3/4) of the new proxy's
+ lifetime. If the time remaining on the current proxy is already
+ small then the jobs may gain an extra lifetime of more than that.
+
+ In any case, a renewal will be scheduled to happen before the
+ lifetime limit.
+
+ 'life_to_lose' is the lifetime that will be lost, ie the time that
+ will still remain on the current proxy when it is renewed
+ */
+
+ life_to_lose = (1.0-RENEWAL_START_FRACTION)*60*60*DGPR_RETRIEVE_DEFAULT_HOURS;
+
+ if (life_to_lose < limit) {
+ life_to_lose = limit;
+ }
+
+ delta = life_to_lose - limit;
+
+ while( remaining_life < (limit + delta) ) {
+ delta *= (1.0-RENEWAL_START_FRACTION);
+ }
+
+ life_to_lose = limit + delta;
+
+ return (remaining_life - life_to_lose);
}
int
continue;
if (tmp_record.jobids.len > 0 &&
- tmp_record.end_time - current_time < condor_limit) {
- /* skip expired proxy (and that ones that are going to expire soon),
+ current_time + condor_limit + RENEWAL_CLOCK_SKEW > tmp_record.end_time) {
+
+ /* skip expired proxy (or ones that are going to expire soon),
leaving it untouched (it will be removed after next run of the
- renewal process */
+ renewal process) */
+
continue;
}
register_signal(int signal);
-#define DGPR_RETRIEVE_DEFAULT_HOURS 10
-#define RENEWAL_CLOCK_SKEW 5 * 60
-
static const char *
get_ssl_err()
{
continue; /* XXX exit? */
if (record.jobids.len == 0) /* no jobid registered for this proxy */
continue;
- if (record.end_time - current_time < RENEWAL_CLOCK_SKEW ||
- abs(record.next_renewal - current_time) < RENEWAL_CLOCK_SKEW ||
- record.next_renewal < current_time ||
- record.end_time < current_time ||
+ if (current_time + RENEWAL_CLOCK_SKEW >= record.end_time ||
+ record.next_renewal <= current_time ||
force_renew) {
ret = EDG_WLPR_PROXY_EXPIRED;
- if (record.end_time >= current_time)
+ if ( record.end_time + RENEWAL_CLOCK_SKEW >= current_time) {
/* only try renewal if the proxy hasn't already expired */
ret = renew_proxy(&record, basename, &new_proxy);
+ }
/* if the proxy wasn't renewed have the daemon planned another renewal */
asprintf(&entry, "%d:%s", record.suffix, (ret == 0) ? new_proxy : "");