Skip to content

Commit

Permalink
Runentry Pool Override Precedence fixed
Browse files Browse the repository at this point in the history
A Pool override in a run entry has precedence over
Pool Level overrides in the job run.

If a Pool Level override is given, the Pool Level overrides
are used.

Fixes #169: Pool Overrides are overriden by "Full Backup Pool" Directive

Signed-off-by: Marco van Wieringen <marco.van.wieringen@bareos.com>
  • Loading branch information
pstorz authored and Marco van Wieringen committed Feb 17, 2015
1 parent 7740144 commit ff0e931
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 68 deletions.
84 changes: 49 additions & 35 deletions src/dird/job.c
Expand Up @@ -1027,6 +1027,7 @@ bool get_level_since_time(JCR *jcr)

void apply_pool_overrides(JCR *jcr, bool force)
{
Dmsg0(100, "entering apply_pool_overrides()\n");
bool pool_override = false;

/*
Expand All @@ -1037,47 +1038,60 @@ void apply_pool_overrides(JCR *jcr, bool force)
return;
}

if (jcr->res.run_pool_override) {
pm_strcpy(jcr->res.pool_source, _("Run pool override"));
}

/*
* Apply any level related Pool selections
* If only a pool override and no level overrides are given in run entry choose this pool
*/
switch (jcr->getJobLevel()) {
case L_FULL:
if (jcr->res.full_pool) {
jcr->res.pool = jcr->res.full_pool;
pool_override = true;
if (jcr->res.run_full_pool_override) {
pm_strcpy(jcr->res.pool_source, _("Run FullPool override"));
} else {
pm_strcpy(jcr->res.pool_source, _("Job FullPool override"));
if (jcr->res.run_pool_override &&
!jcr->res.run_full_pool_override &&
!jcr->res.run_inc_pool_override &&
!jcr->res.run_diff_pool_override) {
pm_strcpy(jcr->res.pool_source, _("Run Pool override"));
Dmsg2(100, "Pool set to '%s' because of %s", jcr->res.pool->name(), _("Run Pool override\n"));
} else {
/*
* Apply any level related Pool selections
*/
switch (jcr->getJobLevel()) {
case L_FULL:
if (jcr->res.full_pool) {
jcr->res.pool = jcr->res.full_pool;
pool_override = true;
if (jcr->res.run_full_pool_override) {
pm_strcpy(jcr->res.pool_source, _("Run FullPool override"));
Dmsg2(100, "Pool set to '%s' because of %s", jcr->res.full_pool->name(), _("Run FullPool override\n"));
} else {
pm_strcpy(jcr->res.pool_source, _("Job FullPool override"));
Dmsg2(100, "Pool set to '%s' because of %s", jcr->res.full_pool->name(), _("Job FullPool override\n"));
}
}
}
break;
case L_INCREMENTAL:
if (jcr->res.inc_pool) {
jcr->res.pool = jcr->res.inc_pool;
pool_override = true;
if (jcr->res.run_inc_pool_override) {
pm_strcpy(jcr->res.pool_source, _("Run IncPool override"));
} else {
pm_strcpy(jcr->res.pool_source, _("Job IncPool override"));
break;
case L_INCREMENTAL:
if (jcr->res.inc_pool) {
jcr->res.pool = jcr->res.inc_pool;
pool_override = true;
if (jcr->res.run_inc_pool_override) {
pm_strcpy(jcr->res.pool_source, _("Run IncPool override"));
Dmsg2(100, "Pool set to '%s' because of %s", jcr->res.full_pool->name(), _("Run IncPool override\n"));
} else {
pm_strcpy(jcr->res.pool_source, _("Job IncPool override"));
Dmsg2(100, "Pool set to '%s' because of %s", jcr->res.full_pool->name(), _("Job IncPool override\n"));
}
}
}
break;
case L_DIFFERENTIAL:
if (jcr->res.diff_pool) {
jcr->res.pool = jcr->res.diff_pool;
pool_override = true;
if (jcr->res.run_diff_pool_override) {
pm_strcpy(jcr->res.pool_source, _("Run DiffPool override"));
} else {
pm_strcpy(jcr->res.pool_source, _("Job DiffPool override"));
break;
case L_DIFFERENTIAL:
if (jcr->res.diff_pool) {
jcr->res.pool = jcr->res.diff_pool;
pool_override = true;
if (jcr->res.run_diff_pool_override) {
pm_strcpy(jcr->res.pool_source, _("Run DiffPool override"));
Dmsg2(100, "Pool set to '%s' because of %s", jcr->res.full_pool->name(), _("Run DiffPool override\n"));
} else {
pm_strcpy(jcr->res.pool_source, _("Job DiffPool override"));
Dmsg2(100, "Pool set to '%s' because of %s", jcr->res.full_pool->name(), _("Job DiffPool override\n"));
}
}
break;
}
break;
}

/*
Expand Down
96 changes: 63 additions & 33 deletions src/dird/ua_run.c
Expand Up @@ -152,6 +152,7 @@ int run_cmd(UAContext *ua, const char *cmd)
RUN_CTX rc;
int status, length;
bool valid_response;
bool do_pool_overrides = true;

if (!open_client_db(ua)) {
return 1;
Expand Down Expand Up @@ -207,15 +208,29 @@ int run_cmd(UAContext *ua, const char *cmd)

/*
* When doing interactive runs perform the pool level overrides
* early this way the user doesn't get nasty surprisses when
* a level override changes the pool the data will be saved to
* later.
* early this way the user doesn't get nasty surprisses when
* a level override changes the pool the data will be saved to
* later. We only want to do these overrides once so we use
* a tracking boolean do_pool_overrides to see if we still
* need to do this (e.g. we pass by here multiple times when
* the user interactivly changes options.
*/
apply_pool_overrides(jcr);
if (do_pool_overrides) {
switch (jcr->getJobType()) {
case JT_BACKUP:
if (!jcr->is_JobLevel(L_VIRTUAL_FULL)) {
apply_pool_overrides(jcr);
}
break;
default:
break;
}
do_pool_overrides = false;
}

/*
* Prompt User to see if all run job parameters are correct, and
* allow him to modify them.
* allow him to modify them.
*/
if (!display_job_parameters(ua, jcr, rc)) {
goto bail_out;
Expand Down Expand Up @@ -281,7 +296,7 @@ int run_cmd(UAContext *ua, const char *cmd)

/*
* For interactive runs we set IgnoreLevelPoolOverrides as we already
* performed the actual overrrides.
* performed the actual overrrides.
*/
jcr->IgnoreLevelPoolOverides = true;

Expand Down Expand Up @@ -372,7 +387,15 @@ int modify_job_parameters(UAContext *ua, JCR *jcr, RUN_CTX &rc)
case 0:
/* Level */
select_job_level(ua, jcr);
apply_pool_overrides(jcr);
switch (jcr->getJobType()) {
case JT_BACKUP:
if (!jcr->is_JobLevel(L_VIRTUAL_FULL)) {
apply_pool_overrides(jcr);
}
break;
default:
break;
}
goto try_again;
case 1:
/* Storage */
Expand Down Expand Up @@ -1026,28 +1049,32 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, RUN_CTX &rc)
case JT_BACKUP:
case JT_VERIFY:
if (jcr->getJobType() == JT_BACKUP) {
bool is_virtual = jcr->is_JobLevel(L_VIRTUAL_FULL);

if (ua->api) {
ua->signal(BNET_RUN_CMD);
ua->send_msg("Type: Backup\n"
"Title: Run Backup Job\n"
"JobName: %s\n"
"Level: %s\n"
"Client: %s\n"
"Format: %s\n"
"FileSet: %s\n"
"Pool: %s\n"
"NextPool: %s\n"
"Storage: %s\n"
"When: %s\n"
"Priority: %d\n"
"%s%s%s",
"Title: Run Backup Job\n"
"JobName: %s\n"
"Level: %s\n"
"Client: %s\n"
"Format: %s\n"
"FileSet: %s\n"
"Pool: %s\n"
"%s%s%s"
"Storage: %s\n"
"When: %s\n"
"Priority: %d\n"
"%s%s%s",
job->name(),
level_to_str(jcr->getJobLevel()),
jcr->res.client->name(),
jcr->backup_format,
jcr->res.fileset->name(),
NPRT(jcr->res.pool->name()),
jcr->res.next_pool ? jcr->res.next_pool->name() : _("*None*"),
is_virtual ? "NextPool: " : "",
is_virtual ? (jcr->res.next_pool ? jcr->res.next_pool->name() : _("*None*")) : "",
is_virtual ? "\n" : "",
jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"),
bstrutime(dt, sizeof(dt), jcr->sched_time),
jcr->JobPriority,
Expand All @@ -1056,25 +1083,28 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, RUN_CTX &rc)
jcr->plugin_options ? "\n" : "");
} else {
ua->send_msg(_("Run Backup job\n"
"JobName: %s\n"
"Level: %s\n"
"Client: %s\n"
"Format: %s\n"
"FileSet: %s\n"
"Pool: %s (From %s)\n"
"NextPool: %s (From %s)\n"
"Storage: %s (From %s)\n"
"When: %s\n"
"Priority: %d\n"
"%s%s%s"),
"JobName: %s\n"
"Level: %s\n"
"Client: %s\n"
"Format: %s\n"
"FileSet: %s\n"
"Pool: %s (From %s)\n"
"%s%s%s%s%s"
"Storage: %s (From %s)\n"
"When: %s\n"
"Priority: %d\n"
"%s%s%s"),
job->name(),
level_to_str(jcr->getJobLevel()),
jcr->res.client->name(),
jcr->backup_format,
jcr->res.fileset->name(),
NPRT(jcr->res.pool->name()), jcr->res.pool_source,
jcr->res.next_pool ? jcr->res.next_pool->name() : _("*None*"),
jcr->res.npool_source,
is_virtual ? "NextPool: " : "",
is_virtual ? (jcr->res.next_pool ? jcr->res.next_pool->name() : _("*None*")) : "",
is_virtual ? " (From " : "",
is_virtual ? jcr->res.npool_source : "",
is_virtual ? ")\n" : "",
jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"),
jcr->res.wstore_source,
bstrutime(dt, sizeof(dt), jcr->sched_time),
Expand Down

0 comments on commit ff0e931

Please sign in to comment.