util

package
v3.11.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FailedRcCreateReason is added in a deployment config when it cannot create a new replication
	// controller.
	FailedRcCreateReason = "ReplicationControllerCreateError"
	// NewReplicationControllerReason is added in a deployment config when it creates a new replication
	// controller.
	NewReplicationControllerReason = "NewReplicationControllerCreated"
	// NewRcAvailableReason is added in a deployment config when its newest replication controller is made
	// available ie. the number of new pods that have passed readiness checks and run for at least
	// minReadySeconds is at least the minimum available pods that need to run for the deployment config.
	NewRcAvailableReason = "NewReplicationControllerAvailable"
	// TimedOutReason is added in a deployment config when its newest replication controller fails to show
	// any progress within the given deadline (progressDeadlineSeconds).
	TimedOutReason = "ProgressDeadlineExceeded"
	// PausedConfigReason is added in a deployment config when it is paused. Lack of progress shouldn't be
	// estimated once a deployment config is paused.
	PausedConfigReason = "DeploymentConfigPaused"
	// CancelledRolloutReason is added in a deployment config when its newest rollout was
	// interrupted by cancellation.
	CancelledRolloutReason = "RolloutCancelled"

	// DeploymentConfigLabel is the name of a label used to correlate a deployment with the
	DeploymentConfigLabel = "deploymentconfig"

	// DeploymentLabel is the name of a label used to correlate a deployment with the Pod created
	DeploymentLabel = "deployment"

	// MaxDeploymentDurationSeconds represents the maximum duration that a deployment is allowed to run.
	// This is set as the default value for ActiveDeadlineSeconds for the deployer pod.
	// Currently set to 6 hours.
	MaxDeploymentDurationSeconds int64 = 21600

	// DefaultRecreateTimeoutSeconds is the default TimeoutSeconds for RecreateDeploymentStrategyParams.
	// Used by strategies:
	DefaultRecreateTimeoutSeconds int64 = 10 * 60
	DefaultRollingTimeoutSeconds  int64 = 10 * 60

	// PreHookPodSuffix is the suffix added to all pre hook pods
	PreHookPodSuffix = "hook-pre"
	// MidHookPodSuffix is the suffix added to all mid hook pods
	MidHookPodSuffix = "hook-mid"
	// PostHookPodSuffix is the suffix added to all post hook pods
	PostHookPodSuffix = "hook-post"

	// DeploymentStatusReasonAnnotation represents the reason for deployment being in a given state
	// Used for specifying the reason for cancellation or failure of a deployment
	DeploymentIgnorePodAnnotation = "deploy.openshift.io/deployer-pod.ignore"
	DeploymentReplicasAnnotation  = "openshift.io/deployment.replicas"

	DeploymentFailedUnrelatedDeploymentExists = "unrelated pod with the same name as this deployment is already running"
	DeploymentFailedUnableToCreateDeployerPod = "unable to create deployer pod"
	DeploymentFailedDeployerPodNoLongerExists = "deployer pod no longer exists"
)

Variables

This section is empty.

Functions

func ActiveDeployment

func ActiveDeployment(input []*v1.ReplicationController) *v1.ReplicationController

ActiveDeployment returns the latest complete deployment, or nil if there is no such deployment. The active deployment is not always the same as the latest deployment.

func AnnotationFor

func AnnotationFor(obj runtime.Object, key string) string

AnnotationFor returns the annotation with key for obj.

func CanTransitionPhase

func CanTransitionPhase(current, next appsv1.DeploymentStatus) bool

CanTransitionPhase returns whether it is allowed to go from the current to the next phase.

func ConfigSelector

func ConfigSelector(name string) labels.Selector

ConfigSelector returns a label Selector which can be used to find all deployments for a DeploymentConfig.

TODO: Using the annotation constant for now since the value is correct but we could consider adding a new constant to the public types.

func DecodeDeploymentConfig

func DecodeDeploymentConfig(controller metav1.ObjectMetaAccessor) (*appsv1.DeploymentConfig, error)

DecodeDeploymentConfig decodes a DeploymentConfig from controller using annotation codec. An error is returned if the controller doesn't contain an encoded config or decoding fail.

func DeleteStatusReasons

func DeleteStatusReasons(rc *v1.ReplicationController)

func DeployerPodNameFor

func DeployerPodNameFor(obj runtime.Object) string

func DeployerPodNameForDeployment

func DeployerPodNameForDeployment(deployment string) string

DeployerPodNameForDeployment returns the name of a pod for a given deployment

func DeployerPodSelector

func DeployerPodSelector(name string) labels.Selector

DeployerPodSelector returns a label Selector which can be used to find all deployer pods associated with a deployment with name.

func DeploymentConfigNameFor

func DeploymentConfigNameFor(obj runtime.Object) string

func DeploymentDesiredReplicas

func DeploymentDesiredReplicas(obj runtime.Object) (int32, bool)

DeploymentDesiredReplicas returns number of desired replica for the given replication controller

func DeploymentNameFor

func DeploymentNameFor(obj runtime.Object) string

func DeploymentNameForConfigVersion

func DeploymentNameForConfigVersion(name string, version int64) string

DeploymentNameForConfigVersion returns the name of the version-th deployment for the config that has the provided name

func DeploymentStatusFor

func DeploymentStatusFor(deployment runtime.Object) appsv1.DeploymentStatus

func DeploymentStatusReasonFor

func DeploymentStatusReasonFor(obj runtime.Object) string

func DeploymentVersionFor

func DeploymentVersionFor(obj runtime.Object) int64

func DeploymentsForCleanup

func DeploymentsForCleanup(configuration *appsv1.DeploymentConfig, deployments []*v1.ReplicationController) []v1.ReplicationController

DeploymentsForCleanup determines which deployments for a configuration are relevant for the revision history limit quota

func GetAvailableReplicaCountForReplicationControllers

func GetAvailableReplicaCountForReplicationControllers(replicationControllers []*v1.ReplicationController) int32

GetAvailableReplicaCountForReplicationControllers returns the number of available pods corresponding to the given replication controller.

func GetDeploymentCondition

GetDeploymentCondition returns the condition with the provided type.

func GetReadyReplicaCountForReplicationControllers

func GetReadyReplicaCountForReplicationControllers(replicationControllers []*v1.ReplicationController) int32

GetReadyReplicaCountForReplicationControllers returns the number of ready pods corresponding to the given replication controller.

func GetReplicaCountForDeployments

func GetReplicaCountForDeployments(deployments []*v1.ReplicationController) int32

GetReplicaCountForDeployments returns the sum of all replicas for the given deployments.

func GetStatusReplicaCountForDeployments

func GetStatusReplicaCountForDeployments(deployments []*v1.ReplicationController) int32

GetStatusReplicaCountForDeployments returns the sum of the replicas reported in the status of the given deployments.

func GetTimeoutSecondsForStrategy

func GetTimeoutSecondsForStrategy(config *appsv1.DeploymentConfig) int64

GetTimeoutSecondsForStrategy returns the timeout in seconds defined in the deployment config strategy.

func HasChangeTrigger

func HasChangeTrigger(config *appsv1.DeploymentConfig) bool

HasChangeTrigger returns whether the provided deployment configuration has a config change trigger or not

func HasImageChangeTrigger

func HasImageChangeTrigger(config *appsv1.DeploymentConfig) bool

HasImageChangeTrigger returns whether the provided deployment configuration has an image change trigger or not.

func HasLastTriggeredImage

func HasLastTriggeredImage(config *appsv1.DeploymentConfig) bool

HasLastTriggeredImage returns whether all image change triggers in provided deployment configuration has the lastTriggerImage field set (iow. all images were updated for them). Returns false if deployment configuration has no image change trigger defined.

func HasLatestPodTemplate

func HasLatestPodTemplate(currentConfig *appsv1.DeploymentConfig, rc *v1.ReplicationController) (bool, string, error)

HasLatestPodTemplate checks for differences between current deployment config template and deployment config template encoded in the latest replication controller. If they are different it will return an string diff containing the change.

func HasSynced

func HasSynced(dc *appsv1.DeploymentConfig, generation int64) bool

HasSynced checks if the provided deployment config has been noticed by the deployment config controller.

func HasTrigger

func HasTrigger(config *appsv1.DeploymentConfig) bool

HasTrigger returns whether the provided deployment configuration has any trigger defined or not.

func HasUpdatedImages

func HasUpdatedImages(dc *appsv1.DeploymentConfig, rc *v1.ReplicationController) (bool, []string)

HasUpdatedImages indicates if the deployment configuration images were updated.

func IsCompleteDeployment

func IsCompleteDeployment(deployment runtime.Object) bool

IsCompleteDeployment returns true if the passed deployment is in state complete.

func IsDeploymentCancelled

func IsDeploymentCancelled(deployment runtime.Object) bool

func IsFailedDeployment

func IsFailedDeployment(deployment runtime.Object) bool

IsFailedDeployment returns true if the passed deployment failed.

func IsInitialDeployment

func IsInitialDeployment(config *appsv1.DeploymentConfig) bool

IsInitialDeployment returns whether the deployment configuration is the first version of this configuration.

func IsOwnedByConfig

func IsOwnedByConfig(obj metav1.Object) bool

IsOwnedByConfig checks whether the provided replication controller is part of a deployment configuration. TODO: Switch to use owner references once we got those working.

func IsProgressing

func IsProgressing(config *appsv1.DeploymentConfig, newStatus *appsv1.DeploymentConfigStatus) bool

IsProgressing expects a state deployment config and its updated status in order to determine if there is any progress.

func IsRollingConfig

func IsRollingConfig(config *appsv1.DeploymentConfig) bool

IsRollingConfig returns true if the strategy type is a rolling update.

func IsTerminatedDeployment

func IsTerminatedDeployment(deployment runtime.Object) bool

IsTerminatedDeployment returns true if the passed deployment has terminated (either complete or failed).

func LabelForDeployment

func LabelForDeployment(deployment *v1.ReplicationController) string

LabelForDeployment builds a string identifier for a Deployment.

func LabelForDeploymentConfig

func LabelForDeploymentConfig(config runtime.Object) string

LabelForDeploymentConfig builds a string identifier for a DeploymentConfig.

func LatestDeploymentInfo

func LatestDeploymentInfo(config *appsv1.DeploymentConfig, deployments []*v1.ReplicationController) (bool, *v1.ReplicationController)

LatestDeploymentInfo returns info about the latest deployment for a config, or nil if there is no latest deployment. The latest deployment is not always the same as the active deployment.

func LatestDeploymentNameForConfig

func LatestDeploymentNameForConfig(config *appsv1.DeploymentConfig) string

LatestDeploymentNameForConfig returns a stable identifier for deployment config

func LatestDeploymentNameForConfigAndVersion

func LatestDeploymentNameForConfigAndVersion(name string, version int64) string

LatestDeploymentNameForConfigAndVersion returns a stable identifier for config based on its version.

func MakeDeployment

func MakeDeployment(config *appsv1.DeploymentConfig) (*v1.ReplicationController, error)

MakeDeployment creates a deployment represented as a ReplicationController and based on the given DeploymentConfig. The controller replica count will be zero.

func MaxSurge

func MaxSurge(config appsv1.DeploymentConfig) int32

MaxSurge returns the maximum surge pods a rolling deployment config can take.

func MaxUnavailable

func MaxUnavailable(config *appsv1.DeploymentConfig) int32

MaxUnavailable returns the maximum unavailable pods a rolling deployment config can take.

func NewDeploymentCondition

func NewDeploymentCondition(condType appsv1.DeploymentConditionType, status v1.ConditionStatus, reason string, message string) *appsv1.DeploymentCondition

NewDeploymentCondition creates a new deployment condition.

func NewReplicationControllerScaleClient

func NewReplicationControllerScaleClient(client kubernetes.Interface) scaleclient.ScalesGetter

func NewReplicationControllerScaler

func NewReplicationControllerScaler(client kubernetes.Interface) kubectl.Scaler

func RecordConfigChangeCause

func RecordConfigChangeCause(config *appsv1.DeploymentConfig)

RecordConfigChangeCause sets a deployment config cause for config change.

func RecordImageChangeCauses

func RecordImageChangeCauses(config *appsv1.DeploymentConfig, imageNames []string)

RecordImageChangeCauses sets a deployment config cause for image change. It takes a list of changed images and record an cause for each image.

func RemoveDeploymentCondition

func RemoveDeploymentCondition(status *appsv1.DeploymentConfigStatus, condType appsv1.DeploymentConditionType)

RemoveDeploymentCondition removes the deployment condition with the provided type.

func ResolveFenceposts

func ResolveFenceposts(maxSurge, maxUnavailable *intstrutil.IntOrString, desired int32) (int32, int32, error)

ResolveFenceposts is copy from k8s deployment_utils to avoid unnecessary imports

func RolloutExceededTimeoutSeconds

func RolloutExceededTimeoutSeconds(config *appsv1.DeploymentConfig, latestRC *v1.ReplicationController) bool

RolloutExceededTimeoutSeconds returns true if the current deployment exceeded the timeoutSeconds defined for its strategy. Note that this is different than activeDeadlineSeconds which is the timeout set for the deployer pod. In some cases, the deployer pod cannot be created (like quota, etc...). In that case deployer controller use this function to measure if the created deployment (RC) exceeded the timeout.

func SetCancelledByNewerDeployment

func SetCancelledByNewerDeployment(rc *v1.ReplicationController)

func SetCancelledByUserReason

func SetCancelledByUserReason(rc *v1.ReplicationController)

func SetDeploymentCondition

func SetDeploymentCondition(status *appsv1.DeploymentConfigStatus, condition appsv1.DeploymentCondition)

SetDeploymentCondition updates the deployment to include the provided condition. 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.

func SetDeploymentLatestVersionAnnotation

func SetDeploymentLatestVersionAnnotation(rc *v1.ReplicationController, version string)

Types

type ByLatestVersionAsc

type ByLatestVersionAsc []*v1.ReplicationController

func (ByLatestVersionAsc) Len

func (d ByLatestVersionAsc) Len() int

func (ByLatestVersionAsc) Less

func (d ByLatestVersionAsc) Less(i, j int) bool

func (ByLatestVersionAsc) Swap

func (d ByLatestVersionAsc) Swap(i, j int)

type ByLatestVersionDesc

type ByLatestVersionDesc []*v1.ReplicationController

ByLatestVersionDesc sorts deployments by LatestVersion descending.

func (ByLatestVersionDesc) Len

func (d ByLatestVersionDesc) Len() int

func (ByLatestVersionDesc) Less

func (d ByLatestVersionDesc) Less(i, j int) bool

func (ByLatestVersionDesc) Swap

func (d ByLatestVersionDesc) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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