From: Kern Sibbald Date: Sun, 17 Dec 2006 12:42:56 +0000 (+0000) Subject: kes Add additional messages when Job canceled automatically for X-Git-Tag: Release-2.0.0~108 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f79170eb032dd55452316f844d212fa8305e1077;p=bacula%2Fbacula kes Add additional messages when Job canceled automatically for 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 --- diff --git a/bacula/po/.cvsignore b/bacula/po/.cvsignore index d00e20efbe..51181b263a 100644 --- a/bacula/po/.cvsignore +++ b/bacula/po/.cvsignore @@ -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 index 0000000000..9b7775a332 Binary files /dev/null and b/bacula/po/es.gmo differ diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 028c437dff..8c2153b0a4 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -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; } diff --git a/bacula/src/dird/ua_purge.c b/bacula/src/dird/ua_purge.c index 261485d665..b3bd849ee4 100644 --- a/bacula/src/dird/ua_purge.c +++ b/bacula/src/dird/ua_purge.c @@ -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 */ diff --git a/bacula/src/filed/authenticate.c b/bacula/src/filed/authenticate.c index 8122061e67..fa09accd87 100644 --- a/bacula/src/filed/authenticate.c +++ b/bacula/src/filed/authenticate.c @@ -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) {