workloads

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 19 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, plan *v1alpha1.ReleasePlan, status *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) FinalizeOneBatch

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

FinalizeOneBatch isn't needed in this mode.

func (*CloneSetRolloutController) FinalizeProgress

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

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, plan *v1alpha1.ReleasePlan, status *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) FinalizeOneBatch

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

FinalizeOneBatch isn't needed in this mode.

func (*DeploymentsRolloutController) FinalizeProgress

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

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 WorkloadController

type WorkloadController interface {
	// VerifyWorkload makes sure that the workload can be upgraded according to the release plan.
	// it returns 'true', the controller will requeue the request and continue to reconcile after a short duration.
	// it returns 'false', the controller will not requeue the request.
	// if err == nil, if the verification is successful.
	// 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)

	// FinalizeOneBatch makes sure that the rollout can start the next batch
	// it returns 'true' if the operation is succeeded.
	// it returns 'false' if the operation should be retried.
	// it returns not-empty error if the check operation has something wrong, and should not retry.
	FinalizeOneBatch() (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

	// 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, *WorkloadInfo, error)
}

WorkloadController is the interface that all type of cloneSet controller implements

type WorkloadEventType

type WorkloadEventType string
const (
	IgnoreWorkloadEvent        WorkloadEventType = "workload-not-cared"
	WorkloadRollback           WorkloadEventType = "workload-is-rolling-back"
	WorkloadPodTemplateChanged WorkloadEventType = "workload-pod-template-changed"
	WorkloadReplicasChanged    WorkloadEventType = "workload-replicas-changed"
	WorkloadStillReconciling   WorkloadEventType = "workload-is-reconciling"
	WorkloadUnHealthy          WorkloadEventType = "workload-is-unhealthy"
)

type WorkloadInfo

type WorkloadInfo struct {
	Paused         bool
	Replicas       *int32
	UpdateRevision *string
	Status         *WorkloadStatus
	Metadata       *metav1.ObjectMeta
}

type WorkloadStatus

type WorkloadStatus struct {
	Replicas             int32
	ReadyReplicas        int32
	UpdatedReplicas      int32
	UpdatedReadyReplicas int32
	ObservedGeneration   int64
}

Jump to

Keyboard shortcuts

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