Documentation
¶
Index ¶
- Variables
- func RunDefaultDebugServer(unixSocket, httpServerAddress string, logger *log.Logger) (*debug.Server, error)
- type AdmissionEventHandler
- type CombineResult
- type ConversionEventHandler
- type HookTaskFactory
- type KubeClientConfig
- type ManagerEventsHandler
- type Option
- type ShellOperator
- func (op *ShellOperator) AssembleCommonOperator(listenAddress, listenPort string, kubeEventsManagerLabels []string) error
- func (op *ShellOperator) CombineBindingContextForHook(q *queue.TaskQueue, t task.Task, stopCombineFn func(tsk task.Task) bool) *CombineResult
- func (op *ShellOperator) RegisterBuiltinTaskHandlers()
- func (op *ShellOperator) RegisterDebugConfigRoutes(dbgSrv *debug.Server, runtimeConfig *config.Config)
- func (op *ShellOperator) RegisterDebugHookRoutes(dbgSrv *debug.Server)
- func (op *ShellOperator) RegisterDebugQueueRoutes(dbgSrv *debug.Server)
- func (op *ShellOperator) SetupEventManagers()
- func (op *ShellOperator) Shutdown()
- func (op *ShellOperator) Start()
- func (op *ShellOperator) Stop()
- type TaskHandlerFunc
- type TaskHandlerRegistry
- type TaskRunner
Constants ¶
This section is empty.
Variables ¶
var WaitQueuesTimeout = time.Second * 10
Functions ¶
Types ¶
type AdmissionEventHandler ¶ added in v1.16.2
type AdmissionEventHandler struct {
// contains filtered or unexported fields
}
AdmissionEventHandler handles admission webhook events by creating a hook task, running it synchronously, and returning the hook's admission response.
func NewAdmissionEventHandler ¶ added in v1.16.2
func NewAdmissionEventHandler(hm hook.HookManager, runner TaskRunner, logger *log.Logger) *AdmissionEventHandler
NewAdmissionEventHandler creates a new AdmissionEventHandler.
type CombineResult ¶
type CombineResult struct {
BindingContexts []bctx.BindingContext
MonitorIDs []string
}
type ConversionEventHandler ¶ added in v1.16.2
type ConversionEventHandler struct {
// contains filtered or unexported fields
}
ConversionEventHandler handles conversion webhook events by finding the conversion path, running the appropriate hook tasks, and returning the converted objects.
func NewConversionEventHandler ¶ added in v1.16.2
func NewConversionEventHandler(hm hook.HookManager, runner TaskRunner, logger *log.Logger) *ConversionEventHandler
NewConversionEventHandler creates a new ConversionEventHandler.
func (*ConversionEventHandler) Handle ¶ added in v1.16.2
func (h *ConversionEventHandler) Handle(ctx context.Context, crdName string, request *v1.ConversionRequest) (*conversion.Response, error)
Handle implements the conversion event handler func signature expected by conversion.WebhookManager.EventHandlerFn.
type HookTaskFactory ¶ added in v1.16.1
type HookTaskFactory struct{}
HookTaskFactory builds HookRun tasks, deduplicating the repeated boilerplate across kube event, schedule, admission, and conversion event handlers.
The factory does not set WithQueuedAt; callers should stamp the task with task.WithQueuedAt(time.Now()) when the task is ready to be enqueued.
func (HookTaskFactory) NewHookRunTask ¶ added in v1.16.1
func (HookTaskFactory) NewHookRunTask(hookName string, bindingType types.BindingType, info controller.BindingExecutionInfo, logLabels map[string]string) task.Task
NewHookRunTask creates a HookRun task populated from a hook and a BindingExecutionInfo. It sets the CompactionID to hook.Name and copies QueueName from info.QueueName.
func (HookTaskFactory) NewSyncHookRunTask ¶ added in v1.16.1
func (HookTaskFactory) NewSyncHookRunTask(h *hook.Hook, info controller.BindingExecutionInfo, logLabels map[string]string) task.Task
NewSyncHookRunTask creates a HookRun task for the Kubernetes synchronization flow. It sets extra MonitorIDs and ExecuteOnSynchronization fields, and always uses the "main" queue regardless of info.QueueName.
type KubeClientConfig ¶ added in v1.16.0
type KubeClientConfig struct {
Context string
Config string
QPS float32
Burst int
Timeout time.Duration // zero means no timeout
}
KubeClientConfig holds explicit connection settings for a Kubernetes client, decoupling business logic from the global app.* configuration variables.
type ManagerEventsHandler ¶
type ManagerEventsHandler struct {
// contains filtered or unexported fields
}
func (*ManagerEventsHandler) Start ¶
func (m *ManagerEventsHandler) Start()
Start runs events handler. This function is used in addon-operator
func (*ManagerEventsHandler) WithKubeEventHandler ¶
func (m *ManagerEventsHandler) WithKubeEventHandler(fn func(ctx context.Context, kubeEvent kemtypes.KubeEvent) []task.Task)
WithKubeEventHandler sets custom function for event handling. This function is used inside addon-operator.
func (*ManagerEventsHandler) WithScheduleEventHandler ¶
func (m *ManagerEventsHandler) WithScheduleEventHandler(fn func(ctx context.Context, crontab string) []task.Task)
WithScheduleEventHandler sets custom scheduler function. This function is used inside addon-operator.
type Option ¶ added in v1.5.0
type Option func(operator *ShellOperator)
func WithLogger ¶ added in v1.5.0
type ShellOperator ¶
type ShellOperator struct {
// APIServer common http server for liveness and metrics endpoints
APIServer *baseHTTPServer
// MetricStorage collects and store metrics for built-in operator primitives, hook execution
MetricStorage metricsstorage.Storage
// HookMetricStorage separate metric storage for metrics, which are returned by user hooks
HookMetricStorage metricsstorage.Storage
KubeClient *klient.Client
ObjectPatcher *objectpatch.ObjectPatcher
ScheduleManager schedulemanager.ScheduleManager
KubeEventsManager kubeeventsmanager.KubeEventsManager
TaskQueues *queue.TaskQueueSet
ManagerEventsHandler *ManagerEventsHandler
HookManager hook.HookManager
AdmissionWebhookManager *admission.WebhookManager
ConversionWebhookManager *conversion.WebhookManager
// contains filtered or unexported fields
}
func Init ¶ added in v1.0.11
Init initialize logging, ensures directories and creates a ShellOperator instance with all dependencies.
func NewShellOperator ¶
func NewShellOperator(ctx context.Context, metricsStorage, hookMetricStorage metricsstorage.Storage, opts ...Option) *ShellOperator
func (*ShellOperator) AssembleCommonOperator ¶ added in v1.4.0
func (op *ShellOperator) AssembleCommonOperator(listenAddress, listenPort string, kubeEventsManagerLabels []string) error
AssembleCommonOperator instantiate common dependencies. These dependencies may be used for shell-operator derivatives, like addon-operator. requires listenAddress, listenPort to run http server for operator APIs
func (*ShellOperator) CombineBindingContextForHook ¶
func (op *ShellOperator) CombineBindingContextForHook(q *queue.TaskQueue, t task.Task, stopCombineFn func(tsk task.Task) bool) *CombineResult
CombineBindingContextForHook combines binding contexts from a sequence of task with similar hook name and task type into array of binding context and delete excess tasks from queue.
Also, sequences of binding contexts with similar group are compacted in one binding context.
If input task has no metadata, result will be nil. Metadata should implement HookNameAccessor, BindingContextAccessor and MonitorIDAccessor interfaces. DEV WARNING! Do not use HookMetadataAccessor here. Use only *Accessor interfaces because this method is used from addon-operator.
func (*ShellOperator) RegisterBuiltinTaskHandlers ¶ added in v1.16.2
func (op *ShellOperator) RegisterBuiltinTaskHandlers()
RegisterBuiltinTaskHandlers populates the registry with the three core task types. It must be called after HookManager is set. Extenders may call Register() afterwards to add extra task types without touching this method.
func (*ShellOperator) RegisterDebugConfigRoutes ¶ added in v1.4.0
func (op *ShellOperator) RegisterDebugConfigRoutes(dbgSrv *debug.Server, runtimeConfig *config.Config)
RegisterDebugConfigRoutes registers routes to manage runtime configuration. This method is also used in addon-operator
func (*ShellOperator) RegisterDebugHookRoutes ¶ added in v1.4.0
func (op *ShellOperator) RegisterDebugHookRoutes(dbgSrv *debug.Server)
RegisterDebugHookRoutes register routes for dumping queues
func (*ShellOperator) RegisterDebugQueueRoutes ¶ added in v1.4.0
func (op *ShellOperator) RegisterDebugQueueRoutes(dbgSrv *debug.Server)
RegisterDebugQueueRoutes register routes for dumping main queue this method is also used in addon-operator
func (*ShellOperator) SetupEventManagers ¶ added in v1.4.0
func (op *ShellOperator) SetupEventManagers()
SetupEventManagers instantiate queues and managers for schedule and Kubernetes events. This function is also used in the addon-operator
func (*ShellOperator) Shutdown ¶
func (op *ShellOperator) Shutdown()
Shutdown pause kubernetes events handling and stop queues. Wait for queues to stop.
func (*ShellOperator) Stop ¶
func (op *ShellOperator) Stop()
type TaskHandlerFunc ¶ added in v1.16.2
TaskHandlerFunc is the function type for handling a single task.
type TaskHandlerRegistry ¶ added in v1.16.2
type TaskHandlerRegistry struct {
// contains filtered or unexported fields
}
TaskHandlerRegistry maps task types to their handlers. New task types can be registered without modifying the dispatcher.
func NewTaskHandlerRegistry ¶ added in v1.16.2
func NewTaskHandlerRegistry() *TaskHandlerRegistry
NewTaskHandlerRegistry creates an empty registry.
func (*TaskHandlerRegistry) Handle ¶ added in v1.16.2
func (r *TaskHandlerRegistry) Handle(ctx context.Context, t task.Task) (queue.TaskResult, bool)
Handle dispatches the task to the registered handler. Returns a Fail result when no handler is found.
func (*TaskHandlerRegistry) Register ¶ added in v1.16.2
func (r *TaskHandlerRegistry) Register(taskType task.TaskType, handler TaskHandlerFunc)
Register associates a handler with a task type. Registering the same type twice overwrites the previous handler.
type TaskRunner ¶ added in v1.16.2
TaskRunner executes a task synchronously and returns its result. ShellOperator.taskHandler satisfies this type.