Export of UI host and VOMS attributes to RGMA
authorZdeněk Salvet <salvet@ics.muni.cz>
Wed, 16 Apr 2008 10:02:53 +0000 (10:02 +0000)
committerZdeněk Salvet <salvet@ics.muni.cz>
Wed, 16 Apr 2008 10:02:53 +0000 (10:02 +0000)
and necessary changes to related internals.j
Fixes #21575 and #21578.

org.glite.lb.server/src/bkindex.c
org.glite.lb.server/src/jobstat.c
org.glite.lb.server/src/jobstat.h
org.glite.lb.server/src/jobstat_supp.c
org.glite.lb.server/src/process_event.c
org.glite.lb.server/src/write2rgma.c

index 6a2da89..c7c9974 100644 (file)
@@ -343,7 +343,7 @@ edg_wll_ErrorCode edg_wll_RefreshIColumns(edg_wll_Context ctx, void *job_index_c
                        stat = NULL;
                        if (!edg_wlc_JobIdParse(res[4], &jobid)) {
                                if ((stat = malloc(sizeof(intJobStat))) != NULL) {
-                                       if (edg_wll_intJobStatus(ctx, jobid, 0, stat, 1)) {
+                                       if (edg_wll_intJobStatus(ctx, jobid, 0, stat, 1, 0)) {
                                                free(stat);
                                                stat = NULL;
                                        }
index a1deafd..52b2585 100644 (file)
@@ -141,7 +141,7 @@ int edg_wll_JobStatus(
 
        } else {
                lockErr = edg_wll_LockJob(ctx,job);
-               intErr = edg_wll_intJobStatus(ctx, job, flags,&jobstat, js_enable_store && !lockErr);
+               intErr = edg_wll_intJobStatus(ctx, job, flags,&jobstat, js_enable_store && !lockErr, 0);
                if (intErr) edg_wll_Error(ctx, NULL, &errdesc);
                if (!lockErr) {
                        edg_wll_UnlockJob(ctx,job);
@@ -320,7 +320,8 @@ int edg_wll_intJobStatus(
        const edg_wlc_JobId     job,
        int                     flags,
        intJobStat      *intstat,
-       int             update_db)
+       int             update_db,
+       int             add_fqans)
 {
 
 /* Local variables */
@@ -410,6 +411,14 @@ int edg_wll_intJobStatus(
                if (!intErr) {
                        if (update_db) {
                                int tsq = num_events - 1;
+                               if (add_fqans && tsq == 0 && ctx->fqans != NULL) {
+                                       for (i=0; ctx->fqans[i]; i++);
+                                       intstat->user_fqans = malloc(sizeof(*ctx->fqans)*(i+1));
+                                       for (i=0; ctx->fqans[i]; i++) {
+                                               intstat->user_fqans[i] = strdup(ctx->fqans[i]);
+                                       }
+                                       intstat->user_fqans[i] = NULL;
+                               }
                                edg_wll_StoreIntState(ctx, intstat, tsq);
                                /* recheck
                                 * intJobStat *reread;
@@ -630,7 +639,7 @@ edg_wll_ErrorCode edg_wll_StoreIntStateEmbryonic(edg_wll_Context ctx,
 
 /* TODO
                edg_wll_UpdateStatistics(ctx, NULL, e, &jobstat.pub);
-               if (ctx->rgma_export) write2rgma_status(&jobstat.pub);
+               if (ctx->rgma_export) write2rgma_status(&jobstat);
 */
 
 #ifdef LB_BUF
@@ -931,7 +940,7 @@ edg_wll_ErrorCode edg_wll_StepIntStateParent(edg_wll_Context ctx,
 
        edg_wll_CpyStatus(&ijsp->pub,&oldstat);
 
-       if (ctx->rgma_export) oldstat_rgmaline = write2rgma_statline(&ijsp->pub);
+       if (ctx->rgma_export) oldstat_rgmaline = write2rgma_statline(ijsp);
 
        res = processEvent(ijsp, e, seq, be_strict, &errstring);
        if (res == RET_FATAL || res == RET_INTERNAL) { /* !strict */
@@ -943,7 +952,7 @@ edg_wll_ErrorCode edg_wll_StepIntStateParent(edg_wll_Context ctx,
 
        edg_wll_UpdateStatistics(ctx,&oldstat,e,&ijsp->pub);
 
-       if (ctx->rgma_export) write2rgma_chgstatus(&ijsp->pub, oldstat_rgmaline);
+       if (ctx->rgma_export) write2rgma_chgstatus(ijsp, oldstat_rgmaline);
 
        if (stat_out) {
                edg_wll_CpyStatus(&ijsp->pub, stat_out);
@@ -983,7 +992,7 @@ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx,
        if (!edg_wll_LoadIntState(ctx, job, seq - 1, &ijsp)) {
                edg_wll_CpyStatus(&ijsp->pub,&oldstat);
 
-               if (ctx->rgma_export) oldstat_rgmaline = write2rgma_statline(&ijsp->pub);
+               if (ctx->rgma_export) oldstat_rgmaline = write2rgma_statline(ijsp);
 
                res = processEvent(ijsp, e, seq, be_strict, &errstring);
                if (res == RET_FATAL || res == RET_INTERNAL) { /* !strict */
@@ -1002,7 +1011,7 @@ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx,
                                return edg_wll_SetError(ctx, EINVAL, "update_parent_status()");
                }
 
-               if (ctx->rgma_export) write2rgma_chgstatus(&ijsp->pub, oldstat_rgmaline);
+               if (ctx->rgma_export) write2rgma_chgstatus(ijsp, oldstat_rgmaline);
 
                if (stat_out) {
                        memcpy(stat_out,&ijsp->pub,sizeof *stat_out);
@@ -1012,7 +1021,7 @@ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx,
                free(ijsp);
                edg_wll_FreeStatus(&oldstat);
        }
-       else if (!edg_wll_intJobStatus(ctx, job, flags,&jobstat, js_enable_store)) 
+       else if (!edg_wll_intJobStatus(ctx, job, flags,&jobstat, js_enable_store, 1)) 
        {
                /* FIXME: we miss state change in the case of seq != 0 
                 * Does anybody care? */
@@ -1025,7 +1034,7 @@ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx,
                if (edg_wll_UnlockJob(ctx,job)) goto err;
                edg_wll_UpdateStatistics(ctx,NULL,e,&jobstat.pub);
 
-               if (ctx->rgma_export) write2rgma_status(&jobstat.pub);
+               if (ctx->rgma_export) write2rgma_status(&jobstat);
 
                if (stat_out) {
                        memcpy(stat_out,&jobstat.pub,sizeof *stat_out);
index 99023c0..9cdd5a6 100644 (file)
@@ -11,7 +11,7 @@
  * (includes edg_wll_JobStat API structure)
  */
 
-#define INTSTAT_VERSION "release-3.3.4"
+#define INTSTAT_VERSION "release-3.3.4+rgma_ui"
 
 
 // Internal error codes 
@@ -55,6 +55,7 @@ typedef struct _intJobStat {
 
                struct timeval  last_pbs_event_timestamp;
                int             pbs_reruning;           // true if rerun event arrived
+               char*           *user_fqans;
 
                /*!! if adding new field, modify also destroy_intJobStat_extension() */
        } intJobStat;
@@ -98,7 +99,7 @@ void destroy_intJobStat_extension(intJobStat *p);
 
 edg_wll_ErrorCode edg_wll_IColumnsSQLPart(edg_wll_Context, void *, intJobStat *, int , char **, char **);
 edg_wll_ErrorCode edg_wll_RefreshIColumns(edg_wll_Context, void *);
-int edg_wll_intJobStatus( edg_wll_Context, const edg_wlc_JobId, int, intJobStat *, int);
+int edg_wll_intJobStatus( edg_wll_Context, const edg_wlc_JobId, int, intJobStat *, int, int);
 edg_wll_ErrorCode edg_wll_StoreIntState(edg_wll_Context, intJobStat *, int);
 edg_wll_ErrorCode edg_wll_StoreIntStateEmbryonic(edg_wll_Context, edg_wlc_JobId, char *icnames, char *values, edg_wll_bufInsert *bi);
 edg_wll_ErrorCode edg_wll_LoadIntState(edg_wll_Context , edg_wlc_JobId , int, intJobStat **);
@@ -110,9 +111,9 @@ edg_wll_ErrorCode edg_wll_StepIntStateParent(edg_wll_Context,edg_wlc_JobId,edg_w
 intJobStat* dec_intJobStat(char *, char **);
 char *enc_intJobStat(char *, intJobStat* );
 
-void write2rgma_status(edg_wll_JobStat *);
-void write2rgma_chgstatus(edg_wll_JobStat *, char *);
-char* write2rgma_statline(edg_wll_JobStat *);
+void write2rgma_status(intJobStat *);
+void write2rgma_chgstatus(intJobStat *, char *);
+char* write2rgma_statline(intJobStat *);
 
 int before_deep_resubmission(const char *, const char *);
 int same_branch(const char *, const char *);
index f5cb84a..d778870 100644 (file)
@@ -502,6 +502,8 @@ static char *enc_JobStat(char *old, edg_wll_JobStat* stat)
        if (ret) ret = enc_strlist(ret, stat->possible_ce_nodes);
        if (ret) ret = enc_int(ret, stat->suspended);
        if (ret) ret = enc_string(ret, stat->suspend_reason);
+       if (ret) ret = enc_string(ret, stat->failure_reasons);
+       if (ret) ret = enc_string(ret, stat->ui_host);
        if (ret) ret = enc_int_array(ret, stat->children_hist, EDG_WLL_NUMBER_OF_STATCODES);
        if (ret) ret = enc_string(ret, stat->pbs_state);
        if (ret) ret = enc_string(ret, stat->pbs_queue);
@@ -576,6 +578,8 @@ static edg_wll_JobStat* dec_JobStat(char *in, char **rest)
         if (tmp_in != NULL) stat->possible_ce_nodes = dec_strlist(tmp_in, &tmp_in);
         if (tmp_in != NULL) stat->suspended = dec_int(tmp_in, &tmp_in);
         if (tmp_in != NULL) stat->suspend_reason = dec_string(tmp_in, &tmp_in);
+        if (tmp_in != NULL) stat->failure_reasons = dec_string(tmp_in, &tmp_in);
+        if (tmp_in != NULL) stat->ui_host = dec_string(tmp_in, &tmp_in);
         if (tmp_in != NULL) {
                            stat->children_hist = (int*)calloc(EDG_WLL_NUMBER_OF_STATCODES+1, sizeof(int));
                            dec_int_array(tmp_in, &tmp_in, stat->children_hist);
@@ -623,6 +627,7 @@ char *enc_intJobStat(char *old, intJobStat* stat)
        if (ret) ret = enc_branch_states(ret, stat->branch_states);
        if (ret) ret = enc_timeval(ret, stat->last_pbs_event_timestamp);
        if (ret) ret = enc_int(ret, stat->pbs_reruning);
+       if (ret) ret = enc_strlist(ret, stat->user_fqans);
        return ret;
 }
 
@@ -665,6 +670,9 @@ intJobStat* dec_intJobStat(char *in, char **rest)
                if (tmp_in != NULL) {
                        stat->pbs_reruning = dec_int(tmp_in, &tmp_in);
                }
+               if (tmp_in != NULL) {
+                       stat->user_fqans = dec_strlist(tmp_in, &tmp_in);
+               }
        } else if (tmp_in != NULL) {
                edg_wll_FreeStatus(pubstat);
                free(pubstat);
index 76c0219..31aad89 100644 (file)
@@ -413,6 +413,7 @@ static int processEvent_glite(intJobStat *js, edg_wll_Event *e, int ev_seq, int
                        if (USABLE_DATA(res, strict)) {
                                switch (e->accepted.source) {
                                        case EDG_WLL_SOURCE_NETWORK_SERVER:
+                                               rep(js->pub.ui_host, e->accepted.from_host);
                                                break; /* no WM id */
                                        case EDG_WLL_SOURCE_LOG_MONITOR:
                                                rep(js->pub.condorId, e->accepted.local_jobid); break;
@@ -973,12 +974,20 @@ int add_stringlist(char ***lptr, const char *new_item)
 
 void destroy_intJobStat_extension(intJobStat *p)
 {
+       int i;
+
        if (p->last_seqcode) free(p->last_seqcode);
        if (p->last_cancel_seqcode) free(p->last_cancel_seqcode);
        if (p->branch_tag_seqcode) free(p->branch_tag_seqcode);
        if (p->last_branch_seqcode) free(p->last_branch_seqcode);
        if (p->deep_resubmit_seqcode) free(p->deep_resubmit_seqcode);
        free_branch_state(&p->branch_states);
+       if (p->user_fqans != NULL ) {
+                for (i=0; p->user_fqans[i]; i++)
+                        free(p->user_fqans[i]);
+                free(p->user_fqans);
+        }
+
        memset(p,0,sizeof(*p));
 }
 
index 7b4a60e..92c487c 100755 (executable)
@@ -149,16 +149,38 @@ static void write2rgma_line(char *line, int old_style)
        return;
 }
 
+static char* format_strlist(char **list, char sep)
+{
+       char *a, *b;
+       int i;
+       
+       if (list && list[0]) {
+               a = strdup(list[0]);
+               for (i = 1; list[i]; i++) {
+                       b = NULL;
+                       trio_asprintf(&b,"%s%c%s",a,sep,list[i]);
+                       free(a);
+                       if (!b) { return strdup(""); }
+                       a = b;
+               }
+               return a;
+       } else {
+               return strdup("");
+       }
+}
 
-char* write2rgma_statline(edg_wll_JobStat *stat)
+char* write2rgma_statline(intJobStat *intstat)
 {
+       edg_wll_JobStat *stat = &intstat->pub;
        char *stmt = NULL;
        char *string_jobid, *string_stat, *string_server;
        char *string_vo = NULL;
+       char *string_fqans = NULL;
 
        string_jobid = edg_wlc_JobIdUnparse(stat->jobId);
        string_stat = edg_wll_StatToString(stat->state);
        string_server = edg_wlc_JobIdGetServer(stat->jobId);
+       string_fqans = format_strlist(intstat->user_fqans, '|');
 
        if (stat->jdl != NULL) {
                struct cclassad *ad;
@@ -184,6 +206,8 @@ char* write2rgma_statline(edg_wll_JobStat *stat)
                "DESTINATION=%|Ss "
                "EXITCODE=%d "
                "DONECODE=%d "
+               "UIHOST=%s "
+               "VOMS=%s "
                "STATUSREASON=%|Ss"
                "\n",
                string_jobid,
@@ -198,6 +222,8 @@ char* write2rgma_statline(edg_wll_JobStat *stat)
                (stat->destination) ? (stat->destination) : "",
                stat->exit_code,
                stat->done_code,
+               (stat->ui_host) ? (stat->ui_host) : "",
+               string_fqans ? string_fqans : "",
                (stat->reason) ? (stat->reason) : ""
        );
                                
@@ -205,18 +231,19 @@ char* write2rgma_statline(edg_wll_JobStat *stat)
        free(string_jobid);
        free(string_stat);
        free(string_server);
+       free(string_fqans);
        
        return stmt;
 }
 
-void write2rgma_status(edg_wll_JobStat *stat)
+void write2rgma_status(intJobStat *intstat)
 {
        char *line;
        int lcgmon = 0;
        
        if (rgma_fd < -1) return;
 
-       line = write2rgma_statline(stat);
+       line = write2rgma_statline(intstat);
        if (line) {
                if (getenv("GLITE_WMS_LCGMON_FILE")) lcgmon = 1;
                write2rgma_line(line, !lcgmon);
@@ -227,14 +254,14 @@ void write2rgma_status(edg_wll_JobStat *stat)
 /* Export status record only if new status line is different from
    previous one. free() prev_statline parameter. */
 
-void write2rgma_chgstatus(edg_wll_JobStat *stat, char *prev_statline)
+void write2rgma_chgstatus(intJobStat *intstat, char *prev_statline)
 {
        char *line;
        int lcgmon = 0;
        
        if (rgma_fd < -1) return;
 
-       line = write2rgma_statline(stat);
+       line = write2rgma_statline(intstat);
        if (line && (!prev_statline || strcmp(line, prev_statline))) {
                if (getenv("GLITE_WMS_LCGMON_FILE")) lcgmon = 1;
                write2rgma_line(line, !lcgmon);