addon_operator

package
v1.5.0-fix-logrus-double Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 62 Imported by: 4

Documentation

Index

Constants

View Source
const (
	LabelHeritage string = "heritage"
)

Variables

View Source
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 ConvergeModulesInQueue(q *queue.TaskQueue) int

func ConvergeTasksInQueue added in v1.0.6

func ConvergeTasksInQueue(q *queue.TaskQueue) int

func DrainNonMainQueue added in v1.0.6

func DrainNonMainQueue(q *queue.TaskQueue)

func InitDefaultHelmResourcesManager added in v1.0.6

func InitDefaultHelmResourcesManager(ctx context.Context, metricStorage *metric_storage.MetricStorage) (helm_resources_manager.HelmResourcesManager, error)

func ModuleEnsureCRDsTasksInQueueAfterId added in v1.5.0

func ModuleEnsureCRDsTasksInQueueAfterId(q *queue.TaskQueue, afterId string) bool

func ModulesWithPendingModuleRun added in v1.0.6

func ModulesWithPendingModuleRun(q *queue.TaskQueue) map[string]struct{}

ModulesWithPendingModuleRun returns names of all modules in pending ModuleRun tasks. First task in queue considered not pending and is ignored.

func QueueHasPendingModuleRunTask

func QueueHasPendingModuleRunTask(q *queue.TaskQueue, moduleName string) bool

QueueHasPendingModuleRunTask returns true if queue has pending tasks with the type "ModuleRun" related to the module "moduleName".

func RemoveAdjacentConvergeModules added in v1.0.6

func RemoveAdjacentConvergeModules(q *queue.TaskQueue, afterId string, logLabels map[string]string)

RemoveAdjacentConvergeModules removes ConvergeModules tasks right after the task with the specified ID.

func RemoveCurrentConvergeTasks added in v1.0.6

func RemoveCurrentConvergeTasks(convergeQueues []*queue.TaskQueue, logLabels map[string]string) bool

RemoveCurrentConvergeTasks detects if converge tasks present in the main and parallel queues. These tasks are drained and the method returns true

func RemoveCurrentConvergeTasksFromId added in v1.5.0

func RemoveCurrentConvergeTasksFromId(q *queue.TaskQueue, afterId string, logLabels map[string]string) bool

RemoveCurrentConvergeTasksFromId 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 {
	DebugServer *debug.Server

	// 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 *converge.ConvergeState

	// Initial KubeConfig to bypass initial loading from the ConfigMap.
	InitialKubeConfig *config.KubeConfig

	// AdmissionServer handles validation and mutation admission webhooks
	AdmissionServer *AdmissionServer

	MetricStorage *metric_storage.MetricStorage

	// LeaderElector represents leaderelection client for HA mode
	LeaderElector *leaderelection.LeaderElector

	// CRDExtraLabels contains labels for processing CRD files
	// like heritage=addon-operator
	CRDExtraLabels map[string]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) Assemble added in v1.1.3

func (op *AddonOperator) Assemble(debugServer *debug.Server) (err error)

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) CheckCRDsEnsured added in v1.5.0

func (op *AddonOperator) CheckCRDsEnsured(t sh_task.Task)

CheckCRDsEnsured checks if there any other ModuleEnsureCRDs tasks in the queue and if there aren't, sets ConvergeState.CRDsEnsured to true and applies global values patch with the discovered GVKs

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) CreateAndStartParallelQueues added in v1.5.0

func (op *AddonOperator) CreateAndStartParallelQueues()

CreateAndStartParallelQueues creates and starts named queues for executing parallel tasks in parallel

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) 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 EnsureCRDsTasks and ModuleRun/ModuleDelete tasks based on moduleManager state.

func (*AddonOperator) CreatePurgeTasks added in v1.0.6

func (op *AddonOperator) CreatePurgeTasks(modulesToPurge []string, t sh_task.Task) []sh_task.Task

CreatePurgeTasks returns ModulePurge tasks for each unknown Helm release.

func (*AddonOperator) CreateReloadModulesTasks added in v1.0.6

func (op *AddonOperator) CreateReloadModulesTasks(moduleNames []string, logLabels map[string]string, eventDescription string) []sh_task.Task

func (*AddonOperator) DrainModuleQueues added in v1.0.3

func (op *AddonOperator) DrainModuleQueues(modName string)

func (*AddonOperator) EnsureCRDs added in v1.5.0

func (op *AddonOperator) EnsureCRDs(module *modules.BasicModule) ([]string, error)

func (*AddonOperator) HandleApplyKubeConfigValues added in v1.4.0

func (op *AddonOperator) HandleApplyKubeConfigValues(t sh_task.Task, logLabels map[string]string) (res queue.TaskResult)

ApplyKubeConfigValues

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) HandleModuleEnsureCRDs added in v1.5.0

func (op *AddonOperator) HandleModuleEnsureCRDs(t sh_task.Task, labels map[string]string) (res queue.TaskResult)

HandleModuleEnsureCRDs ensure CRDs for 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) HandleParallelModuleRun added in v1.5.0

func (op *AddonOperator) HandleParallelModuleRun(t sh_task.Task, labels map[string]string) (res queue.TaskResult)

HandleParallelModuleRun runs multiple HandleModuleRun tasks in parallel and aggregates their results

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) KubeClient added in v1.3.0

func (op *AddonOperator) KubeClient() *client.Client

KubeClient returns default common kubernetes client initialized by shell-operator

func (*AddonOperator) ParallelTasksHandler added in v1.5.0

func (op *AddonOperator) ParallelTasksHandler(t sh_task.Task) queue.TaskResult

ParallelTasksHandler handles limited types of tasks in parallel queues.

func (*AddonOperator) RegisterDebugGlobalRoutes added in v1.1.3

func (op *AddonOperator) RegisterDebugGlobalRoutes(dbgSrv *debug.Server)

func (*AddonOperator) RegisterDebugGraphRoutes added in v1.4.0

func (op *AddonOperator) RegisterDebugGraphRoutes(dbgSrv *debug.Server)

func (*AddonOperator) RegisterDebugModuleRoutes added in v1.1.3

func (op *AddonOperator) RegisterDebugModuleRoutes(dbgSrv *debug.Server)

func (*AddonOperator) RegisterDiscoveryRoute added in v1.3.4

func (op *AddonOperator) RegisterDiscoveryRoute(dbgSrv *debug.Server)

func (*AddonOperator) RegisterManagerEventsHandlers added in v1.0.6

func (op *AddonOperator) RegisterManagerEventsHandlers()

func (*AddonOperator) Setup added in v1.3.0

func (op *AddonOperator) Setup() error

func (*AddonOperator) SetupKubeConfigManager added in v1.3.0

func (op *AddonOperator) SetupKubeConfigManager(bk backend.ConfigHandler)

SetupKubeConfigManager sets manager, which reads configuration for Modules from a cluster

func (*AddonOperator) SetupModuleManager added in v1.1.3

func (op *AddonOperator) SetupModuleManager(modulesDir string, globalHooksDir string, tempDir string)

func (*AddonOperator) Start

func (op *AddonOperator) Start(_ context.Context) error

Start runs all managers, event and queue handlers. TODO: implement context in various dependencies (ModuleManager, KubeConfigManaer, etc)

func (*AddonOperator) StartAPIServer added in v1.3.9

func (op *AddonOperator) StartAPIServer()

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

func (*AddonOperator) WithLeaderElector added in v1.3.9

func (op *AddonOperator) WithLeaderElector(config *leaderelection.LeaderElectionConfig) error

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 CRDsInstaller added in v1.5.0

type CRDsInstaller struct {
	// contains filtered or unexported fields
}

CRDsInstaller simultaneously installs CRDs from specified directory

func NewCRDsInstaller added in v1.5.0

func NewCRDsInstaller(client *client.Client, crdFilesPaths []string, crdExtraLabels map[string]string) (*CRDsInstaller, error)

NewCRDsInstaller creates new installer for CRDs

func (*CRDsInstaller) Run added in v1.5.0

func (cp *CRDsInstaller) Run(ctx context.Context) *multierror.Error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL