workloads

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateRealCanaryReplicasGoal

func CalculateRealCanaryReplicasGoal(expectedStableReplicas, allReplicas int32, canaryReplicas *intstr.IntOrString) int32

func ParseIntegerAsPercentageIfPossible

func ParseIntegerAsPercentageIfPossible(stableReplicas, allReplicas int32, canaryReplicas *intstr.IntOrString) intstr.IntOrString

ParseIntegerAsPercentageIfPossible will return a percentage type IntOrString, such as "20%", "33%", but "33.3%" is illegal. Given A, B, return P that should try best to satisfy ⌈P * B⌉ == A, and we ensure that the error is less than 1%. For examples: * Given stableReplicas 1, allReplicas 3, return "33%"; * Given stableReplicas 98, allReplicas 99, return "97%"; * Given stableReplicas 1, allReplicas 101, return "1";

Types

type CloneSetRolloutController

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

CloneSetRolloutController is responsible for handling rollout CloneSet type of workloads

func NewCloneSetRolloutController

func NewCloneSetRolloutController(cli client.Client, recorder record.EventRecorder, release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchReleaseStatus, targetNamespacedName types.NamespacedName) *CloneSetRolloutController

NewCloneSetRolloutController creates a new CloneSet rollout controller

func (*CloneSetRolloutController) CheckOneBatchReady

func (c *CloneSetRolloutController) CheckOneBatchReady() (bool, error)

CheckOneBatchReady checks to see if the pods are all available according to the rollout plan

func (*CloneSetRolloutController) FinalizeProgress

func (c *CloneSetRolloutController) FinalizeProgress(cleanup bool) (bool, error)

FinalizeProgress makes sure the CloneSet is all upgraded

func (*CloneSetRolloutController) PrepareBeforeProgress

func (c *CloneSetRolloutController) PrepareBeforeProgress() (bool, error)

PrepareBeforeProgress makes sure that the source and target CloneSet is under our control

func (*CloneSetRolloutController) SyncWorkloadInfo

SyncWorkloadInfo return change type if workload was changed during release

func (*CloneSetRolloutController) UpgradeOneBatch

func (c *CloneSetRolloutController) UpgradeOneBatch() (bool, error)

UpgradeOneBatch calculates the number of pods we can upgrade once according to the rollout spec and then set the partition accordingly

func (*CloneSetRolloutController) VerifyWorkload

func (c *CloneSetRolloutController) VerifyWorkload() (bool, error)

VerifyWorkload verifies that the workload is ready to execute release plan

type DeploymentsRolloutController

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

DeploymentsRolloutController is responsible for handling Deployment type of workloads

func NewDeploymentRolloutController

func NewDeploymentRolloutController(cli client.Client, recorder record.EventRecorder, release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchReleaseStatus, stableNamespacedName types.NamespacedName) *DeploymentsRolloutController

NewDeploymentRolloutController creates a new Deployment rollout controller

func (*DeploymentsRolloutController) CheckOneBatchReady

func (c *DeploymentsRolloutController) CheckOneBatchReady() (bool, error)

CheckOneBatchReady checks to see if the pods are all available according to the rollout plan

func (*DeploymentsRolloutController) FinalizeProgress

func (c *DeploymentsRolloutController) FinalizeProgress(cleanup bool) (bool, error)

FinalizeProgress makes sure restore deployments and clean up some canary settings

func (*DeploymentsRolloutController) GetStablePodTemplateHash

func (c *DeploymentsRolloutController) GetStablePodTemplateHash(deploy *apps.Deployment) (string, error)

GetStablePodTemplateHash returns latest/stable revision hash of deployment

func (*DeploymentsRolloutController) PrepareBeforeProgress

func (c *DeploymentsRolloutController) PrepareBeforeProgress() (bool, error)

PrepareBeforeProgress makes sure that the Deployment is under our control

func (*DeploymentsRolloutController) SyncWorkloadInfo

SyncWorkloadInfo return workloadInfo if workload info is changed during rollout TODO: abstract a WorkloadEventTypeJudge interface for these following `if` clauses

func (*DeploymentsRolloutController) UpgradeOneBatch

func (c *DeploymentsRolloutController) UpgradeOneBatch() (bool, error)

UpgradeOneBatch calculates the number of pods we can upgrade once according to the release plan and then set the canary deployment replicas

func (*DeploymentsRolloutController) VerifyWorkload

func (c *DeploymentsRolloutController) VerifyWorkload() (bool, error)

VerifyWorkload verifies that the workload is ready to execute release plan

type StatefulSetLikeController added in v0.2.0

type StatefulSetLikeController struct {
	client.Client
	// contains filtered or unexported fields
}

func (*StatefulSetLikeController) ClaimWorkload added in v0.2.0

func (c *StatefulSetLikeController) ClaimWorkload() (bool, error)

func (*StatefulSetLikeController) GetWorkloadInfo added in v0.2.0

func (c *StatefulSetLikeController) GetWorkloadInfo() (*util.WorkloadInfo, error)

func (*StatefulSetLikeController) GetWorkloadObject added in v0.2.0

func (c *StatefulSetLikeController) GetWorkloadObject() (*unstructured.Unstructured, error)

func (*StatefulSetLikeController) IsBatchReady added in v0.2.0

func (c *StatefulSetLikeController) IsBatchReady(canaryReplicasGoal, stableReplicasGoal int32) (bool, error)

func (*StatefulSetLikeController) ListOwnedPods added in v0.2.0

func (c *StatefulSetLikeController) ListOwnedPods() ([]*v1.Pod, error)

func (*StatefulSetLikeController) ReleaseWorkload added in v0.2.0

func (c *StatefulSetLikeController) ReleaseWorkload(cleanup bool) (bool, error)

func (*StatefulSetLikeController) UpgradeBatch added in v0.2.0

func (c *StatefulSetLikeController) UpgradeBatch(canaryReplicasGoal, stableReplicasGoal int32) (bool, error)

type UnifiedWorkloadController added in v0.2.0

type UnifiedWorkloadController interface {
	GetWorkloadInfo() (*util.WorkloadInfo, error)
	ClaimWorkload() (bool, error)
	ReleaseWorkload(cleanup bool) (bool, error)
	UpgradeBatch(canaryReplicasGoal, stableReplicasGoal int32) (bool, error)
	IsBatchReady(canaryReplicasGoal, stableReplicasGoal int32) (bool, error)
	ListOwnedPods() ([]*v1.Pod, error)
}

type UnifiedWorkloadRolloutControlPlane added in v0.2.0

type UnifiedWorkloadRolloutControlPlane struct {
	UnifiedWorkloadController
	// contains filtered or unexported fields
}

UnifiedWorkloadRolloutControlPlane is responsible for handling rollout StatefulSet type of workloads

func NewUnifiedWorkloadRolloutControlPlane added in v0.2.0

NewUnifiedWorkloadRolloutControlPlane creates a new workload rollout controller

func (*UnifiedWorkloadRolloutControlPlane) CheckOneBatchReady added in v0.2.0

func (c *UnifiedWorkloadRolloutControlPlane) CheckOneBatchReady() (bool, error)

CheckOneBatchReady checks to see if the pods are all available according to the rollout plan

func (*UnifiedWorkloadRolloutControlPlane) FinalizeProgress added in v0.2.0

func (c *UnifiedWorkloadRolloutControlPlane) FinalizeProgress(cleanup bool) (bool, error)

FinalizeProgress makes sure the workload is all upgraded

func (*UnifiedWorkloadRolloutControlPlane) PrepareBeforeProgress added in v0.2.0

func (c *UnifiedWorkloadRolloutControlPlane) PrepareBeforeProgress() (bool, error)

PrepareBeforeProgress makes sure that the source and target workload is under our control

func (*UnifiedWorkloadRolloutControlPlane) RecordWorkloadRevisionAndReplicas added in v0.2.0

func (c *UnifiedWorkloadRolloutControlPlane) RecordWorkloadRevisionAndReplicas() error

func (*UnifiedWorkloadRolloutControlPlane) SyncWorkloadInfo added in v0.2.0

SyncWorkloadInfo return change type if workload was changed during release

func (*UnifiedWorkloadRolloutControlPlane) UpgradeOneBatch added in v0.2.0

func (c *UnifiedWorkloadRolloutControlPlane) UpgradeOneBatch() (bool, error)

UpgradeOneBatch calculates the number of pods we can upgrade once according to the rollout spec and then set the partition accordingly

func (*UnifiedWorkloadRolloutControlPlane) VerifyWorkload added in v0.2.0

func (c *UnifiedWorkloadRolloutControlPlane) VerifyWorkload() (bool, error)

VerifyWorkload verifies that the workload is ready to execute release plan

type WorkloadController

type WorkloadController interface {
	// VerifyWorkload makes sure that the workload can be upgraded according to the release plan.
	// it returns 'true', if this verification is successful.
	// it returns 'false' or err != nil, if this verification is failed.
	// it returns not-empty error if the verification has something wrong, and should not retry.
	VerifyWorkload() (bool, error)

	// PrepareBeforeProgress make sure that the resource is ready to be progressed.
	// this function is tasked to do any initialization work on the resources.
	// it returns 'true' if the preparation is succeeded.
	// it returns 'false' if the preparation should retry.
	// it returns not-empty error if the preparation has something wrong, and should not retry.
	PrepareBeforeProgress() (bool, error)

	// UpgradeOneBatch tries to upgrade old replicas following the release plan.
	// it will upgrade the old replicas as the release plan allows in the current batch.
	// it returns 'true' if the progress is succeeded.
	// it returns 'false' if the progress should retry.
	// it returns not-empty error if the progress has something wrong, and should not retry.
	UpgradeOneBatch() (bool, error)

	// CheckOneBatchReady checks how many replicas are ready to serve requests in the current batch.
	// it returns 'true' if the batch has been ready.
	// it returns 'false' if the batch should be reset and recheck.
	// it returns not-empty error if the check operation has something wrong, and should not retry.
	CheckOneBatchReady() (bool, error)

	// FinalizeProgress makes sure the resources are in a good final state.
	// It might depend on if the rollout succeeded or not.
	// For example, we may remove the objects which created by batchRelease.
	// this function will always retry util it returns 'true'.
	// parameters:
	// - pause: 'nil' means keep current state, 'true' means pause workload, 'false' means do not pause workload
	// - cleanup: 'true' means clean up canary settings, 'false' means do not clean up.
	FinalizeProgress(cleanup bool) (bool, error)

	// SyncWorkloadInfo will watch and compare the status recorded in BatchRelease.Status
	// and the real-time workload info. If workload status is inconsistent with that recorded
	// in release.status, will return the corresponding WorkloadEventType and info.
	SyncWorkloadInfo() (WorkloadEventType, *util.WorkloadInfo, error)
}

WorkloadController is the interface that all type of cloneSet controller implements

type WorkloadEventType

type WorkloadEventType string
const (
	// IgnoreWorkloadEvent means workload event should be ignored.
	IgnoreWorkloadEvent WorkloadEventType = "workload-event-ignore"
	// WorkloadPodTemplateChanged means workload revision changed, should be stopped to execute batch release plan.
	WorkloadPodTemplateChanged WorkloadEventType = "workload-pod-template-changed"
	// WorkloadReplicasChanged means workload is scaling during rollout, should recalculate upgraded pods in current batch.
	WorkloadReplicasChanged WorkloadEventType = "workload-replicas-changed"
	// WorkloadStillReconciling means workload status is untrusted Untrustworthy, we should wait workload controller to reconcile.
	WorkloadStillReconciling WorkloadEventType = "workload-is-reconciling"
	// WorkloadHasGone means workload is deleted during rollout, we should do something finalizing works if this event occurs.
	WorkloadHasGone WorkloadEventType = "workload-has-gone"
	// WorkloadUnHealthy means workload is at some unexpected state that our controller cannot handle, we should stop reconcile.
	WorkloadUnHealthy WorkloadEventType = "workload-is-unhealthy"
)

Jump to

Keyboard shortcuts

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