mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
this is the CE side of an Enterprise-only feature.
a job trying to use this in CE will fail to validate.
to enable daily-scheduled execution entirely client-side,
a job may now contain:
task "name" {
schedule {
cron {
start = "0 12 * * * *" # may not include "," or "/"
end = "0 16" # partial cron, with only {minute} {hour}
timezone = "EST" # anything in your tzdb
}
}
...
and everything about the allocation will be placed as usual,
but if outside the specified schedule, the taskrunner will block
on the client, waiting on the schedule start, before proceeding
with the task driver execution, etc.
this includes a taksrunner hook, which watches for the end of
the schedule, at which point it will kill the task.
then, restarts-allowing, a new task will start and again block
waiting for start, and so on.
this also includes all the plumbing required to pipe API calls
through from command->api->agent->server->client, so that
tasks can be force-run, force-paused, or resume the schedule
on demand.
95 lines
2.1 KiB
JavaScript
95 lines
2.1 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Controller from '@ember/controller';
|
|
import { computed as overridable } from 'ember-overridable-computed';
|
|
import { task } from 'ember-concurrency';
|
|
import classic from 'ember-classic-decorator';
|
|
import messageForError from 'nomad-ui/utils/message-from-adapter-error';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
@classic
|
|
export default class IndexController extends Controller {
|
|
@service nomadActions;
|
|
@service notifications;
|
|
@overridable(() => {
|
|
// { title, description }
|
|
return null;
|
|
})
|
|
error;
|
|
|
|
onDismiss() {
|
|
this.set('error', null);
|
|
}
|
|
|
|
@task(function* () {
|
|
try {
|
|
yield this.model.restart();
|
|
} catch (err) {
|
|
this.set('error', {
|
|
title: 'Could Not Restart Task',
|
|
description: messageForError(err, 'manage allocation lifecycle'),
|
|
});
|
|
}
|
|
})
|
|
restartTask;
|
|
|
|
get shouldShowActions() {
|
|
return (
|
|
this.model.state === 'running' &&
|
|
this.model.task.actions?.length &&
|
|
this.nomadActions.hasActionPermissions
|
|
);
|
|
}
|
|
|
|
@task(function* () {
|
|
try {
|
|
yield this.model.forcePause();
|
|
this.notifications.add({
|
|
title: 'Task Force Paused',
|
|
message: 'Task has been force paused',
|
|
color: 'success',
|
|
});
|
|
} catch (err) {
|
|
this.set('error', {
|
|
title: 'Could Not Force Pause Task',
|
|
});
|
|
}
|
|
})
|
|
forcePause;
|
|
|
|
@task(function* () {
|
|
try {
|
|
yield this.model.forceRun();
|
|
this.notifications.add({
|
|
title: 'Task Force Run',
|
|
message: 'Task has been force run',
|
|
color: 'success',
|
|
});
|
|
} catch (err) {
|
|
this.set('error', {
|
|
title: 'Could Not Force Run Task',
|
|
});
|
|
}
|
|
})
|
|
forceRun;
|
|
|
|
@task(function* () {
|
|
try {
|
|
yield this.model.reEnableSchedule();
|
|
this.notifications.add({
|
|
title: 'Task Put Back On Schedule',
|
|
message: 'Task has been put back on its configured schedule',
|
|
color: 'success',
|
|
});
|
|
} catch (err) {
|
|
this.set('error', {
|
|
title: 'Could Not put back on schedule',
|
|
});
|
|
}
|
|
})
|
|
reEnableSchedule;
|
|
}
|