Documentation
¶
Index ¶
- func InstallDriver(ctx context.Context, conf *config.Config) error
- func NewDriverFactory(conf *config.Config, watcher templates.Watcher) (*driverFactory, error)
- type ConditionMonitor
- type Controller
- type Daemon
- type Inspect
- type Once
- type TasksManager
- func (tm *TasksManager) Config() config.Config
- func (tm *TasksManager) EnableTaskDeletedNotify() <-chan string
- func (tm *TasksManager) EnableTaskRanNotify() <-chan string
- func (tm *TasksManager) Events(_ context.Context, taskName string) (map[string][]event.Event, error)
- func (tm *TasksManager) Init(ctx context.Context) error
- func (tm *TasksManager) Task(_ context.Context, taskName string) (config.TaskConfig, error)
- func (tm TasksManager) TaskByTemplate(tmplID string) (string, bool)
- func (tm *TasksManager) TaskCreate(ctx context.Context, taskConfig config.TaskConfig) (config.TaskConfig, error)
- func (tm *TasksManager) TaskCreateAndRun(ctx context.Context, taskConfig config.TaskConfig) (config.TaskConfig, error)
- func (tm *TasksManager) TaskCreateAndRunAllowFail(ctx context.Context, taskConfig config.TaskConfig)
- func (tm *TasksManager) TaskDelete(_ context.Context, name string) error
- func (tm *TasksManager) TaskInspect(ctx context.Context, taskConfig config.TaskConfig) (bool, string, string, error)
- func (tm *TasksManager) TaskRunNow(ctx context.Context, taskName string) error
- func (tm *TasksManager) TaskUpdate(ctx context.Context, updateConf config.TaskConfig, runOp string) (bool, string, string, error)
- func (tm *TasksManager) Tasks(_ context.Context) config.TaskConfigs
- func (tm TasksManager) WatchCreatedScheduleTasks() <-chan string
- func (tm TasksManager) WatchDeletedScheduleTask() <-chan string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstallDriver ¶
InstallDriver installs necessary drivers based on user configuration.
Types ¶
type ConditionMonitor ¶ added in v0.6.0
type ConditionMonitor struct {
// contains filtered or unexported fields
}
ConditionMonitor monitors the the conditions for all of the tasks and is responsible for triggering a task to execute. It uses the task manager to inform of starting / stopping task monitoring as well as executing a task
func NewConditionMonitor ¶ added in v0.6.0
func NewConditionMonitor(tm *TasksManager, w templates.Watcher) *ConditionMonitor
NewConditionMonitor configures a new condition monitor
func (*ConditionMonitor) Run ¶ added in v0.6.0
func (cm *ConditionMonitor) Run(ctx context.Context) error
Run runs a continuous loop which monitors the Consul catalog. On changes, Run uses the TasksManager to execute tasks to update network infrastructure.
The blocking call runs the main Consul monitoring loop, which identifies triggers for dynamic tasks. Scheduled tasks use their own go routine to trigger on schedule.
type Controller ¶
type Controller interface { // Init initializes elements needed by controller. Returns a map of // taskname to driver Init(ctx context.Context) error // Run runs the controller by monitoring Consul and triggering the driver as needed Run(ctx context.Context) error // Stop stops underlying clients and connections Stop() }
Controller describes the interface for monitoring Consul for relevant changes and triggering the driver to update network infrastructure.
type Daemon ¶ added in v0.6.0
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is the controller to run CTS as a daemon. It executes the tasks once (once-mode) and then runs the task in long-running mode. It also starts daemon-only features such as the API server
func (*Daemon) EnableTaskRanNotify ¶ added in v0.6.0
func (*Daemon) Init ¶ added in v0.6.0
Init initializes the controller before it can be run. Ensures that driver is initializes, works are created for each task.
type Inspect ¶ added in v0.6.0
type Inspect struct {
// contains filtered or unexported fields
}
Inspect is the controller to run in inspect mode
func NewInspect ¶ added in v0.6.0
NewInspect configures and initializes a new inspect controller
type Once ¶ added in v0.6.0
type Once struct {
// contains filtered or unexported fields
}
Once is the controller to run in once mode
type TasksManager ¶ added in v0.6.0
type TasksManager struct {
// contains filtered or unexported fields
}
TasksManager manages the CRUD operations and execution of tasks
func NewTasksManager ¶ added in v0.6.0
func NewTasksManager(conf *config.Config, state state.Store, watcher templates.Watcher) (*TasksManager, error)
NewTasksManager configures a new tasks manager
func (*TasksManager) Config ¶ added in v0.6.0
func (tm *TasksManager) Config() config.Config
Config returns the config from the TasksManager's state store
func (*TasksManager) EnableTaskDeletedNotify ¶ added in v0.6.0
func (tm *TasksManager) EnableTaskDeletedNotify() <-chan string
EnableTaskDeletedNotify is a helper for enabling notifications when a task has finished deleting. Callers of this method must consume from deletedTaskNotify channel to prevent the buffered channel from filling and causing a dead lock. EnableTaskDeletedNotify is typically used for testing.
func (*TasksManager) EnableTaskRanNotify ¶ added in v0.6.0
func (tm *TasksManager) EnableTaskRanNotify() <-chan string
EnableTaskRanNotify is a helper for enabling notifications when a task has finished executing after being triggered. Callers of this method must consume from ranTaskNotify channel to prevent the buffered channel from filling and causing a dead lock. EnableTaskRanNotify is typically used for testing.
func (*TasksManager) Events ¶ added in v0.6.0
func (tm *TasksManager) Events(_ context.Context, taskName string) (map[string][]event.Event, error)
Events takes as an argument a task name and returns the associated event list map from the TasksManager's state store
func (*TasksManager) Init ¶ added in v0.6.0
func (tm *TasksManager) Init(ctx context.Context) error
Init initializes a tasks manager
func (*TasksManager) Task ¶ added in v0.6.0
func (tm *TasksManager) Task(_ context.Context, taskName string) (config.TaskConfig, error)
Task takes as an argument a task name and returns the associated TaskConfig object from the TasksManager's state store
func (TasksManager) TaskByTemplate ¶ added in v0.6.0
func (tm TasksManager) TaskByTemplate(tmplID string) (string, bool)
TaskByTemplate returns the name of the task associated with a template id. If no task is associated with the template id, returns false.
func (*TasksManager) TaskCreate ¶ added in v0.6.0
func (tm *TasksManager) TaskCreate(ctx context.Context, taskConfig config.TaskConfig) (config.TaskConfig, error)
TaskCreate creates a new task and adds it to the managed tasks Note: This will not run the task after creation, see TaskCreateAndRun for this behavior
func (*TasksManager) TaskCreateAndRun ¶ added in v0.6.0
func (tm *TasksManager) TaskCreateAndRun(ctx context.Context, taskConfig config.TaskConfig) (config.TaskConfig, error)
TaskCreateAndRun creates a new task and then runs it. If successful it then adds the task to the managed tasks.
func (*TasksManager) TaskCreateAndRunAllowFail ¶ added in v0.7.0
func (tm *TasksManager) TaskCreateAndRunAllowFail(ctx context.Context, taskConfig config.TaskConfig)
TaskCreateAndRunAllowFail creates, runs, and adds a new task. It expects that this task is highly unlikely to error because it has previously been created and run before. Therefore it allows failure and does not handle error beyond logging
This method is used when we do not want the caller to error and exit when creating, running, and adding a new task.
func (*TasksManager) TaskDelete ¶ added in v0.6.0
func (tm *TasksManager) TaskDelete(_ context.Context, name string) error
TaskDelete marks an existing task that has been added to CTS for deletion then asynchronously deletes the task.
func (*TasksManager) TaskInspect ¶ added in v0.6.0
func (tm *TasksManager) TaskInspect(ctx context.Context, taskConfig config.TaskConfig) (bool, string, string, error)
TaskInspect creates and inspects a temporary task that is not added to the drivers list.
func (*TasksManager) TaskRunNow ¶ added in v0.6.0
func (tm *TasksManager) TaskRunNow(ctx context.Context, taskName string) error
TaskRunNow forces an existing task to run with a retry. It assumes that the task has already been created through TaskCreate or TaskCreateAndRun. It runs a task by attempting to render the template and applying the task as necessary.
An event is stored:
- whenever a task errors while executing
- when a dynamic task successfully executes
- when a scheduled task successfully executes (regardless of if there were dependency changes)
Note on #2: no event is stored when a dynamic task renders but does not apply. This can occur because driver.RenderTemplate() may need to be called multiple times before a template is ready to be applied.
func (*TasksManager) TaskUpdate ¶ added in v0.6.0
func (tm *TasksManager) TaskUpdate(ctx context.Context, updateConf config.TaskConfig, runOp string) (bool, string, string, error)
TaskUpdate patches a managed task with the provided configuration. If runOp is set to runtimeNow it will immediately run before completing the update, otherwise it will perform the update without running. Note: Currently only changes to the enabled state of the task are supported
func (*TasksManager) Tasks ¶ added in v0.6.0
func (tm *TasksManager) Tasks(_ context.Context) config.TaskConfigs
Tasks returns all tasks which exist in the TaskManager's state store
func (TasksManager) WatchCreatedScheduleTasks ¶ added in v0.6.0
func (tm TasksManager) WatchCreatedScheduleTasks() <-chan string
WatchCreatedScheduleTasks returns a channel to inform any watcher that a new scheduled task has been created and added to CTS.
func (TasksManager) WatchDeletedScheduleTask ¶ added in v0.6.0
func (tm TasksManager) WatchDeletedScheduleTask() <-chan string
WatchDeletedScheduleTask returns a channel to inform any watcher that a new scheduled task has been deleted and removed from CTS.