workload

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateExpectedPartition added in v0.1.3

func CalculateExpectedPartition(total *int32, expectedReplicas intstr.IntOrString, partitionInSpec int32) (int32, error)

CalculateExpectedPartition calculates the expected partition based on the total replicas, expected replicas, and the partition in the spec. In this function, partition means how many replicas are not updated.

func CalculateUpdatedReplicas added in v0.1.3

func CalculateUpdatedReplicas(totalReplicas *int32, expectedReplicas intstr.IntOrString) (int32, error)

func GetClusterFromLabel

func GetClusterFromLabel(labels map[string]string) string

func IsCanary added in v0.1.3

func IsCanary(workload client.Object) bool

func IsControlledByRollout added in v0.1.3

func IsControlledByRollout(workload client.Object) bool

func IsProgressing added in v0.1.3

func IsProgressing(workload client.Object) bool

func IsWaitingRollout added in v0.1.1

func IsWaitingRollout(info Info) bool

func PatchMetadata added in v0.1.0

func PatchMetadata(meta *metav1.ObjectMeta, patch rolloutv1alpha1.MetadataPatch)

PatchMetadata patches metadata with the given patch

Types

type Accessor added in v0.1.1

type Accessor interface {
	// GroupVersionKind returns the GroupVersionKind of the workload
	GroupVersionKind() schema.GroupVersionKind
	// DependentWorkloadGVKs returns the dependent workloadds' GroupVersionKinds
	DependentWorkloadGVKs() []schema.GroupVersionKind
	// NewObject returns a new instance of the workload type
	NewObject() client.Object
	// NewObjectList returns a new instance of the workload list type
	NewObjectList() client.ObjectList
	// Watchable indicates whether this workload type can be watched from the API server.
	Watchable() bool
	// GetInfo returns a info represent workload
	GetInfo(cluster string, obj client.Object) (*Info, error)
}

Accessor defines the functions to access the workload. The following interfaces are optional: - CanaryReleaseControl - BatchReleaseControl - PodControl

type BatchReleaseControl added in v0.1.3

type BatchReleaseControl interface {
	// BatchPreCheck checks object before batch release.
	BatchPreCheck(obj client.Object) error
	// ApplyPartition use expectedUpdated replicas to calculate partition and apply it to the workload.
	ApplyPartition(obj client.Object, expectedUpdated intstr.IntOrString) error
}

BatchReleaseControl defines the control functions for workload batch release

type CanaryReleaseControl added in v0.1.3

type CanaryReleaseControl interface {
	// CanaryPreCheck checks object before canary release.
	CanaryPreCheck(obj client.Object) error
	// Scale scales the workload replicas.
	Scale(obj client.Object, replicas int32) error
	// ApplyCanaryPatch applies canary to the workload.
	ApplyCanaryPatch(canary client.Object, podTemplatePatch *v1alpha1.MetadataPatch) error
}

CanaryReleaseControl defines the control functions for workload canary release

type Info

type Info struct {
	metav1.ObjectMeta
	// GVK is the GroupVersionKind of the workload.
	schema.GroupVersionKind
	// Status is the status of the workload.
	Status InfoStatus
	// Object is the object representing the workload.
	Object client.Object
}

workload info

func Get added in v0.1.1

func Get(ctx context.Context, c client.Client, inter Accessor, cluster, namespace, name string) (*Info, error)

func List added in v0.1.1

func List(ctx context.Context, c client.Client, inter Accessor, namespace string, match rolloutv1alpha1.ResourceMatch) ([]*Info, error)

List return a list of workloads that match the given namespace and match. It will ignore canary workloads or deleted workloads by default.

func NewInfo

func NewInfo(cluster string, gvk schema.GroupVersionKind, obj client.Object, status InfoStatus) *Info

func (*Info) APIStatus added in v0.1.0

func (*Info) CheckUpdatedReady added in v0.1.1

func (o *Info) CheckUpdatedReady(replicas int32) bool

func (*Info) NamespacedName added in v0.1.0

func (o *Info) NamespacedName() types.NamespacedName

func (*Info) String added in v0.1.0

func (o *Info) String() string

func (*Info) UpdateOnConflict added in v0.1.1

func (o *Info) UpdateOnConflict(ctx context.Context, client client.Client, mutateFn func(client.Object) error) (bool, error)

type InfoStatus added in v0.1.1

type InfoStatus struct {
	// ObservedGeneration is the most recent generation observed for this workload.
	ObservedGeneration int64
	// StableRevision is the old stable revision used to generate pods.
	StableRevision string
	// UpdatedRevision is the updated template revision used to generate pods.
	UpdatedRevision string
	// Replicas is the desired number of pods targeted by workload
	Replicas int32
	// UpdatedReplicas is the number of pods targeted by workload that have the updated template spec.
	UpdatedReplicas int32
	// UpdatedReadyReplicas is the number of ready pods targeted by workload that have the updated template spec.
	UpdatedReadyReplicas int32
	// UpdatedAvailableReplicas is the number of service available pods targeted by workload that have the updated template spec.
	UpdatedAvailableReplicas int32
}

workload status

type Matcher added in v0.1.1

type Matcher interface {
	Matches(cluster, name string, label map[string]string) bool
}

func MatchAsMatcher

func MatchAsMatcher(match rolloutv1alpha1.ResourceMatch) Matcher

type Owner added in v0.1.3

type Owner struct {
	Ref *metav1.OwnerReference
	GVK schema.GroupVersionKind
}

func GetControllerOf added in v0.1.3

func GetControllerOf(controllee client.Object) (*Owner, error)

func GetOwnersOf added in v0.1.3

func GetOwnersOf(controllee client.Object) ([]*Owner, error)

type PodControl added in v0.1.3

type PodControl interface {
	// IsUpdatedPod checks if the pod revision is updated of the workload
	IsUpdatedPod(reader client.Reader, obj client.Object, pod *corev1.Pod) (bool, error)
	// GetPodSelector gets the pod selector of the workload
	GetPodSelector(obj client.Object) (labels.Selector, error)
}

type Set

type Set struct {
	// contains filtered or unexported fields
}

func NewSet added in v0.1.1

func NewSet(workloads ...*Info) *Set

func (*Set) Get

func (s *Set) Get(cluster, name string) *Info

func (*Set) ToSlice

func (s *Set) ToSlice() []*Info

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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