Tuning error messages in client and server for background purge (SB #77974).
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Mon, 6 Jun 2011 15:31:03 +0000 (15:31 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Mon, 6 Jun 2011 15:31:03 +0000 (15:31 +0000)
org.glite.lb.client/src/connection.c
org.glite.lb.common/interface/context.h
org.glite.lb.common/src/context.c
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/lb_proto.c
org.glite.lb.utils/src/purge.c

index ea73bb6..8acefbf 100644 (file)
@@ -567,7 +567,10 @@ int http_check_status(
                        break;
                case HTTP_UNSUPPORTED:
                        edg_wll_SetError(ctx, ENOTSUP, "Protocol versions incompatible");
-                       break;                                                          
+                       break;
+               case HTTP_ACCEPTED:
+                       edg_wll_SetError(ctx,EDG_WLL_ERROR_ACCEPTED_OK,response+len);
+                       break;
                case HTTP_INTERNAL:
                        /* fall through */
                default: 
index ab0b1b2..ad5953d 100644 (file)
@@ -214,6 +214,7 @@ typedef enum _edg_wll_ErrorCode {
        EDG_WLL_ERROR_COMPARE_EVENTS, /**< Two compared events differ. */
        EDG_WLL_ERROR_DB_TRANS_DEADLOCK,        /**< Deadlock detected during DB operation. */
        EDG_WLL_ERROR_DB_LOST_CONNECTION,       /**< Lost connection to DB */
+       EDG_WLL_ERROR_ACCEPTED_OK,      /**< Deferred or background operation accepted. */
 } edg_wll_ErrorCode;
 
 /**
index fb638b8..55b11d2 100644 (file)
@@ -207,6 +207,8 @@ static const char* const errTexts[] = {
        "Interlogger has events pending",
        "Compared events differ",
        "DB deadlock detected",
+       "DB connection lost",
+       "Background operation accepted",
 };
 
 const char *edg_wll_GetErrorText(int code) {
index 0fcb9c1..90d6b53 100644 (file)
@@ -1489,7 +1489,16 @@ static int handle_server_error(edg_wll_Context ctx)
                 *      no action for non-fatal errors
                 */
                break;
-               
+
+       case EDG_WLL_ERROR_ACCEPTED_OK:
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+                       "[%d] %s (%s)", getpid(), errt, errd);
+               /*
+                *      all OK, but slave needs to be restarted
+                */
+               ret = -EINPROGRESS;
+               break;
+
        case EDG_WLL_ERROR_DB_INIT:
        case EDG_WLL_ERROR_DB_CALL:
        case EDG_WLL_ERROR_SERVER_RESPONSE:
index 73f1b2a..5bc12cc 100644 (file)
@@ -974,7 +974,7 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
                                        default: /* client request handler */
                                                ret = HTTP_ACCEPTED;
                                                /* to end this parent */
-                                               edg_wll_SetError(ctx, EDG_WLL_ERROR_SERVER_RESPONSE, edg_wll_HTTPErrorMessage(ret));
+                                               edg_wll_SetError(ctx, EDG_WLL_ERROR_ACCEPTED_OK, edg_wll_HTTPErrorMessage(ret));
                                                goto err;
                                        }
                                }
@@ -994,7 +994,7 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
                                        if (edg_wll_PurgeResultToXML(ctx, &result, &message))
                                                ret = HTTP_INTERNAL;
                                        else
-                                               printf("%s", message);
+                                               glite_common_log_msg(LOG_CATEGORY_CONTROL, LOG_PRIORITY_DEBUG, message);
                                }                               
 
                                /* result is now packed in message, free it */  
@@ -1009,9 +1009,19 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
 
                                /* forked cleaner sends no results */
                                if ((request.flags & EDG_WLL_PURGE_BACKGROUND)) {
-                                       *response = NULL;
+                                       char *et, *ed;
+
                                        free(message);
                                        message = NULL;
+                                       if (ret != HTTP_OK && ret != HTTP_ACCEPTED) {
+                                               edg_wll_Error(ctx, &et, &ed);
+                                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "Background purge failed, %s (%s)",et, ed);
+                                               free(et);
+                                               free(ed);
+                                       } else {
+                                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Background purge done, %d jobs purged.", i - 1:);
+                                       }
+                                       *response = NULL;
                                        if (requestPTR) free(requestPTR);
                                        exit(0);
                                }
index 4c7ac92..f018c40 100644 (file)
@@ -108,7 +108,7 @@ int main(int argc,char *argv[])
 {
        edg_wll_PurgeRequest *request;
        edg_wll_PurgeResult *result;
-       int     i, timeout, background;
+       int     i, timeout, background, err = 1;
        char *server = NULL;
 
        char *me;
@@ -285,15 +285,19 @@ int main(int argc,char *argv[])
 
        /* that is the Purge */
        dprintf(("Running the edg_wll_Purge...\n"));
-       if (edg_wll_Purge(ctx, request, result) != 0) {
-               fprintf(stderr,"Error running the edg_wll_Purge().\n");
+       if ((err = edg_wll_Purge(ctx, request, result)) != 0) {
+               if (err == EDG_WLL_ERROR_ACCEPTED_OK) err = 0;
+               else fprintf(stderr,"Error running the edg_wll_Purge().\n");
                printerr(ctx);
+
                switch ( edg_wll_Error(ctx, NULL, NULL) )
                {
                case ENOENT:
                case EPERM:
                case EINVAL:
                        break;
+               case EDG_WLL_ERROR_ACCEPTED_OK:
+                       /* fall-through */
                default:
                        goto main_end;
                }
@@ -326,7 +330,7 @@ main_end:
        }
        if (result) free(result);
        edg_wll_FreeContext(ctx);
-       return 0;
+       return err != 0;
 }