From 6305dc56733b61faaf37aec05882ed19ade1070e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Kou=C5=99il?= Date: Tue, 15 Mar 2005 08:29:27 +0000 Subject: [PATCH] Applied ommited patch fixing issues in the scheduling part (LCG bug 4909) --- .../project/version.properties | 2 +- org.glite.security.proxyrenewal/src/commands.c | 89 +++++++++++++--------- org.glite.security.proxyrenewal/src/renew.c | 12 +-- org.glite.security.proxyrenewal/src/renewal_locl.h | 4 + 4 files changed, 62 insertions(+), 45 deletions(-) diff --git a/org.glite.security.proxyrenewal/project/version.properties b/org.glite.security.proxyrenewal/project/version.properties index 54d6b19..e27af18 100644 --- a/org.glite.security.proxyrenewal/project/version.properties +++ b/org.glite.security.proxyrenewal/project/version.properties @@ -1,4 +1,4 @@ -module.version = 1.0.2 +module.version = 1.0.3 module.age = 1 diff --git a/org.glite.security.proxyrenewal/src/commands.c b/org.glite.security.proxyrenewal/src/commands.c index fc6235e..77b1a60 100644 --- a/org.glite.security.proxyrenewal/src/commands.c +++ b/org.glite.security.proxyrenewal/src/commands.c @@ -9,7 +9,6 @@ #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; @@ -144,42 +143,58 @@ copy_file_content(FILE *in, FILE *out) 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 @@ -563,10 +578,12 @@ get_record_ext(FILE *fd, proxy_record *record, int *last_used_suffix) 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; } diff --git a/org.glite.security.proxyrenewal/src/renew.c b/org.glite.security.proxyrenewal/src/renew.c index 35df781..ee7dc1e 100644 --- a/org.glite.security.proxyrenewal/src/renew.c +++ b/org.glite.security.proxyrenewal/src/renew.c @@ -28,9 +28,6 @@ static void register_signal(int signal); -#define DGPR_RETRIEVE_DEFAULT_HOURS 10 -#define RENEWAL_CLOCK_SKEW 5 * 60 - static const char * get_ssl_err() { @@ -1017,15 +1014,14 @@ check_renewal(char *datafile, int force_renew, int *num_renewed) 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 : ""); diff --git a/org.glite.security.proxyrenewal/src/renewal_locl.h b/org.glite.security.proxyrenewal/src/renewal_locl.h index 6ebc8c4..0eb94e4 100644 --- a/org.glite.security.proxyrenewal/src/renewal_locl.h +++ b/org.glite.security.proxyrenewal/src/renewal_locl.h @@ -65,6 +65,10 @@ typedef enum { #define MAX_PROXIES 4 /* max. number of jobids sharing one proxy */ +#define RENEWAL_CLOCK_SKEW (5 * 60) + +#define DGPR_RETRIEVE_DEFAULT_HOURS 10 + typedef struct { char *version; edg_wlpr_Command command; -- 1.8.2.3