Documentation ¶
Index ¶
- Constants
- func GroupRestoreExecHooks(restoreName string, resourceRestoreHooks []ResourceRestoreHook, ...) (map[string][]PodExecRestoreHook, error)
- func ValidateContainer(raw []byte) error
- type DefaultItemHookHandler
- type DefaultListWatchFactory
- type DefaultWaitExecHookHandler
- type HookErrInfo
- type HookPhase
- type HookTracker
- func (ht *HookTracker) Add(podNamespace, podName, container, source, hookName string, hookPhase HookPhase)
- func (ht *HookTracker) HookErrs() []HookErrInfo
- func (ht *HookTracker) IsComplete() bool
- func (ht *HookTracker) Record(podNamespace, podName, container, source, hookName string, hookPhase HookPhase, ...) error
- func (ht *HookTracker) Stat() (hookAttemptedCnt int, hookFailedCnt int)
- type InitContainerRestoreHookHandler
- type ItemHookHandler
- type ItemRestoreHookHandler
- type ListWatchFactory
- type MultiHookTracker
- func (mht *MultiHookTracker) Add(name, podNamespace, podName, container, source, hookName string, ...)
- func (mht *MultiHookTracker) Delete(name string)
- func (mht *MultiHookTracker) HookErrs(name string) []HookErrInfo
- func (mht *MultiHookTracker) IsComplete(name string) bool
- func (mht *MultiHookTracker) Record(name, podNamespace, podName, container, source, hookName string, ...) error
- func (mht *MultiHookTracker) Stat(name string) (hookAttemptedCnt int, hookFailedCnt int)
- type NoOpItemHookHandler
- type PodExecRestoreHook
- type ResourceHook
- type ResourceHookSelector
- type ResourceRestoreHook
- type WaitExecHookHandler
Constants ¶
const ( HookSourceAnnotation = "annotation" HookSourceSpec = "spec" )
Variables ¶
This section is empty.
Functions ¶
func GroupRestoreExecHooks ¶ added in v1.5.1
func GroupRestoreExecHooks( restoreName string, resourceRestoreHooks []ResourceRestoreHook, pod *corev1api.Pod, log logrus.FieldLogger, hookTrack *MultiHookTracker, ) (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, multiHookTracker *MultiHookTracker, restoreName string, ) []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 in a single backup/restore.
func NewHookTracker ¶ added in v1.13.0
func NewHookTracker() *HookTracker
NewHookTracker creates a hookTracker instance.
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 hook 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) HookErrs ¶ added in v1.14.0
func (ht *HookTracker) HookErrs() []HookErrInfo
HooksErr returns hook execution errors
func (*HookTracker) IsComplete ¶ added in v1.14.0
func (ht *HookTracker) IsComplete() bool
IsComplete returns whether the execution of all hooks has finished or not
func (*HookTracker) Record ¶ added in v1.13.0
func (ht *HookTracker) Record(podNamespace, podName, container, source, hookName string, hookPhase HookPhase, hookFailed bool, hookErr error) 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, hookFailedCnt int)
Stat returns 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 MultiHookTracker ¶ added in v1.14.0
type MultiHookTracker struct {
// contains filtered or unexported fields
}
MultiHookTrackers tracks all hooks' execution status for multiple backups/restores.
func NewMultiHookTracker ¶ added in v1.14.0
func NewMultiHookTracker() *MultiHookTracker
NewMultiHookTracker creates a multiHookTracker instance.
func (*MultiHookTracker) Add ¶ added in v1.14.0
func (mht *MultiHookTracker) Add(name, podNamespace, podName, container, source, hookName string, hookPhase HookPhase)
Add adds a backup/restore hook to the tracker
func (*MultiHookTracker) Delete ¶ added in v1.14.0
func (mht *MultiHookTracker) Delete(name string)
Delete removes the hook data for a particular backup/restore
func (*MultiHookTracker) HookErrs ¶ added in v1.14.0
func (mht *MultiHookTracker) HookErrs(name string) []HookErrInfo
HooksErr returns hook execution errors for a particular backup/restore
func (*MultiHookTracker) IsComplete ¶ added in v1.14.0
func (mht *MultiHookTracker) IsComplete(name string) bool
IsComplete returns whether the execution of all hooks for a particular backup/restore has finished or not
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, multiHookTracker *MultiHookTracker, restoreName string, ) []error }