]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Add additional messages when Job canceled automatically for
authorKern Sibbald <kern@sibbald.com>
Sun, 17 Dec 2006 12:42:56 +0000 (12:42 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 17 Dec 2006 12:42:56 +0000 (12:42 +0000)
     max run time or max start wait exceeded.  This fixes bug #621.
kes  Update maxruntime-test in regression script to properly test
     max run time -- from info given in bug #621.
kes  Simplify automatic cancel code.
kes  Add check for job_canceled() in FD when contacting SD so that if
     job is canceled from max runtime, it terminates faster.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3809 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/po/.cvsignore
bacula/po/es.gmo [new file with mode: 0644]
bacula/src/dird/job.c
bacula/src/dird/ua_purge.c
bacula/src/filed/authenticate.c

index d00e20efbee5e14af08fdcc19297cd90c94ecd88..51181b263a993f9ec9e5aa37f9719c6aad61996a 100644 (file)
@@ -3,6 +3,4 @@ Makefile.in
 Makefile
 stamp-po
 remove-potcdate.sed
-fr.mo
-it.mo
-de.mo
+*.mo
diff --git a/bacula/po/es.gmo b/bacula/po/es.gmo
new file mode 100644 (file)
index 0000000..9b7775a
Binary files /dev/null and b/bacula/po/es.gmo differ
index 028c437dff4f8e67a3bc804915fc198894816ea1..8c2153b0a4bbc5a2c82aa02583e8329cae6b7f36 100644 (file)
@@ -174,7 +174,6 @@ bool setup_job(JCR *jcr)
       goto bail_out;
    }
 
-
    /*
     * Now, do pre-run stuff, like setting job level (Inc/diff, ...)
     *  this allows us to setup a proper job start record for restarting
@@ -248,8 +247,8 @@ static void *job_thread(void *arg)
 
    if (jcr->job->MaxStartDelay != 0 && jcr->job->MaxStartDelay <
        (utime_t)(jcr->start_time - jcr->sched_time)) {
-      Jmsg(jcr, M_FATAL, 0, _("Job canceled because max start delay time exceeded.\n"));
       set_jcr_job_status(jcr, JS_Canceled);
+      Jmsg(jcr, M_FATAL, 0, _("Job canceled because max start delay time exceeded.\n"));
    }
 
    /* TODO : check if it is used somewhere */
@@ -352,6 +351,7 @@ static void *job_thread(void *arg)
 bool cancel_job(UAContext *ua, JCR *jcr)
 {
    BSOCK *sd, *fd;
+   char ed1[50];
 
    set_jcr_job_status(jcr, JS_Canceled);
 
@@ -363,8 +363,8 @@ bool cancel_job(UAContext *ua, JCR *jcr)
    case JS_WaitPriority:
    case JS_WaitMaxJobs:
    case JS_WaitStartTime:
-      bsendmsg(ua, _("JobId %d, Job %s marked to be canceled.\n"),
-              jcr->JobId, jcr->Job);
+      bsendmsg(ua, _("JobId %s, Job %s marked to be canceled.\n"),
+              edit_uint64(jcr->JobId, ed1), jcr->Job);
       jobq_remove(&job_queue, jcr); /* attempt to remove it from queue */
       return true;
 
@@ -445,32 +445,34 @@ static void job_monitor_watchdog(watchdog_t *self)
    foreach_jcr(jcr) {
       bool cancel;
 
-      if (jcr->JobId == 0) {
-         Dmsg2(800, "Skipping JCR %p (%s) with JobId 0\n",
-               jcr, jcr->Job);
+      if (jcr->JobId == 0 || job_canceled(jcr)) {
+         Dmsg2(800, "Skipping JCR=%p Job=%s\n", jcr, jcr->Job);
          continue;
       }
 
       /* check MaxWaitTime */
-      cancel = job_check_maxwaittime(control_jcr, jcr);
-
+      if (job_check_maxwaittime(control_jcr, jcr)) {
+         set_jcr_job_status(jcr, JS_Canceled);
+         Jmsg(jcr, M_FATAL, 0, _("Max wait time exceeded. Job canceled.\n"));
+         cancel = true;
       /* check MaxRunTime */
-      cancel |= job_check_maxruntime(control_jcr, jcr);
+      } else if (job_check_maxruntime(control_jcr, jcr)) {
+         set_jcr_job_status(jcr, JS_Canceled);
+         Jmsg(jcr, M_FATAL, 0, _("Max run time exceeded. Job canceled.\n"));
+         cancel = true;
+      }
 
       if (cancel) {
-         Dmsg3(800, "Cancelling JCR %p jobid %d (%s)\n",
-               jcr, jcr->JobId, jcr->Job);
-
+         Dmsg3(800, "Cancelling JCR %p jobid %d (%s)\n", jcr, jcr->JobId, jcr->Job);
          UAContext *ua = new_ua_context(jcr);
          ua->jcr = control_jcr;
          cancel_job(ua, jcr);
          free_ua_context(ua);
-
          Dmsg2(800, "Have cancelled JCR %p Job=%d\n", jcr, jcr->JobId);
       }
 
-      /* Keep reference counts correct */
    }
+   /* Keep reference counts correct */
    endeach_jcr(jcr);
 }
 
@@ -484,6 +486,9 @@ static bool job_check_maxwaittime(JCR *control_jcr, JCR *jcr)
    bool ok_to_cancel = false;
    JOB *job = jcr->job;
 
+   if (job_canceled(jcr)) {
+      return false;                /* already canceled */
+   }
    if (job->MaxWaitTime == 0 && job->FullMaxWaitTime == 0 &&
        job->IncMaxWaitTime == 0 && job->DiffMaxWaitTime == 0) {
       return false;
@@ -504,6 +509,11 @@ static bool job_check_maxwaittime(JCR *control_jcr, JCR *jcr)
    if (!ok_to_cancel) {
       return false;
    }
+
+/*
+ * I don't see the need for all this -- kes 17Dec06
+ */
+#ifdef xxx
    Dmsg3(800, "Job %d (%s): MaxWaitTime of %d seconds exceeded, "
          "checking status\n",
          jcr->JobId, jcr->Job, job->MaxWaitTime);
@@ -547,7 +557,7 @@ static bool job_check_maxwaittime(JCR *control_jcr, JCR *jcr)
    }
    Dmsg3(800, "MaxWaitTime result: %scancel JCR %p (%s)\n",
          cancel ? "" : "do not ", jcr, jcr->job);
-
+#endif
    return cancel;
 }
 
@@ -559,7 +569,7 @@ static bool job_check_maxruntime(JCR *control_jcr, JCR *jcr)
 {
    bool cancel = false;
 
-   if (jcr->job->MaxRunTime == 0) {
+   if (jcr->job->MaxRunTime == 0 || job_canceled(jcr)) {
       return false;
    }
    if ((watchdog_time - jcr->start_time) < jcr->job->MaxRunTime) {
@@ -568,6 +578,7 @@ static bool job_check_maxruntime(JCR *control_jcr, JCR *jcr)
       return false;
    }
 
+#ifdef xxx
    switch (jcr->JobStatus) {
    case JS_Created:
    case JS_Running:
@@ -596,7 +607,7 @@ static bool job_check_maxruntime(JCR *control_jcr, JCR *jcr)
 
    Dmsg3(200, "MaxRunTime result: %scancel JCR %p (%s)\n",
          cancel ? "" : "do not ", jcr, jcr->job);
-
+#endif
    return cancel;
 }
 
index 261485d66545498650731497c814c476180f3776..b3bd849ee4fb9a6efd98ec67d267ea8ceea48d6d 100644 (file)
@@ -419,7 +419,7 @@ void purge_job_from_catalog(UAContext *ua, JobId_t JobId)
    POOL_MEM query(PM_MESSAGE);
    char ed1[50];
 
-   /* Records associated with the job */
+   /* Delete (or purge) records associated with the job */
    purge_job_records_from_catalog(ua, JobId);
 
    /* Now remove the Job record itself */
index 8122061e6703fed1042c94084c24ba495d2b72f1..fa09accd8729ed0902f067a75505a5e0307a8b5b 100644 (file)
@@ -112,6 +112,10 @@ static bool authenticate(int rcode, BSOCK *bs, JCR* jcr)
    tid = start_bsock_timer(bs, AUTH_TIMEOUT);
    /* Challenge the director */
    auth_success = cram_md5_challenge(bs, director->password, tls_local_need, compatible);  
+   if (job_canceled(jcr)) {
+      auth_success = false;
+      goto auth_fatal;                   /* quick exit */
+   }
    if (auth_success) {
       auth_success = cram_md5_respond(bs, director->password, &tls_remote_need, &compatible);
       if (!auth_success) {
@@ -215,8 +219,17 @@ int authenticate_storagedaemon(JCR *jcr)
       }
    }
 
+   if (job_canceled(jcr)) {
+      auth_success = false;     /* force quick exit */
+      goto auth_fatal;
+   }
+
    /* Respond to SD challenge */
    auth_success = cram_md5_respond(sd, jcr->sd_auth_key, &tls_remote_need, &compatible);
+   if (job_canceled(jcr)) {
+      auth_success = false;     /* force quick exit */
+      goto auth_fatal;
+   }
    if (!auth_success) {
       Dmsg1(50, "cram_respond failed for %s\n", sd->who);
    } else {
@@ -227,9 +240,6 @@ int authenticate_storagedaemon(JCR *jcr)
       }
    }
 
-   /* Destroy session key */
-   memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key));
-
    if (!auth_success) {
       Jmsg(jcr, M_FATAL, 0, _("Authorization key rejected by Storage daemon.\n"
        "Please see http://www.bacula.org/rel-manual/faq.html#AuthorizationErrors for help.\n"));
@@ -261,6 +271,8 @@ int authenticate_storagedaemon(JCR *jcr)
    }
 
 auth_fatal:
+   /* Destroy session key */
+   memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key));
    stop_bsock_timer(tid);
    /* Single thread all failures to avoid DOS */
    if (!auth_success) {