From: František Dvořák Date: Fri, 28 Mar 2008 16:11:29 +0000 (+0000) Subject: Dig error code from soap faults. X-Git-Tag: merge_313_4~4 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=90c940d9d2ed15f763970a36b0897c9c6ff53618;p=jra1mw.git Dig error code from soap faults. Register job by importer only on ENOENT or not propagated application error from JP. Repeat "importing" message on second attempt. --- diff --git a/org.glite.jp.client/src/jpimporter.c b/org.glite.jp.client/src/jpimporter.c index d9709ee..e5a20fb 100644 --- a/org.glite.jp.client/src/jpimporter.c +++ b/org.glite.jp.client/src/jpimporter.c @@ -503,7 +503,7 @@ static int dump_importer(void) *fname = NULL, *bname; char fspec[PATH_MAX]; - int ret, retry_upload; + int ret, retry_upload, jperrno; int fhnd; msg_pattern_t tab[] = { {"jobid", NULL}, @@ -549,8 +549,6 @@ static int dump_importer(void) su_in.name = NULL; su_in.commitBefore = 1000 + time(NULL); su_in.contentType = "text/lb"; - dprintf("[%s] Importing LB dump file '%s'\n", name, tab[_file].val); - if ( !debug ) syslog(LOG_INFO, "Importing LB dump file '%s'\n", msg); #ifdef JP_PERF if ((sink & 1)) { /* statistics started by file, ended by count limit (from the appropriate result fikle) */ @@ -576,6 +574,8 @@ static int dump_importer(void) #endif retry_upload = 2; do { + dprintf("[%s] Importing LB dump file '%s'\n", name, tab[_file].val); + if ( !debug ) syslog(LOG_INFO, "Importing LB dump file '%s'\n", msg); refresh_connection(soap); ret = soap_call___jpsrv__StartUpload(soap, tab[_jpps].val?:jpps, "", &su_in, &su_out); if ( (ret = check_soap_fault(soap, ret)) ) { @@ -588,21 +588,28 @@ static int dump_importer(void) GLITE_SECURITY_GSOAP_LIST_CREATE(soap, &gja_in, attributes, struct _jpelem__GetJobAttributes, 1); GLITE_SECURITY_GSOAP_LIST_GET(gja_in.attributes, 0) = GLITE_JP_ATTR_REGTIME; ret = soap_call___jpsrv__GetJobAttributes(soap, jpps, "", &gja_in, &gja_out); - if (ret == 0) { + jperrno = glite_jp_clientGetErrno(soap, ret); + /* no error ==> some application fault from JP */ + if (jperrno == 0) { dprintf("[%s] Dump failed when job %s exists\n", name, su_in.job); ret = -1; break; } + /* other then "job not found" error ==> other problem, don't register */ + if (jperrno != ENOENT && jperrno != -2) { + ret = check_soap_fault(soap, ret); + break; + } GLITE_SECURITY_GSOAP_LIST_GET(gja_in.attributes, 0) = NULL; - /* register job */ - dprintf("[%s] Failsafe registration '%s'\n", name, rj_in.job); - if ( !debug ) syslog(LOG_INFO, "Failsafe registration '%s'\n",rj_in.job); + /* "job not found" error ==> register job */ refresh_connection(soap); rj_in.job = su_in.job; rj_in.owner = mycred->name; + dprintf("[%s] Failsafe registration\n", name); + dprintf("[%s] \tjobid: %s\n[%s] \towner: %s\n", name, rj_in.job, name, rj_in.owner); + if ( !debug ) syslog(LOG_INFO, "Failsafe registration '%s'\n",rj_in.job); ret = soap_call___jpsrv__RegisterJob(soap, tab[_jpps].val?:jpps, "", &rj_in, &rj_empty); if ( (ret = check_soap_fault(soap, ret)) ) break; - dprintf("[%s] \tjobid: %s\n[%s] \towner: %s\n", name, rj_in.job, name, rj_in.owner); retry_upload--; ret = 1; } diff --git a/org.glite.jp.ws-interface/src/ws_fault.c b/org.glite.jp.ws-interface/src/ws_fault.c index bac4d9f..4cb07d9 100644 --- a/org.glite.jp.ws-interface/src/ws_fault.c +++ b/org.glite.jp.ws-interface/src/ws_fault.c @@ -32,70 +32,114 @@ static int glite_jp_clientCheckFault(struct soap *soap, int err, const char *name, int toSyslog) UNUSED; -static struct jptype__genericFault* jp2s_error(struct soap *soap, const glite_jp_error_t *err) UNUSED; +static int glite_jp_clientGetErrno(struct soap *soap, int err) UNUSED; static void glite_jp_server_err2fault(const glite_jp_context_t ctx,struct soap *soap) UNUSED; +static struct jptype__genericFault* jp2s_error(struct soap *soap, const glite_jp_error_t *err); +static int clientGetFault(struct soap *soap, int err, const char **reason, struct jptype__genericFault **f, const char **fallback); + + +/* + * get client fault structs + * err - code got from soap call + * reason - error text + * f - extended fault structs or NULL + * fallback - xml fault description or NULL + * return values: + * 0 - OK + * 1 - got a extended fault info + * 2 - internal gsoap fault + */ +static int clientGetFault(struct soap *soap, int err, const char **reason, struct jptype__genericFault **f, const char **fallback) { + struct SOAP_ENV__Detail *detail; + + *f = NULL; + if (fallback) *fallback = NULL; + + switch(err) { + case SOAP_OK: + return 0; + + case SOAP_FAULT: + case SOAP_SVR_FAULT: + detail = GLITE_SECURITY_GSOAP_DETAIL(soap); + if (reason) *reason = GLITE_SECURITY_GSOAP_REASON(soap); + + if (!detail) return 1; + if (detail->__type != GFNUM && detail->__any) { + // compatibility with clients gSoaps < 2.7.9b + if (fallback) *fallback = detail->__any; + return 1; + } + // client is based on gSoap 2.7.9b + assert(detail->__type == GFNUM); +#if GSOAP_VERSIO >= 20709 + *f = (struct jptype__genericFault *)detail->fault; +#elif GSOAP_VERSION >= 20700 + *f = ((struct _genericFault *)detail->fault)->jpelem__genericFault; +#else + *f = ((struct _genericFault *)detail->value)->jpelem__genericFault; +#endif + return 1; + + default: + return 2; + } +} + + +static int glite_jp_clientGetErrno(struct soap *soap, int err) { + struct jptype__genericFault *f; + + switch(clientGetFault(soap, err, NULL, &f, NULL)) { + case 0: return 0; + case 1: return f ? f->code : -2; + default: return -1; + } +} + static int glite_jp_clientCheckFault(struct soap *soap, int err, const char *name, int toSyslog) { - struct SOAP_ENV__Detail *detail; struct jptype__genericFault *f; - const char *reason; + const char *reason, *xml; char indent[200] = " "; char *prefix; int retval; if (name) asprintf(&prefix, "[%s] ", name); else prefix = strdup(""); - retval = 0; - switch(err) { - case SOAP_OK: + switch(clientGetFault(soap, err, &reason, &f, &xml)) { + case 0: + retval = 0; dprintf("%sOK\n", prefix); break; - case SOAP_FAULT: - case SOAP_SVR_FAULT: + case 1: retval = -1; - detail = GLITE_SECURITY_GSOAP_DETAIL(soap); - reason = GLITE_SECURITY_GSOAP_REASON(soap); dprintf("%s%s\n", prefix, reason); if (toSyslog) syslog(LOG_ERR, "%s", reason); - - if (!detail) break; - if (detail->__type != GFNUM && detail->__any) { - // compatibility with clients gSoaps < 2.7.9b - dprintf("%s%s%s\n", prefix, indent, detail->__any); - if (toSyslog) syslog(LOG_ERR, "%s", detail->__any); - - f = NULL; - } else { - // client is based on gSoap 2.7.9b - assert(detail->__type == GFNUM); -#if GSOAP_VERSION >= 20709 - f = (struct jptype__genericFault *)detail->fault; -#elif GSOAP_VERSION >= 20700 - f = ((struct _genericFault *)detail->fault)->jpelem__genericFault; -#else - f = ((struct _genericFault *)detail->value)->jpelem__genericFault; -#endif + if (!f && xml) { + dprintf("%s%s%s\n", prefix, indent, xml); + if (toSyslog) syslog(LOG_ERR, "%s", xml); } - while (f) { dprintf("%s%s%s: %s (%s)\n", prefix, indent, f->source, f->text, f->description); if (toSyslog) syslog(LOG_ERR, "%s%s: %s (%s)", - reason, f->source, f->text, f->description); + prefix, f->source, f->text, f->description); f = f->reason; strcat(indent," "); } break; - default: + case 2: fprintf(stderr, "%ssoap err=%d, ", prefix, err); - soap_print_fault(soap,stderr); + soap_print_fault(soap, stderr); retval = -1; + break; } free(prefix);