Documentation
¶
Index ¶
- Constants
- Variables
- func ConvergeModulesInQueue(q *queue.TaskQueue) int
- func ConvergeTasksInQueue(q *queue.TaskQueue) int
- func DefaultHelmMonitorKubeClient(metricStorage *metric_storage.MetricStorage, metricLabels map[string]string) klient.Client
- func DrainNonMainQueue(q *queue.TaskQueue)
- func InitDefaultHelmResourcesManager(ctx context.Context, metricStorage *metric_storage.MetricStorage) (helm_resources_manager.HelmResourcesManager, error)
- func IsConvergeTask(t sh_task.Task) bool
- func IsFirstConvergeTask(t sh_task.Task) bool
- func ModulesWithPendingModuleRun(q *queue.TaskQueue) map[string]struct{}
- func NewConvergeModulesTask(description string, convergeEvent ConvergeEvent, logLabels map[string]string) sh_task.Task
- func QueueHasPendingModuleRunTask(q *queue.TaskQueue, moduleName string) bool
- func RegisterAddonOperatorMetrics(metricStorage *metric_storage.MetricStorage)
- func RegisterHookMetrics(metricStorage *metric_storage.MetricStorage)
- func RemoveAdjacentConvergeModules(q *queue.TaskQueue, afterId string)
- func RemoveCurrentConvergeTasks(q *queue.TaskQueue, afterId string) bool
- func StartLiveTicksUpdater(metricStorage *metric_storage.MetricStorage)
- func StartTasksQueueLengthUpdater(metricStorage *metric_storage.MetricStorage, tqs *queue.TaskQueueSet)
- type AddonOperator
- func (op *AddonOperator) AllowHandleScheduleEvent(hook *module_manager.CommonHook) bool
- func (op *AddonOperator) Assemble(modulesDir string, globalHooksDir string, tempDir string, ...) (err error)
- func (op *AddonOperator) BootstrapMainQueue(tqs *queue.TaskQueueSet)
- func (op *AddonOperator) CheckConvergeStatus(t sh_task.Task)
- func (op *AddonOperator) CreateAfterAllTasks(logLabels map[string]string, eventDescription string) ([]sh_task.Task, error)
- func (op *AddonOperator) CreateAndStartQueue(queueName string) bool
- func (op *AddonOperator) CreateAndStartQueuesForAllModuleHooks()
- func (op *AddonOperator) CreateAndStartQueuesForGlobalHooks()
- func (op *AddonOperator) CreateAndStartQueuesForModuleHooks(moduleName string)
- func (op *AddonOperator) CreateBeforeAllTasks(logLabels map[string]string, eventDescription string) []sh_task.Task
- func (op *AddonOperator) CreateBootstrapTasks(logLabels map[string]string) []sh_task.Task
- func (op *AddonOperator) CreateConvergeModulesTasks(state *module_manager.ModulesState, logLabels map[string]string, ...) []sh_task.Task
- func (op *AddonOperator) CreatePurgeTasks(modulesToPurge []string, t sh_task.Task) []sh_task.Task
- func (op *AddonOperator) CreateReloadModulesTasks(moduleNames []string, logLabels map[string]string, eventDescription string) []sh_task.Task
- func (op *AddonOperator) DrainModuleQueues(modName string)
- func (op *AddonOperator) EmitModulesSync()
- func (op *AddonOperator) HandleConvergeModules(t sh_task.Task, logLabels map[string]string) (res queue.TaskResult)
- func (op *AddonOperator) HandleDiscoverHelmReleases(t sh_task.Task, labels map[string]string) (res queue.TaskResult)
- func (op *AddonOperator) HandleGlobalHookEnableKubernetesBindings(t sh_task.Task, labels map[string]string) (res queue.TaskResult)
- func (op *AddonOperator) HandleGlobalHookRun(t sh_task.Task, labels map[string]string) (res queue.TaskResult)
- func (op *AddonOperator) HandleModuleDelete(t sh_task.Task, labels map[string]string) (status queue.TaskStatus)
- func (op *AddonOperator) HandleModuleHookRun(t sh_task.Task, labels map[string]string) (res queue.TaskResult)
- func (op *AddonOperator) HandleModulePurge(t sh_task.Task, labels map[string]string) (status queue.TaskStatus)
- func (op *AddonOperator) HandleModuleRun(t sh_task.Task, labels map[string]string) (res queue.TaskResult)
- func (op *AddonOperator) InitModuleManager() error
- func (op *AddonOperator) IsStartupConvergeDone() bool
- func (op *AddonOperator) OnFirstConvergeDone()
- func (op *AddonOperator) RegisterDebugGlobalRoutes(dbgSrv *debug.Server)
- func (op *AddonOperator) RegisterDebugModuleRoutes(dbgSrv *debug.Server)
- func (op *AddonOperator) RegisterDefaultRoutes()
- func (op *AddonOperator) RegisterManagerEventsHandlers()
- func (op *AddonOperator) SetupModuleManager(modulesDir string, globalHooksDir string, tempDir string, ...)
- func (op *AddonOperator) Shutdown()
- func (op *AddonOperator) Start() error
- func (op *AddonOperator) StartModuleManagerEventHandler()
- func (op *AddonOperator) Stop()
- func (op *AddonOperator) TaskHandler(t sh_task.Task) queue.TaskResult
- func (op *AddonOperator) UpdateFirstConvergeStatus(convergeTasks int)
- func (op *AddonOperator) UpdateWaitInQueueMetric(t sh_task.Task)
- type AdmissionServer
- type ConvergeEvent
- type ConvergePhase
- type ConvergeState
Constants ¶
const ConvergeEventProp = "converge.event"
Variables ¶
var DefaultHelmMonitorKubeClientMetricLabels = map[string]string{"component": "helm_monitor"}
DefaultHelmMonitorKubeClientMetricLabels are labels that indicates go client metrics producer. Important! These labels should be consistent with similar labels in ShellOperator!
Functions ¶
func ConvergeModulesInQueue ¶ added in v1.0.6
func ConvergeTasksInQueue ¶ added in v1.0.6
func DefaultHelmMonitorKubeClient ¶ added in v1.0.6
func DefaultHelmMonitorKubeClient(metricStorage *metric_storage.MetricStorage, metricLabels map[string]string) klient.Client
DefaultHelmMonitorKubeClient initializes a Kubernetes client for helm monitor.
func DrainNonMainQueue ¶ added in v1.0.6
func InitDefaultHelmResourcesManager ¶ added in v1.0.6
func InitDefaultHelmResourcesManager(ctx context.Context, metricStorage *metric_storage.MetricStorage) (helm_resources_manager.HelmResourcesManager, error)
func IsConvergeTask ¶ added in v1.0.6
func IsFirstConvergeTask ¶ added in v1.0.6
func ModulesWithPendingModuleRun ¶ added in v1.0.6
ModulesWithPendingModuleRun returns names of all modules in pending ModuleRun tasks. First task in queue considered not pending and is ignored.
func NewConvergeModulesTask ¶ added in v1.0.6
func QueueHasPendingModuleRunTask ¶
QueueHasPendingModuleRunTask returns true if queue has pending tasks with the type "ModuleRun" related to the module "moduleName".
func RegisterAddonOperatorMetrics ¶
func RegisterAddonOperatorMetrics(metricStorage *metric_storage.MetricStorage)
func RegisterHookMetrics ¶
func RegisterHookMetrics(metricStorage *metric_storage.MetricStorage)
func RemoveAdjacentConvergeModules ¶ added in v1.0.6
RemoveAdjacentConvergeModules removes ConvergeModules tasks right after the task with the specified ID.
func RemoveCurrentConvergeTasks ¶ added in v1.0.6
RemoveCurrentConvergeTasks detects if converge tasks present in the main queue after task which ID equals to 'afterID'. These tasks are drained and the method returns true.
func StartLiveTicksUpdater ¶ added in v1.0.6
func StartLiveTicksUpdater(metricStorage *metric_storage.MetricStorage)
func StartTasksQueueLengthUpdater ¶ added in v1.0.6
func StartTasksQueueLengthUpdater(metricStorage *metric_storage.MetricStorage, tqs *queue.TaskQueueSet)
Types ¶
type AddonOperator ¶
type AddonOperator struct { *shell_operator.ShellOperator // KubeConfigManager monitors changes in ConfigMap. KubeConfigManager *kube_config_manager.KubeConfigManager // ModuleManager is the module manager object, which monitors configuration // and variable changes. ModuleManager *module_manager.ModuleManager Helm *helm.ClientFactory // HelmResourcesManager monitors absent resources created for modules. HelmResourcesManager helm_resources_manager.HelmResourcesManager // converge state ConvergeState *ConvergeState // Initial KubeConfig to bypass initial loading from the ConfigMap. InitialKubeConfig *kube_config_manager.KubeConfig // AdmissionServer handles validation and mutation admission webhooks AdmissionServer *AdmissionServer // ExplicitlyPurgeModules temporary way to purge explicitly set modules // linked with pkg/module_manager/module_manager.go#L555 ExplicitlyPurgeModules []string // contains filtered or unexported fields }
AddonOperator extends ShellOperator with modules and global hooks and with a value storage.
func NewAddonOperator ¶
func NewAddonOperator(ctx context.Context) *AddonOperator
func (*AddonOperator) AllowHandleScheduleEvent ¶ added in v1.0.6
func (op *AddonOperator) AllowHandleScheduleEvent(hook *module_manager.CommonHook) bool
AllowHandleScheduleEvent returns false if the Schedule event can be ignored.
func (*AddonOperator) BootstrapMainQueue ¶ added in v1.0.6
func (op *AddonOperator) BootstrapMainQueue(tqs *queue.TaskQueueSet)
BootstrapMainQueue adds tasks to initiate Startup sequence:
- Run onStartup hooks. - Enable global schedule bindings. - Enable kubernetes bindings: run Synchronization tasks. - Purge unknown Helm releases. - Start reload all modules.
func (*AddonOperator) CheckConvergeStatus ¶
func (op *AddonOperator) CheckConvergeStatus(t sh_task.Task)
CheckConvergeStatus detects if converge process is started and updates ConvergeState. It updates metrics on converge finish.
func (*AddonOperator) CreateAfterAllTasks ¶ added in v1.0.6
func (op *AddonOperator) CreateAfterAllTasks(logLabels map[string]string, eventDescription string) ([]sh_task.Task, error)
CreateAfterAllTasks returns tasks to run AfterAll global hooks.
func (*AddonOperator) CreateAndStartQueue ¶ added in v1.0.6
func (op *AddonOperator) CreateAndStartQueue(queueName string) bool
CreateAndStartQueue creates a named queue and starts it. It returns false is queue is already created
func (*AddonOperator) CreateAndStartQueuesForAllModuleHooks ¶ added in v1.0.6
func (op *AddonOperator) CreateAndStartQueuesForAllModuleHooks()
CreateAndStartQueuesForAllModuleHooks creates queues for all registered modules. It is safe to run this method multiple times, as it checks for existing queues.
func (*AddonOperator) CreateAndStartQueuesForGlobalHooks ¶ added in v1.0.6
func (op *AddonOperator) CreateAndStartQueuesForGlobalHooks()
CreateAndStartQueuesForGlobalHooks creates queues for all registered global hooks. It is safe to run this method multiple times, as it checks for existing queues.
func (*AddonOperator) CreateAndStartQueuesForModuleHooks ¶ added in v1.0.6
func (op *AddonOperator) CreateAndStartQueuesForModuleHooks(moduleName string)
CreateAndStartQueuesForModuleHooks creates queues for registered module hooks. It is safe to run this method multiple times, as it checks for existing queues.
func (*AddonOperator) CreateBeforeAllTasks ¶ added in v1.0.6
func (op *AddonOperator) CreateBeforeAllTasks(logLabels map[string]string, eventDescription string) []sh_task.Task
CreateBeforeAllTasks returns tasks to run BeforeAll global hooks.
func (*AddonOperator) CreateBootstrapTasks ¶ added in v1.0.6
func (op *AddonOperator) CreateBootstrapTasks(logLabels map[string]string) []sh_task.Task
func (*AddonOperator) CreateConvergeModulesTasks ¶ added in v1.0.6
func (op *AddonOperator) CreateConvergeModulesTasks(state *module_manager.ModulesState, logLabels map[string]string, eventDescription string) []sh_task.Task
CreateConvergeModulesTasks creates ModuleRun/ModuleDelete tasks based on moduleManager state.
func (*AddonOperator) CreatePurgeTasks ¶ added in v1.0.6
CreatePurgeTasks returns ModulePurge tasks for each unknown Helm release.
func (*AddonOperator) CreateReloadModulesTasks ¶ added in v1.0.6
func (*AddonOperator) DrainModuleQueues ¶ added in v1.0.3
func (op *AddonOperator) DrainModuleQueues(modName string)
func (*AddonOperator) EmitModulesSync ¶ added in v1.1.4
func (op *AddonOperator) EmitModulesSync()
EmitModulesSync emit modules CR synchronization
func (*AddonOperator) HandleConvergeModules ¶ added in v1.0.6
func (op *AddonOperator) HandleConvergeModules(t sh_task.Task, logLabels map[string]string) (res queue.TaskResult)
HandleConvergeModules is a multi-phase task.
func (*AddonOperator) HandleDiscoverHelmReleases ¶ added in v1.0.6
func (op *AddonOperator) HandleDiscoverHelmReleases(t sh_task.Task, labels map[string]string) (res queue.TaskResult)
HandleDiscoverHelmReleases runs RefreshStateFromHelmReleases to detect modules state at start.
func (*AddonOperator) HandleGlobalHookEnableKubernetesBindings ¶ added in v1.0.6
func (op *AddonOperator) HandleGlobalHookEnableKubernetesBindings(t sh_task.Task, labels map[string]string) (res queue.TaskResult)
HandleGlobalHookEnableKubernetesBindings add Synchronization tasks.
func (*AddonOperator) HandleGlobalHookRun ¶
func (op *AddonOperator) HandleGlobalHookRun(t sh_task.Task, labels map[string]string) (res queue.TaskResult)
func (*AddonOperator) HandleModuleDelete ¶ added in v1.0.6
func (op *AddonOperator) HandleModuleDelete(t sh_task.Task, labels map[string]string) (status queue.TaskStatus)
HandleModuleDelete deletes helm release for known module.
func (*AddonOperator) HandleModuleHookRun ¶
func (op *AddonOperator) HandleModuleHookRun(t sh_task.Task, labels map[string]string) (res queue.TaskResult)
func (*AddonOperator) HandleModulePurge ¶ added in v1.0.6
func (op *AddonOperator) HandleModulePurge(t sh_task.Task, labels map[string]string) (status queue.TaskStatus)
HandleModulePurge run helm purge for unknown module.
func (*AddonOperator) HandleModuleRun ¶
func (op *AddonOperator) HandleModuleRun(t sh_task.Task, labels map[string]string) (res queue.TaskResult)
HandleModuleRun starts a module by executing module hooks and installing a Helm chart.
Execution sequence: - Run onStartup hooks. - Queue kubernetes hooks as Synchronization tasks. - Wait until Synchronization tasks are done to fill all snapshots. - Enable kubernetes events. - Enable schedule events. - Run beforeHelm hooks - Run Helm to install or upgrade a module's chart. - Run afterHelm hooks.
ModuleRun is restarted if hook or chart is failed. After first HandleModuleRun success, no onStartup and kubernetes.Synchronization tasks will run.
func (*AddonOperator) InitModuleManager ¶
func (op *AddonOperator) InitModuleManager() error
InitModuleManager initialize KubeConfigManager and ModuleManager, reads values from ConfigMap for the first time and sets handlers for kubernetes and schedule events.
func (*AddonOperator) IsStartupConvergeDone ¶ added in v1.0.5
func (op *AddonOperator) IsStartupConvergeDone() bool
func (*AddonOperator) OnFirstConvergeDone ¶ added in v1.1.4
func (op *AddonOperator) OnFirstConvergeDone()
OnFirstConvergeDone run addon-operator business logic when first converge is done and operator is ready
func (*AddonOperator) RegisterDebugGlobalRoutes ¶ added in v1.1.3
func (op *AddonOperator) RegisterDebugGlobalRoutes(dbgSrv *debug.Server)
func (*AddonOperator) RegisterDebugModuleRoutes ¶ added in v1.1.3
func (op *AddonOperator) RegisterDebugModuleRoutes(dbgSrv *debug.Server)
func (*AddonOperator) RegisterDefaultRoutes ¶ added in v1.1.3
func (op *AddonOperator) RegisterDefaultRoutes()
func (*AddonOperator) RegisterManagerEventsHandlers ¶ added in v1.0.6
func (op *AddonOperator) RegisterManagerEventsHandlers()
func (*AddonOperator) SetupModuleManager ¶ added in v1.1.3
func (*AddonOperator) Shutdown ¶
func (op *AddonOperator) Shutdown()
func (*AddonOperator) Start ¶
func (op *AddonOperator) Start() error
Start runs all managers, event and queue handlers.
func (*AddonOperator) StartModuleManagerEventHandler ¶
func (op *AddonOperator) StartModuleManagerEventHandler()
func (*AddonOperator) Stop ¶
func (op *AddonOperator) Stop()
func (*AddonOperator) TaskHandler ¶
func (op *AddonOperator) TaskHandler(t sh_task.Task) queue.TaskResult
TaskHandler handles tasks in queue.
func (*AddonOperator) UpdateFirstConvergeStatus ¶ added in v1.0.6
func (op *AddonOperator) UpdateFirstConvergeStatus(convergeTasks int)
UpdateFirstConvergeStatus checks first converge status and prints log messages if first converge is in progress.
func (*AddonOperator) UpdateWaitInQueueMetric ¶
func (op *AddonOperator) UpdateWaitInQueueMetric(t sh_task.Task)
UpdateWaitInQueueMetric increases task_wait_in_queue_seconds_total counter for the task type. TODO pass queue name from handler, not from task
type AdmissionServer ¶ added in v1.1.4
type AdmissionServer struct {
// contains filtered or unexported fields
}
func NewAdmissionServer ¶ added in v1.1.4
func NewAdmissionServer(listenPort, certsDir string) *AdmissionServer
func (*AdmissionServer) RegisterHandler ¶ added in v1.1.4
func (as *AdmissionServer) RegisterHandler(route string, handler http.Handler)
type ConvergeEvent ¶ added in v1.0.6
type ConvergeEvent string
const ( // OperatorStartup is a first converge during startup. OperatorStartup ConvergeEvent = "OperatorStartup" // GlobalValuesChanged is a converge initiated by changing values in the global hook. GlobalValuesChanged ConvergeEvent = "GlobalValuesChanged" // KubeConfigChanged is a converge started after changing ConfigMap. KubeConfigChanged ConvergeEvent = "KubeConfigChanged" // ReloadAllModules is a converge queued to the ReloadAllModules ConvergeEvent = "ReloadAllModules" )
type ConvergePhase ¶ added in v1.0.6
type ConvergePhase string
const ( StandBy ConvergePhase = "StandBy" RunBeforeAll ConvergePhase = "RunBeforeAll" WaitBeforeAll ConvergePhase = "WaitBeforeAll" WaitDeleteAndRunModules ConvergePhase = "WaitDeleteAndRunModules" WaitAfterAll ConvergePhase = "WaitAfterAll" )
type ConvergeState ¶ added in v1.0.6
type ConvergeState struct { Phase ConvergePhase StartedAt int64 Activation string // contains filtered or unexported fields }
func NewConvergeState ¶ added in v1.0.6
func NewConvergeState() *ConvergeState