mirror of
https://github.com/kemko/nomad.git
synced 2026-01-03 17:05: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.
74 lines
2.3 KiB
Go
74 lines
2.3 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package interfaces
|
|
|
|
import (
|
|
"github.com/hashicorp/nomad/client/allocdir"
|
|
"github.com/hashicorp/nomad/client/allocrunner/state"
|
|
"github.com/hashicorp/nomad/client/pluginmanager/csimanager"
|
|
"github.com/hashicorp/nomad/client/pluginmanager/drivermanager"
|
|
cstructs "github.com/hashicorp/nomad/client/structs"
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
"github.com/hashicorp/nomad/plugins/drivers"
|
|
)
|
|
|
|
// AllocRunner is the interface to the allocRunner struct used by client.Client
|
|
type AllocRunner interface {
|
|
Alloc() *structs.Allocation
|
|
|
|
Run()
|
|
Restore() error
|
|
Update(*structs.Allocation)
|
|
Reconnect(update *structs.Allocation) error
|
|
Shutdown()
|
|
Destroy()
|
|
|
|
IsDestroyed() bool
|
|
IsMigrating() bool
|
|
IsWaiting() bool
|
|
|
|
WaitCh() <-chan struct{}
|
|
DestroyCh() <-chan struct{}
|
|
ShutdownCh() <-chan struct{}
|
|
|
|
AllocState() *state.State
|
|
PersistState() error
|
|
AcknowledgeState(*state.State)
|
|
GetUpdatePriority(*structs.Allocation) cstructs.AllocUpdatePriority
|
|
SetClientStatus(string)
|
|
|
|
Signal(taskName, signal string) error
|
|
RestartTask(taskName string, taskEvent *structs.TaskEvent) error
|
|
RestartRunning(taskEvent *structs.TaskEvent) error
|
|
RestartAll(taskEvent *structs.TaskEvent) error
|
|
|
|
GetTaskEventHandler(taskName string) drivermanager.EventHandler
|
|
GetTaskExecHandler(taskName string) drivermanager.TaskExecHandler
|
|
GetTaskDriverCapabilities(taskName string) (*drivers.Capabilities, error)
|
|
StatsReporter() AllocStatsReporter
|
|
Listener() *cstructs.AllocListener
|
|
GetAllocDir() allocdir.Interface
|
|
SetTaskPauseState(taskName string, ps structs.TaskScheduleState) error
|
|
GetTaskPauseState(taskName string) (structs.TaskScheduleState, error)
|
|
}
|
|
|
|
// TaskStateHandler exposes a handler to be called when a task's state changes
|
|
type TaskStateHandler interface {
|
|
// TaskStateUpdated is used to notify the alloc runner about task state
|
|
// changes.
|
|
TaskStateUpdated()
|
|
}
|
|
|
|
// AllocStatsReporter gives access to the latest resource usage from the
|
|
// allocation
|
|
type AllocStatsReporter interface {
|
|
LatestAllocStats(taskFilter string) (*cstructs.AllocResourceUsage, error)
|
|
}
|
|
|
|
// HookResourceSetter is used to communicate between alloc hooks and task hooks
|
|
type HookResourceSetter interface {
|
|
SetCSIMounts(map[string]*csimanager.MountInfo)
|
|
GetCSIMounts(map[string]*csimanager.MountInfo)
|
|
}
|