control

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildReleaseControlInfo

func BuildReleaseControlInfo(release *v1beta1.BatchRelease) string

BuildReleaseControlInfo return a NewControllerRef of release with escaped `"`.

func CalculateBatchReplicas

func CalculateBatchReplicas(release *v1beta1.BatchRelease, workloadReplicas, currentBatch int) int

CalculateBatchReplicas return the planned updated replicas of current batch.

func GenerateNotFoundError

func GenerateNotFoundError(name, resource string) error

GenerateNotFoundError return a not found error

func InitOriginalSetting added in v0.6.0

func InitOriginalSetting(setting *OriginalDeploymentStrategy, object client.Object)

InitOriginalSetting will update the original setting based on the workload object note: update the maxSurge and maxUnavailable only when MaxSurge and MaxUnavailable are nil, which means they should keep unchanged in continuous release (though continuous release isn't supported for now)

func IsControlledByBatchRelease

func IsControlledByBatchRelease(release *v1beta1.BatchRelease, object client.Object) bool

IsControlledByBatchRelease return true if * object ownerReference has referred release; * object has batchRelease control info annotation about release.

func IsCurrentMoreThanOrEqualToDesired

func IsCurrentMoreThanOrEqualToDesired(current, desired intstr.IntOrString) bool

IsCurrentMoreThanOrEqualToDesired return true if current >= desired

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%";

func ShouldWaitResume

func ShouldWaitResume(release *v1beta1.BatchRelease) bool

ShouldWaitResume return true if FinalizingPolicy is "waitResume".

func ValidateReadyForBlueGreenRelease added in v0.6.0

func ValidateReadyForBlueGreenRelease(object client.Object) error

only when IsReadyForBlueGreenRelease returns true, can we go on to the next batch

Types

type Interface

type Interface interface {
	// Initialize make sure that the resource is ready to be progressed.
	// this function is tasked to do any initialization work on the resources.
	// it returns nil if the preparation is succeeded, else the preparation should retry.
	Initialize() error

	// UpgradeBatch tries to upgrade old replicas according to the release plan.
	// it will upgrade the old replicas as the release plan allows in the current batch.
	// this function is tasked to do any initialization work on the resources.
	// it returns nil if the preparation is succeeded, else the preparation should retry.
	UpgradeBatch() error

	// CheckBatchReady checks how many replicas are ready to serve requests in the current batch.
	// this function is tasked to do any initialization work on the resources.
	// it returns nil if the preparation is succeeded, else the preparation should retry.
	CheckBatchReady() error

	// Finalize makes sure the resources are in a good final state.
	// this function is tasked to do any initialization work on the resources.
	// it returns nil if the preparation is succeeded, else the preparation should retry.
	Finalize() error

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

Interface is the interface that all type of control plane implements for rollout.

type OriginalDeploymentStrategy added in v0.6.0

type OriginalDeploymentStrategy struct {
	// +optional
	MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty" protobuf:"bytes,1,opt,name=maxUnavailable"`
	// +optional
	MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty" protobuf:"bytes,2,opt,name=maxSurge"`
	// Minimum number of seconds for which a newly created pod should be ready
	// without any of its container crashing, for it to be considered available.
	// Defaults to 0 (pod will be considered available as soon as it is ready)
	// +optional
	MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,5,opt,name=minReadySeconds"`
	// The maximum time in seconds for a deployment to make progress before it
	// is considered to be failed. The deployment controller will continue to
	// process failed deployments and a condition with a ProgressDeadlineExceeded
	// reason will be surfaced in the deployment status. Note that progress will
	// not be estimated during the time a deployment is paused. Defaults to 600s.
	ProgressDeadlineSeconds *int32 `json:"progressDeadlineSeconds,omitempty" protobuf:"varint,9,opt,name=progressDeadlineSeconds"`
}

OriginalDeploymentStrategy stores part of the fileds of a workload, so that it can be restored when finalizing. It is only used for BlueGreen Release Similar to DeploymentStrategy, it is an annotation used in workload However, unlike DeploymentStrategy, it is only used to store and restore the user's strategy

func GetOriginalSetting added in v0.6.0

func GetOriginalSetting(object client.Object) (OriginalDeploymentStrategy, error)

GetDeploymentStrategy decode the strategy object for advanced deployment from the annotation "rollouts.kruise.io/original-deployment-strategy"

type WorkloadEventType

type WorkloadEventType string
const (
	// WorkloadNormalState means workload is normal and event should be ignored.
	WorkloadNormalState WorkloadEventType = "workload-is-at-normal-state"
	// WorkloadUnknownState means workload state is unknown and should retry.
	WorkloadUnknownState WorkloadEventType = "workload-is-at-unknown-state"
	// 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"
	// WorkloadRollbackInBatch means workload is rollback according to BatchRelease batch plan.
	WorkloadRollbackInBatch WorkloadEventType = "workload-rollback-in-batch"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳