utils

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: 24 Imported by: 0

Documentation

Index

Constants

View Source
const ConditionUpdatePeriodBackOff = 30 * time.Second

Variables

View Source
var (
	UpdateOpsLifecycleAdapter  = &CollaSetUpdateOpsLifecycleAdapter{}
	ScaleInOpsLifecycleAdapter = &CollaSetScaleInOpsLifecycleAdapter{}
)
View Source
var (
	// ActiveExpectations is used to check the cache in informer is updated, before reconciling.
	ActiveExpectations *expectations.ActiveExpectations
)

Functions

func AddOrUpdateCondition

func AddOrUpdateCondition(status *appsv1alpha1.CollaSetStatus, conditionType appsv1alpha1.CollaSetConditionType, err error, reason, message string)

func ApplyPatchFromRevision added in v0.2.0

func ApplyPatchFromRevision(pod *corev1.Pod, revision *appsv1.ControllerRevision) (*corev1.Pod, error)

func BuildPvcWithHash added in v0.3.0

func CollectPodInstanceID

func CollectPodInstanceID(pods []*PodWrapper) map[int]struct{}

func ComparePod added in v0.2.0

func ComparePod(l, r *corev1.Pod) bool

func ExtractPvcTmpName added in v0.3.0

func ExtractPvcTmpName(cls *appsv1alpha1.CollaSet, pvc *corev1.PersistentVolumeClaim) (string, error)

func GetCondition

GetCondition returns a inplace set condition with the provided type if it exists.

func GetPodFromRevision added in v0.2.0

func GetPodFromRevision(revision *appsv1.ControllerRevision) (*corev1.Pod, error)

func GetPodInstanceID

func GetPodInstanceID(pod *corev1.Pod) (int, error)

func GetPodRevisionPatch added in v0.2.0

func GetPodRevisionPatch(revision *appsv1.ControllerRevision) ([]byte, error)

func GetPodsPrefix added in v0.2.0

func GetPodsPrefix(controllerName string) string

func InitExpectations

func InitExpectations(c client.Client)

func IsPodUpdatedRevision added in v0.2.0

func IsPodUpdatedRevision(pod *corev1.Pod, revision string) bool

func NewPodFrom

func NewPodFrom(owner metav1.Object, ownerRef *metav1.OwnerReference, revision *appsv1.ControllerRevision, updateFn ...func(*corev1.Pod) error) (*corev1.Pod, error)

func PatchToPod added in v0.2.0

func PatchToPod(currentRevisionPod, updateRevisionPod, currentPod *corev1.Pod) (*corev1.Pod, error)

PatchToPod Use three-way merge to get a updated pod.

func PvcTmpHash added in v0.3.0

func PvcTmpHash(pvc *corev1.PersistentVolumeClaim) (string, error)

func PvcTmpHashMapping added in v0.3.0

func PvcTmpHashMapping(pvcTmps []corev1.PersistentVolumeClaim) (map[string]string, error)

func RemoveCondition

func RemoveCondition(status *appsv1alpha1.CollaSetStatus, condType appsv1alpha1.CollaSetConditionType)

RemoveCondition removes the condition with the provided type from the replicaset status.

func SetCondition

func SetCondition(status *appsv1alpha1.CollaSetStatus, condition *appsv1alpha1.CollaSetCondition)

SetCondition adds/replaces the given condition in the replicaset status. If the condition that we are about to add already exists and has the same status and reason then we are not going to update.

Types

type CollaSetScaleInOpsLifecycleAdapter

type CollaSetScaleInOpsLifecycleAdapter struct {
}

CollaSetScaleInOpsLifecycleAdapter tells PodOpsLifecycle the basic workload scaling in ops info

func (*CollaSetScaleInOpsLifecycleAdapter) AllowMultiType

func (a *CollaSetScaleInOpsLifecycleAdapter) AllowMultiType() bool

AllowMultiType indicates whether multiple IDs which have the same Type are allowed

func (*CollaSetScaleInOpsLifecycleAdapter) GetID

GetID indicates ID of one PodOpsLifecycle

func (*CollaSetScaleInOpsLifecycleAdapter) GetType

GetType indicates type for an Operator

func (*CollaSetScaleInOpsLifecycleAdapter) WhenBegin

WhenBegin will be executed when begin a lifecycle

func (*CollaSetScaleInOpsLifecycleAdapter) WhenFinish

WhenFinish will be executed when finish a lifecycle

type CollaSetUpdateOpsLifecycleAdapter

type CollaSetUpdateOpsLifecycleAdapter struct {
}

CollaSetUpdateOpsLifecycleAdapter tells PodOpsLifecycle the basic workload update ops info

func (*CollaSetUpdateOpsLifecycleAdapter) AllowMultiType

func (a *CollaSetUpdateOpsLifecycleAdapter) AllowMultiType() bool

AllowMultiType indicates whether multiple IDs which have the same Type are allowed

func (*CollaSetUpdateOpsLifecycleAdapter) GetID

GetID indicates ID of one PodOpsLifecycle

func (*CollaSetUpdateOpsLifecycleAdapter) GetType

GetType indicates type for an Operator

func (*CollaSetUpdateOpsLifecycleAdapter) WhenBegin

WhenBegin will be executed when begin a lifecycle

func (*CollaSetUpdateOpsLifecycleAdapter) WhenFinish

WhenFinish will be executed when finish a lifecycle

type PodDecorationGetter added in v0.2.0

type PodDecorationGetter interface {
	GetLatestDecorations() []*appsv1alpha1.PodDecoration
	GetCurrentDecorationsOnPod(ctx context.Context, pod *corev1.Pod) (map[string]*appsv1alpha1.PodDecoration, error)
	GetDecorationByRevisions(ctx context.Context, revisions ...string) (map[string]*appsv1alpha1.PodDecoration, error)
	GetLatestDecorationsByTargetLabel(ctx context.Context, labels map[string]string) (map[string]*appsv1alpha1.PodDecoration, error)
	GetUpdatedDecorationsByOldPod(ctx context.Context, pod *corev1.Pod) (map[string]*appsv1alpha1.PodDecoration, error)
}

func NewPodDecorationGetter added in v0.2.0

func NewPodDecorationGetter(ctx context.Context, c client.Client, namespace string) (PodDecorationGetter, error)

type PodWrapper

type PodWrapper struct {
	*corev1.Pod
	ID            int
	ContextDetail *appsv1alpha1.ContextDetail
}

type RelatedResources added in v0.2.0

type RelatedResources struct {
	Revisions       []*appsv1.ControllerRevision
	CurrentRevision *appsv1.ControllerRevision
	UpdatedRevision *appsv1.ControllerRevision
	ExistingPvcs    []*corev1.PersistentVolumeClaim

	PDGetter PodDecorationGetter

	NewStatus *appsv1alpha1.CollaSetStatus
}

Jump to

Keyboard shortcuts

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