podopslifecycle

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLabel added in v0.3.0

func AddLabel(po *corev1.Pod, k, v string) bool

func AllowOps

func AllowOps(adapter LifecycleAdapter, operationDelaySeconds int32, obj client.Object) (requeueAfter *time.Duration, allow bool)

AllowOps is used to check whether the PodOpsLifecycle phase is in UPGRADE to do following operations.

func Begin

func Begin(c client.Client, adapter LifecycleAdapter, obj client.Object, updateFunc ...UpdateFunc) (updated bool, err error)

Begin is used for an CRD Operator to begin a lifecycle

func DefaultUpdateAll added in v0.3.0

func DefaultUpdateAll(pod client.Object, updateFunc ...UpdateFunc) (updated bool, err error)

func Finish

func Finish(c client.Client, adapter LifecycleAdapter, obj client.Object, updateFunc ...UpdateFunc) (updated bool, err error)

Finish is used for an CRD Operator to finish a lifecycle

func IsDuringOps

func IsDuringOps(adapter LifecycleAdapter, obj client.Object) bool

IsDuringOps decides whether the Pod is during ops or not DuringOps means the Pod's OpsLifecycle phase is in or after PreCheck phase and before Finish phase.

Types

type LifecycleAdapter

type LifecycleAdapter interface {
	// GetID indicates ID of one PodOpsLifecycle
	GetID() string

	// GetType indicates type for an Operator
	GetType() OperationType

	// AllowMultiType indicates whether multiple IDs which have the same Type are allowed
	AllowMultiType() bool

	// WhenBegin will be executed when begin a lifecycle
	WhenBegin(pod client.Object) (bool, error)

	// WhenFinish will be executed when finish a lifecycle
	WhenFinish(pod client.Object) (bool, error)
}

LifecycleAdapter helps CRD Operators to easily access PodOpsLifecycle

type OperationType

type OperationType string
var (
	OpsLifecycleTypeUpdate  OperationType = "update"
	OpsLifecycleTypeScaleIn OperationType = "scale-in"
	OpsLifecycleTypeDelete  OperationType = "delete"
)

type UpdateFunc added in v0.3.0

type UpdateFunc func(object client.Object) (bool, error)
var WhenBeginDelete UpdateFunc = func(obj client.Object) (bool, error) {
	return AddLabel(obj.(*corev1.Pod), appsv1alpha1.PodPreparingDeleteLabel, strconv.FormatInt(time.Now().UnixNano(), 10)), nil
}

Jump to

Keyboard shortcuts

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