Documentation ¶
Index ¶
- Constants
- func GroupRestoreExecHooks(resourceRestoreHooks []ResourceRestoreHook, pod *corev1api.Pod, ...) (map[string][]PodExecRestoreHook, error)
- func ValidateContainer(raw []byte) error
- type DefaultItemHookHandler
- type DefaultListWatchFactory
- type DefaultWaitExecHookHandler
- type HookErrInfo
- type HookTracker
- func (ht *HookTracker) Add(podNamespace, podName, container, source, hookName string, hookPhase hookPhase)
- func (ht *HookTracker) GetTracker() map[hookTrackerKey]hookTrackerVal
- func (ht *HookTracker) Record(podNamespace, podName, container, source, hookName string, hookPhase hookPhase, ...) error
- func (ht *HookTracker) Stat() (hookAttemptedCnt int, hookFailed int)
- type InitContainerRestoreHookHandler
- type ItemHookHandler
- type ItemRestoreHookHandler
- type ListWatchFactory
- type NoOpItemHookHandler
- type PodExecRestoreHook
- type ResourceHook
- type ResourceHookSelector
- type ResourceRestoreHook
- type WaitExecHookHandler
Constants ¶
const ( HookSourceAnnotation = "annotation" HookSourceSpec = "spec" )
const ( PhasePre hookPhase = "pre" PhasePost hookPhase = "post" )
Variables ¶
This section is empty.
Functions ¶
func GroupRestoreExecHooks ¶ added in v1.5.1
func GroupRestoreExecHooks( resourceRestoreHooks []ResourceRestoreHook, pod *corev1api.Pod, log logrus.FieldLogger, hookTrack *HookTracker, ) (map[string][]PodExecRestoreHook, error)
GroupRestoreExecHooks returns a list of hooks to be executed in a pod grouped by container name. If an exec hook is defined in annotation that is used, else applicable exec hooks from the restore resource are accumulated.
func ValidateContainer ¶ added in v1.10.0
ValidateContainer validate whether a map contains mandatory k8s Container fields. mandatory fields include name, image and commands.
Types ¶
type DefaultItemHookHandler ¶
type DefaultItemHookHandler struct {
PodCommandExecutor podexec.PodCommandExecutor
}
DefaultItemHookHandler is the default itemHookHandler.
func (*DefaultItemHookHandler) HandleHooks ¶
func (h *DefaultItemHookHandler) HandleHooks( log logrus.FieldLogger, groupResource schema.GroupResource, obj runtime.Unstructured, resourceHooks []ResourceHook, phase hookPhase, hookTracker *HookTracker, ) error
type DefaultListWatchFactory ¶ added in v1.5.1
func (*DefaultListWatchFactory) NewListWatch ¶ added in v1.5.1
func (d *DefaultListWatchFactory) NewListWatch(namespace string, selector fields.Selector) cache.ListerWatcher
type DefaultWaitExecHookHandler ¶ added in v1.5.1
type DefaultWaitExecHookHandler struct { ListWatchFactory ListWatchFactory PodCommandExecutor podexec.PodCommandExecutor }
func (*DefaultWaitExecHookHandler) HandleHooks ¶ added in v1.5.1
func (e *DefaultWaitExecHookHandler) HandleHooks( ctx context.Context, log logrus.FieldLogger, pod *v1.Pod, byContainer map[string][]PodExecRestoreHook, hookTracker *HookTracker, ) []error
type HookErrInfo ¶ added in v1.13.0
type HookTracker ¶ added in v1.13.0
type HookTracker struct {
// contains filtered or unexported fields
}
HookTracker tracks all hooks' execution status
func NewHookTracker ¶ added in v1.13.0
func NewHookTracker() *HookTracker
NewHookTracker creates a hookTracker.
func (*HookTracker) Add ¶ added in v1.13.0
func (ht *HookTracker) Add(podNamespace, podName, container, source, hookName string, hookPhase hookPhase)
Add adds a hook to the tracker Add must precede the Record for each individual hook. In other words, a hook must be added to the tracker before its execution result is recorded.
func (*HookTracker) GetTracker ¶ added in v1.13.0
func (ht *HookTracker) GetTracker() map[hookTrackerKey]hookTrackerVal
GetTracker gets the tracker inside HookTracker
func (*HookTracker) Record ¶ added in v1.13.0
func (ht *HookTracker) Record(podNamespace, podName, container, source, hookName string, hookPhase hookPhase, hookFailed bool) error
Record records the hook's execution status Add must precede the Record for each individual hook. In other words, a hook must be added to the tracker before its execution result is recorded.
func (*HookTracker) Stat ¶ added in v1.13.0
func (ht *HookTracker) Stat() (hookAttemptedCnt int, hookFailed int)
Stat calculates the number of attempted hooks and failed hooks
type InitContainerRestoreHookHandler ¶
type InitContainerRestoreHookHandler struct{}
InitContainerRestoreHookHandler is the restore hook handler to add init containers to restored pods.
func (*InitContainerRestoreHookHandler) HandleRestoreHooks ¶
func (i *InitContainerRestoreHookHandler) HandleRestoreHooks( log logrus.FieldLogger, groupResource schema.GroupResource, obj runtime.Unstructured, resourceRestoreHooks []ResourceRestoreHook, namespaceMapping map[string]string, ) (runtime.Unstructured, error)
HandleRestoreHooks runs the restore hooks for an item. If the item is a pod, then hooks are chosen to be run as follows: If the pod has the appropriate annotations specifying the hook action, then hooks from the annotation are run Otherwise, the supplied ResourceRestoreHooks are applied.
type ItemHookHandler ¶
type ItemHookHandler interface { // HandleHooks invokes hooks for an item. If the item is a pod and the appropriate annotations exist // to specify a hook, that is executed. Otherwise, this looks at the backup context's Backup to // determine if there are any hooks relevant to the item, taking into account the hook spec's // namespaces, resources, and label selector. HandleHooks( log logrus.FieldLogger, groupResource schema.GroupResource, obj runtime.Unstructured, resourceHooks []ResourceHook, phase hookPhase, hookTracker *HookTracker, ) error }
ItemHookHandler invokes hooks for an item.
type ItemRestoreHookHandler ¶
type ItemRestoreHookHandler interface { HandleRestoreHooks( log logrus.FieldLogger, groupResource schema.GroupResource, obj runtime.Unstructured, rh []ResourceRestoreHook, ) (runtime.Unstructured, error) }
ItemRestoreHookHandler invokes restore hooks for an item
type ListWatchFactory ¶ added in v1.5.1
type ListWatchFactory interface {
NewListWatch(namespace string, selector fields.Selector) cache.ListerWatcher
}
type NoOpItemHookHandler ¶ added in v1.11.0
type NoOpItemHookHandler struct{}
NoOpItemHookHandler is the an itemHookHandler for the Finalize controller where hooks don't run
func (*NoOpItemHookHandler) HandleHooks ¶ added in v1.11.0
func (h *NoOpItemHookHandler) HandleHooks( log logrus.FieldLogger, groupResource schema.GroupResource, obj runtime.Unstructured, resourceHooks []ResourceHook, phase hookPhase, hookTracker *HookTracker, ) error
type PodExecRestoreHook ¶ added in v1.5.1
type PodExecRestoreHook struct { HookName string HookSource string Hook velerov1api.ExecRestoreHook // contains filtered or unexported fields }
type ResourceHook ¶
type ResourceHook struct { Name string Selector ResourceHookSelector Pre []velerov1api.BackupResourceHook Post []velerov1api.BackupResourceHook }
ResourceHook is a hook for a given resource.
type ResourceHookSelector ¶
type ResourceHookSelector struct { Namespaces *collections.IncludesExcludes Resources *collections.IncludesExcludes LabelSelector labels.Selector }
type ResourceRestoreHook ¶
type ResourceRestoreHook struct { Name string Selector ResourceHookSelector RestoreHooks []velerov1api.RestoreResourceHook }
ResourceRestoreHook is a restore hook for a given resource.
func GetRestoreHooksFromSpec ¶
func GetRestoreHooksFromSpec(hooksSpec *velerov1api.RestoreHooks) ([]ResourceRestoreHook, error)
GetRestoreHooksFromSpec returns a list of ResourceRestoreHooks from the restore Spec.
type WaitExecHookHandler ¶ added in v1.5.1
type WaitExecHookHandler interface { HandleHooks( ctx context.Context, log logrus.FieldLogger, pod *v1.Pod, byContainer map[string][]PodExecRestoreHook, hookTrack *HookTracker, ) []error }