switch from godep to glide

This commit is contained in:
Tomas Kral
2016-12-07 19:57:19 +01:00
parent 862419b836
commit fe679fbca6
861 changed files with 16916 additions and 81678 deletions
+7
View File
@@ -49,6 +49,13 @@ func ScaleFromConfig(dc *DeploymentConfig) *extensions.Scale {
}
}
// RequestForConfig builds a new deployment request for a deployment config.
func RequestForConfig(dc *DeploymentConfig) *DeploymentRequest {
return &DeploymentRequest{
Name: dc.Name,
}
}
// TemplateImage is a structure for helping a caller iterate over a PodSpec
type TemplateImage struct {
Image string
+2
View File
@@ -32,6 +32,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&DeploymentConfig{},
&DeploymentConfigList{},
&DeploymentConfigRollback{},
&DeploymentRequest{},
&DeploymentLog{},
&DeploymentLogOptions{},
)
@@ -41,5 +42,6 @@ func addKnownTypes(scheme *runtime.Scheme) error {
func (obj *DeploymentConfig) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *DeploymentConfigList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *DeploymentConfigRollback) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *DeploymentRequest) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *DeploymentLog) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *DeploymentLogOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
+251 -208
View File
@@ -6,181 +6,7 @@ import (
"k8s.io/kubernetes/pkg/util/intstr"
)
// DeploymentStatus describes the possible states a deployment can be in.
type DeploymentStatus string
const (
// DeploymentStatusNew means the deployment has been accepted but not yet acted upon.
DeploymentStatusNew DeploymentStatus = "New"
// DeploymentStatusPending means the deployment been handed over to a deployment strategy,
// but the strategy has not yet declared the deployment to be running.
DeploymentStatusPending DeploymentStatus = "Pending"
// DeploymentStatusRunning means the deployment strategy has reported the deployment as
// being in-progress.
DeploymentStatusRunning DeploymentStatus = "Running"
// DeploymentStatusComplete means the deployment finished without an error.
DeploymentStatusComplete DeploymentStatus = "Complete"
// DeploymentStatusFailed means the deployment finished with an error.
DeploymentStatusFailed DeploymentStatus = "Failed"
)
// DeploymentStrategy describes how to perform a deployment.
type DeploymentStrategy struct {
// Type is the name of a deployment strategy.
Type DeploymentStrategyType
// RecreateParams are the input to the Recreate deployment strategy.
RecreateParams *RecreateDeploymentStrategyParams
// RollingParams are the input to the Rolling deployment strategy.
RollingParams *RollingDeploymentStrategyParams
// CustomParams are the input to the Custom deployment strategy, and may also
// be specified for the Recreate and Rolling strategies to customize the execution
// process that runs the deployment.
CustomParams *CustomDeploymentStrategyParams
// Resources contains resource requirements to execute the deployment
Resources kapi.ResourceRequirements
// Labels is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
Labels map[string]string
// Annotations is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
Annotations map[string]string
}
// DeploymentStrategyType refers to a specific DeploymentStrategy implementation.
type DeploymentStrategyType string
const (
// DeploymentStrategyTypeRecreate is a simple strategy suitable as a default.
DeploymentStrategyTypeRecreate DeploymentStrategyType = "Recreate"
// DeploymentStrategyTypeCustom is a user defined strategy. It is optional to set.
DeploymentStrategyTypeCustom DeploymentStrategyType = "Custom"
// DeploymentStrategyTypeRolling uses the Kubernetes RollingUpdater.
DeploymentStrategyTypeRolling DeploymentStrategyType = "Rolling"
)
// CustomDeploymentStrategyParams are the input to the Custom deployment strategy.
type CustomDeploymentStrategyParams struct {
// Image specifies a Docker image which can carry out a deployment.
Image string
// Environment holds the environment which will be given to the container for Image.
Environment []kapi.EnvVar
// Command is optional and overrides CMD in the container Image.
Command []string
}
// RecreateDeploymentStrategyParams are the input to the Recreate deployment
// strategy.
type RecreateDeploymentStrategyParams struct {
// TimeoutSeconds is the time to wait for updates before giving up. If the
// value is nil, a default will be used.
TimeoutSeconds *int64
// Pre is a lifecycle hook which is executed before the strategy manipulates
// the deployment. All LifecycleHookFailurePolicy values are supported.
Pre *LifecycleHook
// Mid is a lifecycle hook which is executed while the deployment is scaled down to zero before the first new
// pod is created. All LifecycleHookFailurePolicy values are supported.
Mid *LifecycleHook
// Post is a lifecycle hook which is executed after the strategy has
// finished all deployment logic.
Post *LifecycleHook
}
// LifecycleHook defines a specific deployment lifecycle action. Only one type of action may be specified at any time.
type LifecycleHook struct {
// FailurePolicy specifies what action to take if the hook fails.
FailurePolicy LifecycleHookFailurePolicy
// ExecNewPod specifies the options for a lifecycle hook backed by a pod.
ExecNewPod *ExecNewPodHook
// TagImages instructs the deployer to tag the current image referenced under a container onto an image stream tag if the deployment succeeds.
TagImages []TagImageHook
}
// LifecycleHookFailurePolicy describes possibles actions to take if a hook fails.
type LifecycleHookFailurePolicy string
const (
// LifecycleHookFailurePolicyRetry means retry the hook until it succeeds.
LifecycleHookFailurePolicyRetry LifecycleHookFailurePolicy = "Retry"
// LifecycleHookFailurePolicyAbort means abort the deployment (if possible).
LifecycleHookFailurePolicyAbort LifecycleHookFailurePolicy = "Abort"
// LifecycleHookFailurePolicyIgnore means ignore failure and continue the deployment.
LifecycleHookFailurePolicyIgnore LifecycleHookFailurePolicy = "Ignore"
)
// ExecNewPodHook is a hook implementation which runs a command in a new pod
// based on the specified container which is assumed to be part of the
// deployment template.
type ExecNewPodHook struct {
// Command is the action command and its arguments.
Command []string
// Env is a set of environment variables to supply to the hook pod's container.
Env []kapi.EnvVar
// ContainerName is the name of a container in the deployment pod template
// whose Docker image will be used for the hook pod's container.
ContainerName string
// Volumes is a list of named volumes from the pod template which should be
// copied to the hook pod.
Volumes []string
}
// TagImageHook is a request to tag the image in a particular container onto an ImageStreamTag.
type TagImageHook struct {
// ContainerName is the name of a container in the deployment config whose image value will be used as the source of the tag
ContainerName string
// To is the target ImageStreamTag to set the image of
To kapi.ObjectReference
}
// RollingDeploymentStrategyParams are the input to the Rolling deployment
// strategy.
type RollingDeploymentStrategyParams struct {
// UpdatePeriodSeconds is the time to wait between individual pod updates.
// If the value is nil, a default will be used.
UpdatePeriodSeconds *int64
// IntervalSeconds is the time to wait between polling deployment status
// after update. If the value is nil, a default will be used.
IntervalSeconds *int64
// TimeoutSeconds is the time to wait for updates before giving up. If the
// value is nil, a default will be used.
TimeoutSeconds *int64
// The maximum number of pods that can be unavailable during the update.
// Value can be an absolute number (ex: 5) or a percentage of total pods at the start of update (ex: 10%).
// Absolute number is calculated from percentage by rounding up.
// This can not be 0 if MaxSurge is 0.
// By default, a fixed value of 1 is used.
// Example: when this is set to 30%, the old RC can be scaled down by 30%
// immediately when the rolling update starts. Once new pods are ready, old RC
// can be scaled down further, followed by scaling up the new RC, ensuring
// that at least 70% of original number of pods are available at all times
// during the update.
MaxUnavailable intstr.IntOrString
// The maximum number of pods that can be scheduled above the original number of
// pods.
// Value can be an absolute number (ex: 5) or a percentage of total pods at
// the start of the update (ex: 10%). This can not be 0 if MaxUnavailable is 0.
// Absolute number is calculated from percentage by rounding up.
// By default, a value of 1 is used.
// Example: when this is set to 30%, the new RC can be scaled up by 30%
// immediately when the rolling update starts. Once old pods have been killed,
// new RC can be scaled up further, ensuring that total number of pods running
// at any time during the update is atmost 130% of original pods.
MaxSurge intstr.IntOrString
// UpdatePercent is the percentage of replicas to scale up or down each
// interval. If nil, one replica will be scaled up and down each interval.
// If negative, the scale order will be down/up instead of up/down.
// DEPRECATED: Use MaxUnavailable/MaxSurge instead.
UpdatePercent *int32
// Pre is a lifecycle hook which is executed before the deployment process
// begins. All LifecycleHookFailurePolicy values are supported.
Pre *LifecycleHook
// Post is a lifecycle hook which is executed after the strategy has
// finished all deployment logic.
Post *LifecycleHook
}
// These constants represent defaults used in the deployment process.
const (
// DefaultRollingTimeoutSeconds is the default TimeoutSeconds for RollingDeploymentStrategyParams.
DefaultRollingTimeoutSeconds int64 = 10 * 60
@@ -188,6 +14,10 @@ const (
DefaultRollingIntervalSeconds int64 = 1
// DefaultRollingUpdatePeriodSeconds is the default PeriodSeconds for RollingDeploymentStrategyParams.
DefaultRollingUpdatePeriodSeconds int64 = 1
// 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
)
// These constants represent keys used for correlating objects related to deployments.
@@ -253,6 +83,13 @@ const (
PostHookPodSuffix = "hook-post"
)
// These constants represent values used in deployment annotations.
const (
// DeploymentCancelledAnnotationValue represents the value for the DeploymentCancelledAnnotation
// annotation that signifies that the deployment should be cancelled
DeploymentCancelledAnnotationValue = "true"
)
// These constants represent the various reasons for cancelling a deployment
// or for a deployment being placed in a failed state
const (
@@ -262,18 +99,23 @@ const (
DeploymentFailedDeployerPodNoLongerExists = "deployer pod no longer exists"
)
// 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
const MaxDeploymentDurationSeconds int64 = 21600
// DeploymentStatus describes the possible states a deployment can be in.
type DeploymentStatus string
// DeploymentCancelledAnnotationValue represents the value for the DeploymentCancelledAnnotation
// annotation that signifies that the deployment should be cancelled
const DeploymentCancelledAnnotationValue = "true"
// DeploymentInstantiatedAnnotationValue represents the value for the DeploymentInstantiatedAnnotation
// annotation that signifies that the deployment should be instantiated.
const DeploymentInstantiatedAnnotationValue = "true"
const (
// DeploymentStatusNew means the deployment has been accepted but not yet acted upon.
DeploymentStatusNew DeploymentStatus = "New"
// DeploymentStatusPending means the deployment been handed over to a deployment strategy,
// but the strategy has not yet declared the deployment to be running.
DeploymentStatusPending DeploymentStatus = "Pending"
// DeploymentStatusRunning means the deployment strategy has reported the deployment as
// being in-progress.
DeploymentStatusRunning DeploymentStatus = "Running"
// DeploymentStatusComplete means the deployment finished without an error.
DeploymentStatusComplete DeploymentStatus = "Complete"
// DeploymentStatusFailed means the deployment finished with an error.
DeploymentStatusFailed DeploymentStatus = "Failed"
)
// +genclient=true
@@ -331,25 +173,162 @@ type DeploymentConfigSpec struct {
Template *kapi.PodTemplateSpec
}
// DeploymentConfigStatus represents the current deployment state.
type DeploymentConfigStatus struct {
// LatestVersion is used to determine whether the current deployment associated with a deployment
// config is out of sync.
LatestVersion int64
// ObservedGeneration is the most recent generation observed by the deployment config controller.
ObservedGeneration int64
// Replicas is the total number of pods targeted by this deployment config.
Replicas int32
// UpdatedReplicas is the total number of non-terminated pods targeted by this deployment config
// that have the desired template spec.
UpdatedReplicas int32
// AvailableReplicas is the total number of available pods targeted by this deployment config.
AvailableReplicas int32
// UnavailableReplicas is the total number of unavailable pods targeted by this deployment config.
UnavailableReplicas int32
// Details are the reasons for the update to this deployment config.
// This could be based on a change made by the user or caused by an automatic trigger
Details *DeploymentDetails
// DeploymentStrategy describes how to perform a deployment.
type DeploymentStrategy struct {
// Type is the name of a deployment strategy.
Type DeploymentStrategyType
// CustomParams are the input to the Custom deployment strategy, and may also
// be specified for the Recreate and Rolling strategies to customize the execution
// process that runs the deployment.
CustomParams *CustomDeploymentStrategyParams
// RecreateParams are the input to the Recreate deployment strategy.
RecreateParams *RecreateDeploymentStrategyParams
// RollingParams are the input to the Rolling deployment strategy.
RollingParams *RollingDeploymentStrategyParams
// Resources contains resource requirements to execute the deployment and any hooks.
Resources kapi.ResourceRequirements
// Labels is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
Labels map[string]string
// Annotations is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
Annotations map[string]string
}
// DeploymentStrategyType refers to a specific DeploymentStrategy implementation.
type DeploymentStrategyType string
const (
// DeploymentStrategyTypeRecreate is a simple strategy suitable as a default.
DeploymentStrategyTypeRecreate DeploymentStrategyType = "Recreate"
// DeploymentStrategyTypeCustom is a user defined strategy.
DeploymentStrategyTypeCustom DeploymentStrategyType = "Custom"
// DeploymentStrategyTypeRolling uses the Kubernetes RollingUpdater.
DeploymentStrategyTypeRolling DeploymentStrategyType = "Rolling"
)
// CustomDeploymentStrategyParams are the input to the Custom deployment strategy.
type CustomDeploymentStrategyParams struct {
// Image specifies a Docker image which can carry out a deployment.
Image string
// Environment holds the environment which will be given to the container for Image.
Environment []kapi.EnvVar
// Command is optional and overrides CMD in the container Image.
Command []string
}
// RecreateDeploymentStrategyParams are the input to the Recreate deployment
// strategy.
type RecreateDeploymentStrategyParams struct {
// TimeoutSeconds is the time to wait for updates before giving up. If the
// value is nil, a default will be used.
TimeoutSeconds *int64
// Pre is a lifecycle hook which is executed before the strategy manipulates
// the deployment. All LifecycleHookFailurePolicy values are supported.
Pre *LifecycleHook
// Mid is a lifecycle hook which is executed while the deployment is scaled down to zero before the first new
// pod is created. All LifecycleHookFailurePolicy values are supported.
Mid *LifecycleHook
// Post is a lifecycle hook which is executed after the strategy has
// finished all deployment logic. All LifecycleHookFailurePolicy values are supported.
Post *LifecycleHook
}
// RollingDeploymentStrategyParams are the input to the Rolling deployment
// strategy.
type RollingDeploymentStrategyParams struct {
// UpdatePeriodSeconds is the time to wait between individual pod updates.
// If the value is nil, a default will be used.
UpdatePeriodSeconds *int64
// IntervalSeconds is the time to wait between polling deployment status
// after update. If the value is nil, a default will be used.
IntervalSeconds *int64
// TimeoutSeconds is the time to wait for updates before giving up. If the
// value is nil, a default will be used.
TimeoutSeconds *int64
// MaxUnavailable is the maximum number of pods that can be unavailable
// during the update. Value can be an absolute number (ex: 5) or a
// percentage of total pods at the start of update (ex: 10%). Absolute
// number is calculated from percentage by rounding up.
//
// This cannot be 0 if MaxSurge is 0. By default, 25% is used.
//
// Example: when this is set to 30%, the old RC can be scaled down by 30%
// immediately when the rolling update starts. Once new pods are ready, old
// RC can be scaled down further, followed by scaling up the new RC,
// ensuring that at least 70% of original number of pods are available at
// all times during the update.
MaxUnavailable intstr.IntOrString
// MaxSurge is the maximum number of pods that can be scheduled above the
// original number of pods. Value can be an absolute number (ex: 5) or a
// percentage of total pods at the start of the update (ex: 10%). Absolute
// number is calculated from percentage by rounding up.
//
// This cannot be 0 if MaxUnavailable is 0. By default, 25% is used.
//
// Example: when this is set to 30%, the new RC can be scaled up by 30%
// immediately when the rolling update starts. Once old pods have been
// killed, new RC can be scaled up further, ensuring that total number of
// pods running at any time during the update is atmost 130% of original
// pods.
MaxSurge intstr.IntOrString
// Pre is a lifecycle hook which is executed before the deployment process
// begins. All LifecycleHookFailurePolicy values are supported.
Pre *LifecycleHook
// Post is a lifecycle hook which is executed after the strategy has
// finished all deployment logic. All LifecycleHookFailurePolicy values
// are supported.
Post *LifecycleHook
}
// LifecycleHook defines a specific deployment lifecycle action. Only one type of action may be specified at any time.
type LifecycleHook struct {
// FailurePolicy specifies what action to take if the hook fails.
FailurePolicy LifecycleHookFailurePolicy
// ExecNewPod specifies the options for a lifecycle hook backed by a pod.
ExecNewPod *ExecNewPodHook
// TagImages instructs the deployer to tag the current image referenced under a container onto an image stream tag.
TagImages []TagImageHook
}
// LifecycleHookFailurePolicy describes possibles actions to take if a hook fails.
type LifecycleHookFailurePolicy string
const (
// LifecycleHookFailurePolicyRetry means retry the hook until it succeeds.
LifecycleHookFailurePolicyRetry LifecycleHookFailurePolicy = "Retry"
// LifecycleHookFailurePolicyAbort means abort the deployment.
LifecycleHookFailurePolicyAbort LifecycleHookFailurePolicy = "Abort"
// LifecycleHookFailurePolicyIgnore means ignore failure and continue the deployment.
LifecycleHookFailurePolicyIgnore LifecycleHookFailurePolicy = "Ignore"
)
// ExecNewPodHook is a hook implementation which runs a command in a new pod
// based on the specified container which is assumed to be part of the
// deployment template.
type ExecNewPodHook struct {
// Command is the action command and its arguments.
Command []string
// Env is a set of environment variables to supply to the hook pod's container.
Env []kapi.EnvVar
// ContainerName is the name of a container in the deployment pod template
// whose Docker image will be used for the hook pod's container.
ContainerName string
// Volumes is a list of named volumes from the pod template which should be
// copied to the hook pod. Volumes names not found in pod spec are ignored.
// An empty list means no volumes will be copied.
Volumes []string
}
// TagImageHook is a request to tag the image in a particular container onto an ImageStreamTag.
type TagImageHook struct {
// ContainerName is the name of a container in the deployment config whose image value will be used as the source of the tag. If there is only a single
// container this value will be defaulted to the name of that container.
ContainerName string
// To is the target ImageStreamTag to set the container's image onto.
To kapi.ObjectReference
}
// DeploymentTriggerPolicy describes a policy for a single trigger that results in a new deployment.
@@ -377,9 +356,7 @@ const (
// DeploymentTriggerImageChangeParams represents the parameters to the ImageChange trigger.
type DeploymentTriggerImageChangeParams struct {
// Automatic means that the detection of a new tag value should result in an image update
// inside the pod template. Deployment configs that haven't been deployed yet will always
// have their images updated. Deployment configs that have been deployed at least once, will
// have their images updated only if this is set to true.
// inside the pod template.
Automatic bool
// ContainerNames is used to restrict tag updates to the specified set of container names in a pod.
ContainerNames []string
@@ -391,6 +368,29 @@ type DeploymentTriggerImageChangeParams struct {
LastTriggeredImage string
}
// DeploymentConfigStatus represents the current deployment state.
type DeploymentConfigStatus struct {
// LatestVersion is used to determine whether the current deployment associated with a deployment
// config is out of sync.
LatestVersion int64
// ObservedGeneration is the most recent generation observed by the deployment config controller.
ObservedGeneration int64
// Replicas is the total number of pods targeted by this deployment config.
Replicas int32
// UpdatedReplicas is the total number of non-terminated pods targeted by this deployment config
// that have the desired template spec.
UpdatedReplicas int32
// AvailableReplicas is the total number of available pods targeted by this deployment config.
AvailableReplicas int32
// UnavailableReplicas is the total number of unavailable pods targeted by this deployment config.
UnavailableReplicas int32
// Details are the reasons for the update to this deployment config.
// This could be based on a change made by the user or caused by an automatic trigger
Details *DeploymentDetails
// Conditions represents the latest available observations of a deployment config's current state.
Conditions []DeploymentCondition
}
// DeploymentDetails captures information about the causes of a deployment.
type DeploymentDetails struct {
// Message is the user specified change message, if this deployment was triggered manually by the user
@@ -414,6 +414,37 @@ type DeploymentCauseImageTrigger struct {
From kapi.ObjectReference
}
type DeploymentConditionType string
// These are valid conditions of a deployment config.
const (
// DeploymentAvailable means the deployment config is available, ie. at least the minimum available
// replicas required are up and running for at least minReadySeconds.
DeploymentAvailable DeploymentConditionType = "Available"
// DeploymentProgressing means the deployment config is progressing. Progress for a deployment
// config is considered when a new replica set is created or adopted, and when new pods scale up or
// old pods scale down. Progress is not estimated for paused deployment configs, when the deployment
// config needs to rollback, or when progressDeadlineSeconds is not specified.
DeploymentProgressing DeploymentConditionType = "Progressing"
// DeploymentReplicaFailure is added in a deployment config when one of its pods
// fails to be created or deleted.
DeploymentReplicaFailure DeploymentConditionType = "ReplicaFailure"
)
// DeploymentCondition describes the state of a deployment config at a certain point.
type DeploymentCondition struct {
// Type of deployment condition.
Type DeploymentConditionType
// Status of the condition, one of True, False, Unknown.
Status kapi.ConditionStatus
// The last time the condition transitioned from one status to another.
LastTransitionTime unversioned.Time
// The reason for the condition's last transition.
Reason string
// A human readable message indicating details about the transition.
Message string
}
// DeploymentConfigList is a collection of deployment configs.
type DeploymentConfigList struct {
unversioned.TypeMeta
@@ -450,6 +481,18 @@ type DeploymentConfigRollbackSpec struct {
IncludeStrategy bool
}
// DeploymentRequest is a request to a deployment config for a new deployment.
type DeploymentRequest struct {
unversioned.TypeMeta
// Name of the deployment config for requesting a new deployment.
Name string
// Latest will update the deployment config with the latest state from all triggers.
Latest bool
// Force will try to force a new deployment to run. If the deployment config is paused,
// then setting this to true will return an Invalid error.
Force bool
}
// DeploymentLog represents the logs for a deployment
type DeploymentLog struct {
unversioned.TypeMeta
+8 -27
View File
@@ -1,8 +1,6 @@
package v1
import (
"fmt"
"math"
"reflect"
"strings"
@@ -60,7 +58,6 @@ func Convert_v1_RollingDeploymentStrategyParams_To_api_RollingDeploymentStrategy
out.UpdatePeriodSeconds = in.UpdatePeriodSeconds
out.IntervalSeconds = in.IntervalSeconds
out.TimeoutSeconds = in.TimeoutSeconds
out.UpdatePercent = in.UpdatePercent
if in.Pre != nil {
if err := s.Convert(&in.Pre, &out.Pre, 0); err != nil {
@@ -72,18 +69,12 @@ func Convert_v1_RollingDeploymentStrategyParams_To_api_RollingDeploymentStrategy
return err
}
}
if in.UpdatePercent != nil {
pct := intstr.FromString(fmt.Sprintf("%d%%", int(math.Abs(float64(*in.UpdatePercent)))))
if *in.UpdatePercent > 0 {
out.MaxSurge = pct
} else {
out.MaxUnavailable = pct
}
} else {
if in.MaxUnavailable != nil {
if err := s.Convert(in.MaxUnavailable, &out.MaxUnavailable, 0); err != nil {
return err
}
}
if in.MaxSurge != nil {
if err := s.Convert(in.MaxSurge, &out.MaxSurge, 0); err != nil {
return err
}
@@ -95,7 +86,6 @@ func Convert_api_RollingDeploymentStrategyParams_To_v1_RollingDeploymentStrategy
out.UpdatePeriodSeconds = in.UpdatePeriodSeconds
out.IntervalSeconds = in.IntervalSeconds
out.TimeoutSeconds = in.TimeoutSeconds
out.UpdatePercent = in.UpdatePercent
if in.Pre != nil {
if err := s.Convert(&in.Pre, &out.Pre, 0); err != nil {
@@ -114,20 +104,11 @@ func Convert_api_RollingDeploymentStrategyParams_To_v1_RollingDeploymentStrategy
if out.MaxSurge == nil {
out.MaxSurge = &intstr.IntOrString{}
}
if in.UpdatePercent != nil {
pct := intstr.FromString(fmt.Sprintf("%d%%", int(math.Abs(float64(*in.UpdatePercent)))))
if *in.UpdatePercent > 0 {
out.MaxSurge = &pct
} else {
out.MaxUnavailable = &pct
}
} else {
if err := s.Convert(&in.MaxUnavailable, out.MaxUnavailable, 0); err != nil {
return err
}
if err := s.Convert(&in.MaxSurge, out.MaxSurge, 0); err != nil {
return err
}
if err := s.Convert(&in.MaxUnavailable, out.MaxUnavailable, 0); err != nil {
return err
}
if err := s.Convert(&in.MaxSurge, out.MaxSurge, 0); err != nil {
return err
}
return nil
}
+19 -10
View File
@@ -71,6 +71,7 @@ func SetDefaults_RecreateDeploymentStrategyParams(obj *RecreateDeploymentStrateg
obj.TimeoutSeconds = mkintp(deployapi.DefaultRollingTimeoutSeconds)
}
}
func SetDefaults_RollingDeploymentStrategyParams(obj *RollingDeploymentStrategyParams) {
if obj.IntervalSeconds == nil {
obj.IntervalSeconds = mkintp(deployapi.DefaultRollingIntervalSeconds)
@@ -84,16 +85,24 @@ func SetDefaults_RollingDeploymentStrategyParams(obj *RollingDeploymentStrategyP
obj.TimeoutSeconds = mkintp(deployapi.DefaultRollingTimeoutSeconds)
}
if obj.UpdatePercent == nil {
// Apply defaults.
if obj.MaxUnavailable == nil {
maxUnavailable := intstr.FromString("25%")
obj.MaxUnavailable = &maxUnavailable
}
if obj.MaxSurge == nil {
maxSurge := intstr.FromString("25%")
obj.MaxSurge = &maxSurge
}
if obj.MaxUnavailable == nil && obj.MaxSurge == nil {
maxUnavailable := intstr.FromString("25%")
obj.MaxUnavailable = &maxUnavailable
maxSurge := intstr.FromString("25%")
obj.MaxSurge = &maxSurge
}
if obj.MaxUnavailable == nil && obj.MaxSurge != nil &&
(*obj.MaxSurge == intstr.FromInt(0) || *obj.MaxSurge == intstr.FromString("0%")) {
maxUnavailable := intstr.FromString("25%")
obj.MaxUnavailable = &maxUnavailable
}
if obj.MaxSurge == nil && obj.MaxUnavailable != nil &&
(*obj.MaxUnavailable == intstr.FromInt(0) || *obj.MaxUnavailable == intstr.FromString("0%")) {
maxSurge := intstr.FromString("25%")
obj.MaxSurge = &maxSurge
}
}
File diff suppressed because it is too large Load Diff
-410
View File
@@ -1,410 +0,0 @@
// This file was autogenerated by go-to-protobuf. Do not edit it manually!
syntax = 'proto2';
package github.com.openshift.origin.pkg.deploy.api.v1;
import "k8s.io/kubernetes/pkg/api/unversioned/generated.proto";
import "k8s.io/kubernetes/pkg/api/v1/generated.proto";
import "k8s.io/kubernetes/pkg/apis/extensions/v1beta1/generated.proto";
import "k8s.io/kubernetes/pkg/runtime/generated.proto";
import "k8s.io/kubernetes/pkg/util/intstr/generated.proto";
// Package-wide variables from generator "generated".
option go_package = "v1";
// CustomDeploymentStrategyParams are the input to the Custom deployment strategy.
message CustomDeploymentStrategyParams {
// Image specifies a Docker image which can carry out a deployment.
optional string image = 1;
// Environment holds the environment which will be given to the container for Image.
repeated k8s.io.kubernetes.pkg.api.v1.EnvVar environment = 2;
// Command is optional and overrides CMD in the container Image.
repeated string command = 3;
}
// DeploymentCause captures information about a particular cause of a deployment.
message DeploymentCause {
// Type of the trigger that resulted in the creation of a new deployment
optional string type = 1;
// ImageTrigger contains the image trigger details, if this trigger was fired based on an image change
optional DeploymentCauseImageTrigger imageTrigger = 2;
}
// DeploymentCauseImageTrigger represents details about the cause of a deployment originating
// from an image change trigger
message DeploymentCauseImageTrigger {
// From is a reference to the changed object which triggered a deployment. The field may have
// the kinds DockerImage, ImageStreamTag, or ImageStreamImage.
optional k8s.io.kubernetes.pkg.api.v1.ObjectReference from = 1;
}
// DeploymentConfig represents a configuration for a single deployment (represented as a
// ReplicationController). It also contains details about changes which resulted in the current
// state of the DeploymentConfig. Each change to the DeploymentConfig which should result in
// a new deployment results in an increment of LatestVersion.
message DeploymentConfig {
// Standard object's metadata.
optional k8s.io.kubernetes.pkg.api.v1.ObjectMeta metadata = 1;
// Spec represents a desired deployment state and how to deploy to it.
optional DeploymentConfigSpec spec = 2;
// Status represents the current deployment state.
optional DeploymentConfigStatus status = 3;
}
// DeploymentConfigList is a collection of deployment configs.
message DeploymentConfigList {
// Standard object's metadata.
optional k8s.io.kubernetes.pkg.api.unversioned.ListMeta metadata = 1;
// Items is a list of deployment configs
repeated DeploymentConfig items = 2;
}
// DeploymentConfigRollback provides the input to rollback generation.
message DeploymentConfigRollback {
// Name of the deployment config that will be rolled back.
optional string name = 1;
// UpdatedAnnotations is a set of new annotations that will be added in the deployment config.
map<string, string> updatedAnnotations = 2;
// Spec defines the options to rollback generation.
optional DeploymentConfigRollbackSpec spec = 3;
}
// DeploymentConfigRollbackSpec represents the options for rollback generation.
message DeploymentConfigRollbackSpec {
// From points to a ReplicationController which is a deployment.
optional k8s.io.kubernetes.pkg.api.v1.ObjectReference from = 1;
// Revision to rollback to. If set to 0, rollback to the last revision.
optional int64 revision = 2;
// IncludeTriggers specifies whether to include config Triggers.
optional bool includeTriggers = 3;
// IncludeTemplate specifies whether to include the PodTemplateSpec.
optional bool includeTemplate = 4;
// IncludeReplicationMeta specifies whether to include the replica count and selector.
optional bool includeReplicationMeta = 5;
// IncludeStrategy specifies whether to include the deployment Strategy.
optional bool includeStrategy = 6;
}
// DeploymentConfigSpec represents the desired state of the deployment.
message DeploymentConfigSpec {
// Strategy describes how a deployment is executed.
optional DeploymentStrategy strategy = 1;
// MinReadySeconds is the 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 int32 minReadySeconds = 9;
// Triggers determine how updates to a DeploymentConfig result in new deployments. If no triggers
// are defined, a new deployment can only occur as a result of an explicit client update to the
// DeploymentConfig with a new LatestVersion. If null, defaults to having a config change trigger.
optional DeploymentTriggerPolicies triggers = 2;
// Replicas is the number of desired replicas.
optional int32 replicas = 3;
// RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks.
// This field is a pointer to allow for differentiation between an explicit zero and not specified.
optional int32 revisionHistoryLimit = 4;
// Test ensures that this deployment config will have zero replicas except while a deployment is running. This allows the
// deployment config to be used as a continuous deployment test - triggering on images, running the deployment, and then succeeding
// or failing. Post strategy hooks and After actions can be used to integrate successful deployment with an action.
optional bool test = 5;
// Paused indicates that the deployment config is paused resulting in no new deployments on template
// changes or changes in the template caused by other triggers.
optional bool paused = 6;
// Selector is a label query over pods that should match the Replicas count.
map<string, string> selector = 7;
// Template is the object that describes the pod that will be created if
// insufficient replicas are detected.
optional k8s.io.kubernetes.pkg.api.v1.PodTemplateSpec template = 8;
}
// DeploymentConfigStatus represents the current deployment state.
message DeploymentConfigStatus {
// LatestVersion is used to determine whether the current deployment associated with a deployment
// config is out of sync.
optional int64 latestVersion = 1;
// ObservedGeneration is the most recent generation observed by the deployment config controller.
optional int64 observedGeneration = 2;
// Replicas is the total number of pods targeted by this deployment config.
optional int32 replicas = 3;
// UpdatedReplicas is the total number of non-terminated pods targeted by this deployment config
// that have the desired template spec.
optional int32 updatedReplicas = 4;
// AvailableReplicas is the total number of available pods targeted by this deployment config.
optional int32 availableReplicas = 5;
// UnavailableReplicas is the total number of unavailable pods targeted by this deployment config.
optional int32 unavailableReplicas = 6;
// Details are the reasons for the update to this deployment config.
// This could be based on a change made by the user or caused by an automatic trigger
optional DeploymentDetails details = 7;
}
// DeploymentDetails captures information about the causes of a deployment.
message DeploymentDetails {
// Message is the user specified change message, if this deployment was triggered manually by the user
optional string message = 1;
// Causes are extended data associated with all the causes for creating a new deployment
repeated DeploymentCause causes = 2;
}
// DeploymentLog represents the logs for a deployment
message DeploymentLog {
}
// DeploymentLogOptions is the REST options for a deployment log
message DeploymentLogOptions {
// The container for which to stream logs. Defaults to only container if there is one container in the pod.
optional string container = 1;
// Follow if true indicates that the build log should be streamed until
// the build terminates.
optional bool follow = 2;
// Return previous deployment logs. Defaults to false.
optional bool previous = 3;
// A relative time in seconds before the current time from which to show logs. If this value
// precedes the time a pod was started, only logs since the pod start will be returned.
// If this value is in the future, no logs will be returned.
// Only one of sinceSeconds or sinceTime may be specified.
optional int64 sinceSeconds = 4;
// An RFC3339 timestamp from which to show logs. If this value
// precedes the time a pod was started, only logs since the pod start will be returned.
// If this value is in the future, no logs will be returned.
// Only one of sinceSeconds or sinceTime may be specified.
optional k8s.io.kubernetes.pkg.api.unversioned.Time sinceTime = 5;
// If true, add an RFC3339 or RFC3339Nano timestamp at the beginning of every line
// of log output. Defaults to false.
optional bool timestamps = 6;
// If set, the number of lines from the end of the logs to show. If not specified,
// logs are shown from the creation of the container or sinceSeconds or sinceTime
optional int64 tailLines = 7;
// If set, the number of bytes to read from the server before terminating the
// log output. This may not display a complete final line of logging, and may return
// slightly more or slightly less than the specified limit.
optional int64 limitBytes = 8;
// NoWait if true causes the call to return immediately even if the deployment
// is not available yet. Otherwise the server will wait until the deployment has started.
// TODO: Fix the tag to 'noWait' in v2
optional bool nowait = 9;
// Version of the deployment for which to view logs.
optional int64 version = 10;
}
// DeploymentStrategy describes how to perform a deployment.
message DeploymentStrategy {
// Type is the name of a deployment strategy.
optional string type = 1;
// CustomParams are the input to the Custom deployment strategy.
optional CustomDeploymentStrategyParams customParams = 2;
// RecreateParams are the input to the Recreate deployment strategy.
optional RecreateDeploymentStrategyParams recreateParams = 3;
// RollingParams are the input to the Rolling deployment strategy.
optional RollingDeploymentStrategyParams rollingParams = 4;
// Resources contains resource requirements to execute the deployment and any hooks
optional k8s.io.kubernetes.pkg.api.v1.ResourceRequirements resources = 5;
// Labels is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
map<string, string> labels = 6;
// Annotations is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
map<string, string> annotations = 7;
}
// DeploymentTriggerImageChangeParams represents the parameters to the ImageChange trigger.
message DeploymentTriggerImageChangeParams {
// Automatic means that the detection of a new tag value should result in an image update
// inside the pod template. Deployment configs that haven't been deployed yet will always
// have their images updated. Deployment configs that have been deployed at least once, will
// have their images updated only if this is set to true.
optional bool automatic = 1;
// ContainerNames is used to restrict tag updates to the specified set of container names in a pod.
repeated string containerNames = 2;
// From is a reference to an image stream tag to watch for changes. From.Name is the only
// required subfield - if From.Namespace is blank, the namespace of the current deployment
// trigger will be used.
optional k8s.io.kubernetes.pkg.api.v1.ObjectReference from = 3;
// LastTriggeredImage is the last image to be triggered.
optional string lastTriggeredImage = 4;
}
// DeploymentTriggerPolicies is a list of policies where nil values and different from empty arrays.
// +protobuf.nullable=true
// +protobuf.options.(gogoproto.goproto_stringer)=false
message DeploymentTriggerPolicies {
// items, if empty, will result in an empty slice
repeated DeploymentTriggerPolicy items = 1;
}
// DeploymentTriggerPolicy describes a policy for a single trigger that results in a new deployment.
message DeploymentTriggerPolicy {
// Type of the trigger
optional string type = 1;
// ImageChangeParams represents the parameters for the ImageChange trigger.
optional DeploymentTriggerImageChangeParams imageChangeParams = 2;
}
// ExecNewPodHook is a hook implementation which runs a command in a new pod
// based on the specified container which is assumed to be part of the
// deployment template.
message ExecNewPodHook {
// Command is the action command and its arguments.
repeated string command = 1;
// Env is a set of environment variables to supply to the hook pod's container.
repeated k8s.io.kubernetes.pkg.api.v1.EnvVar env = 2;
// ContainerName is the name of a container in the deployment pod template
// whose Docker image will be used for the hook pod's container.
optional string containerName = 3;
// Volumes is a list of named volumes from the pod template which should be
// copied to the hook pod. Volumes names not found in pod spec are ignored.
// An empty list means no volumes will be copied.
repeated string volumes = 4;
}
// LifecycleHook defines a specific deployment lifecycle action. Only one type of action may be specified at any time.
message LifecycleHook {
// FailurePolicy specifies what action to take if the hook fails.
optional string failurePolicy = 1;
// ExecNewPod specifies the options for a lifecycle hook backed by a pod.
optional ExecNewPodHook execNewPod = 2;
// TagImages instructs the deployer to tag the current image referenced under a container onto an image stream tag.
repeated TagImageHook tagImages = 3;
}
// RecreateDeploymentStrategyParams are the input to the Recreate deployment
// strategy.
message RecreateDeploymentStrategyParams {
// TimeoutSeconds is the time to wait for updates before giving up. If the
// value is nil, a default will be used.
optional int64 timeoutSeconds = 1;
// Pre is a lifecycle hook which is executed before the strategy manipulates
// the deployment. All LifecycleHookFailurePolicy values are supported.
optional LifecycleHook pre = 2;
// Mid is a lifecycle hook which is executed while the deployment is scaled down to zero before the first new
// pod is created. All LifecycleHookFailurePolicy values are supported.
optional LifecycleHook mid = 3;
// Post is a lifecycle hook which is executed after the strategy has
// finished all deployment logic. All LifecycleHookFailurePolicy values are supported.
optional LifecycleHook post = 4;
}
// RollingDeploymentStrategyParams are the input to the Rolling deployment
// strategy.
message RollingDeploymentStrategyParams {
// UpdatePeriodSeconds is the time to wait between individual pod updates.
// If the value is nil, a default will be used.
optional int64 updatePeriodSeconds = 1;
// IntervalSeconds is the time to wait between polling deployment status
// after update. If the value is nil, a default will be used.
optional int64 intervalSeconds = 2;
// TimeoutSeconds is the time to wait for updates before giving up. If the
// value is nil, a default will be used.
optional int64 timeoutSeconds = 3;
// MaxUnavailable is the maximum number of pods that can be unavailable
// during the update. Value can be an absolute number (ex: 5) or a
// percentage of total pods at the start of update (ex: 10%). Absolute
// number is calculated from percentage by rounding up.
//
// This cannot be 0 if MaxSurge is 0. By default, 25% is used.
//
// Example: when this is set to 30%, the old RC can be scaled down by 30%
// immediately when the rolling update starts. Once new pods are ready, old
// RC can be scaled down further, followed by scaling up the new RC,
// ensuring that at least 70% of original number of pods are available at
// all times during the update.
optional k8s.io.kubernetes.pkg.util.intstr.IntOrString maxUnavailable = 4;
// MaxSurge is the maximum number of pods that can be scheduled above the
// original number of pods. Value can be an absolute number (ex: 5) or a
// percentage of total pods at the start of the update (ex: 10%). Absolute
// number is calculated from percentage by rounding up.
//
// This cannot be 0 if MaxUnavailable is 0. By default, 25% is used.
//
// Example: when this is set to 30%, the new RC can be scaled up by 30%
// immediately when the rolling update starts. Once old pods have been
// killed, new RC can be scaled up further, ensuring that total number of
// pods running at any time during the update is atmost 130% of original
// pods.
optional k8s.io.kubernetes.pkg.util.intstr.IntOrString maxSurge = 5;
// UpdatePercent is the percentage of replicas to scale up or down each
// interval. If nil, one replica will be scaled up and down each interval.
// If negative, the scale order will be down/up instead of up/down.
// DEPRECATED: Use MaxUnavailable/MaxSurge instead.
optional int32 updatePercent = 6;
// Pre is a lifecycle hook which is executed before the deployment process
// begins. All LifecycleHookFailurePolicy values are supported.
optional LifecycleHook pre = 7;
// Post is a lifecycle hook which is executed after the strategy has
// finished all deployment logic. The LifecycleHookFailurePolicyAbort policy
// is NOT supported.
optional LifecycleHook post = 8;
}
// TagImageHook is a request to tag the image in a particular container onto an ImageStreamTag.
message TagImageHook {
// ContainerName is the name of a container in the deployment config whose image value will be used as the source of the tag. If there is only a single
// container this value will be defaulted to the name of that container.
optional string containerName = 1;
// To is the target ImageStreamTag to set the container's image onto.
optional k8s.io.kubernetes.pkg.api.v1.ObjectReference to = 2;
}
+2
View File
@@ -21,6 +21,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&DeploymentConfig{},
&DeploymentConfigList{},
&DeploymentConfigRollback{},
&DeploymentRequest{},
&DeploymentLog{},
&DeploymentLogOptions{},
)
@@ -30,5 +31,6 @@ func addKnownTypes(scheme *runtime.Scheme) error {
func (obj *DeploymentConfig) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *DeploymentConfigList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *DeploymentConfigRollback) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *DeploymentRequest) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *DeploymentLog) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
func (obj *DeploymentLogOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
+30 -6
View File
@@ -35,8 +35,21 @@ func (DeploymentCauseImageTrigger) SwaggerDoc() map[string]string {
return map_DeploymentCauseImageTrigger
}
var map_DeploymentCondition = map[string]string{
"": "DeploymentCondition describes the state of a deployment config at a certain point.",
"type": "Type of deployment condition.",
"status": "Status of the condition, one of True, False, Unknown.",
"lastTransitionTime": "The last time the condition transitioned from one status to another.",
"reason": "The reason for the condition's last transition.",
"message": "A human readable message indicating details about the transition.",
}
func (DeploymentCondition) SwaggerDoc() map[string]string {
return map_DeploymentCondition
}
var map_DeploymentConfig = map[string]string{
"": "DeploymentConfig represents a configuration for a single deployment (represented as a ReplicationController). It also contains details about changes which resulted in the current state of the DeploymentConfig. Each change to the DeploymentConfig which should result in a new deployment results in an increment of LatestVersion.",
"": "Deployment Configs define the template for a pod and manages deploying new images or configuration changes. A single deployment configuration is usually analogous to a single micro-service. Can support many different deployment patterns, including full restart, customizable rolling updates, and fully custom behaviors, as well as pre- and post- deployment hooks. Each individual deployment is represented as a replication controller.\n\nA deployment is \"triggered\" when its configuration is changed or a tag in an Image Stream is changed. Triggers can be disabled to allow manual control over a deployment. The \"strategy\" determines how the deployment is carried out and may be changed at any time. The `latestVersion` field is updated when a new deployment is triggered by any means.",
"metadata": "Standard object's metadata.",
"spec": "Spec represents a desired deployment state and how to deploy to it.",
"status": "Status represents the current deployment state.",
@@ -107,6 +120,7 @@ var map_DeploymentConfigStatus = map[string]string{
"availableReplicas": "AvailableReplicas is the total number of available pods targeted by this deployment config.",
"unavailableReplicas": "UnavailableReplicas is the total number of unavailable pods targeted by this deployment config.",
"details": "Details are the reasons for the update to this deployment config. This could be based on a change made by the user or caused by an automatic trigger",
"conditions": "Conditions represents the latest available observations of a deployment config's current state.",
}
func (DeploymentConfigStatus) SwaggerDoc() map[string]string {
@@ -149,13 +163,24 @@ func (DeploymentLogOptions) SwaggerDoc() map[string]string {
return map_DeploymentLogOptions
}
var map_DeploymentRequest = map[string]string{
"": "DeploymentRequest is a request to a deployment config for a new deployment.",
"name": "Name of the deployment config for requesting a new deployment.",
"latest": "Latest will update the deployment config with the latest state from all triggers.",
"force": "Force will try to force a new deployment to run. If the deployment config is paused, then setting this to true will return an Invalid error.",
}
func (DeploymentRequest) SwaggerDoc() map[string]string {
return map_DeploymentRequest
}
var map_DeploymentStrategy = map[string]string{
"": "DeploymentStrategy describes how to perform a deployment.",
"type": "Type is the name of a deployment strategy.",
"customParams": "CustomParams are the input to the Custom deployment strategy.",
"customParams": "CustomParams are the input to the Custom deployment strategy, and may also be specified for the Recreate and Rolling strategies to customize the execution process that runs the deployment.",
"recreateParams": "RecreateParams are the input to the Recreate deployment strategy.",
"rollingParams": "RollingParams are the input to the Rolling deployment strategy.",
"resources": "Resources contains resource requirements to execute the deployment and any hooks",
"resources": "Resources contains resource requirements to execute the deployment and any hooks.",
"labels": "Labels is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.",
"annotations": "Annotations is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.",
}
@@ -166,7 +191,7 @@ func (DeploymentStrategy) SwaggerDoc() map[string]string {
var map_DeploymentTriggerImageChangeParams = map[string]string{
"": "DeploymentTriggerImageChangeParams represents the parameters to the ImageChange trigger.",
"automatic": "Automatic means that the detection of a new tag value should result in an image update inside the pod template. Deployment configs that haven't been deployed yet will always have their images updated. Deployment configs that have been deployed at least once, will have their images updated only if this is set to true.",
"automatic": "Automatic means that the detection of a new tag value should result in an image update inside the pod template.",
"containerNames": "ContainerNames is used to restrict tag updates to the specified set of container names in a pod.",
"from": "From is a reference to an image stream tag to watch for changes. From.Name is the only required subfield - if From.Namespace is blank, the namespace of the current deployment trigger will be used.",
"lastTriggeredImage": "LastTriggeredImage is the last image to be triggered.",
@@ -228,9 +253,8 @@ var map_RollingDeploymentStrategyParams = map[string]string{
"timeoutSeconds": "TimeoutSeconds is the time to wait for updates before giving up. If the value is nil, a default will be used.",
"maxUnavailable": "MaxUnavailable is the maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of total pods at the start of update (ex: 10%). Absolute number is calculated from percentage by rounding up.\n\nThis cannot be 0 if MaxSurge is 0. By default, 25% is used.\n\nExample: when this is set to 30%, the old RC can be scaled down by 30% immediately when the rolling update starts. Once new pods are ready, old RC can be scaled down further, followed by scaling up the new RC, ensuring that at least 70% of original number of pods are available at all times during the update.",
"maxSurge": "MaxSurge is the maximum number of pods that can be scheduled above the original number of pods. Value can be an absolute number (ex: 5) or a percentage of total pods at the start of the update (ex: 10%). Absolute number is calculated from percentage by rounding up.\n\nThis cannot be 0 if MaxUnavailable is 0. By default, 25% is used.\n\nExample: when this is set to 30%, the new RC can be scaled up by 30% immediately when the rolling update starts. Once old pods have been killed, new RC can be scaled up further, ensuring that total number of pods running at any time during the update is atmost 130% of original pods.",
"updatePercent": "UpdatePercent is the percentage of replicas to scale up or down each interval. If nil, one replica will be scaled up and down each interval. If negative, the scale order will be down/up instead of up/down. DEPRECATED: Use MaxUnavailable/MaxSurge instead.",
"pre": "Pre is a lifecycle hook which is executed before the deployment process begins. All LifecycleHookFailurePolicy values are supported.",
"post": "Post is a lifecycle hook which is executed after the strategy has finished all deployment logic. The LifecycleHookFailurePolicyAbort policy is NOT supported.",
"post": "Post is a lifecycle hook which is executed after the strategy has finished all deployment logic. All LifecycleHookFailurePolicy values are supported.",
}
func (RollingDeploymentStrategyParams) SwaggerDoc() map[string]string {
+177 -199
View File
@@ -8,37 +8,83 @@ import (
"k8s.io/kubernetes/pkg/util/intstr"
)
// DeploymentPhase describes the possible states a deployment can be in.
type DeploymentPhase string
// +genclient=true
const (
// DeploymentPhaseNew means the deployment has been accepted but not yet acted upon.
DeploymentPhaseNew DeploymentPhase = "New"
// DeploymentPhasePending means the deployment been handed over to a deployment strategy,
// but the strategy has not yet declared the deployment to be running.
DeploymentPhasePending DeploymentPhase = "Pending"
// DeploymentPhaseRunning means the deployment strategy has reported the deployment as
// being in-progress.
DeploymentPhaseRunning DeploymentPhase = "Running"
// DeploymentPhaseComplete means the deployment finished without an error.
DeploymentPhaseComplete DeploymentPhase = "Complete"
// DeploymentPhaseFailed means the deployment finished with an error.
DeploymentPhaseFailed DeploymentPhase = "Failed"
)
// Deployment Configs define the template for a pod and manages deploying new images or configuration changes.
// A single deployment configuration is usually analogous to a single micro-service. Can support many different
// deployment patterns, including full restart, customizable rolling updates, and fully custom behaviors, as
// well as pre- and post- deployment hooks. Each individual deployment is represented as a replication controller.
//
// A deployment is "triggered" when its configuration is changed or a tag in an Image Stream is changed.
// Triggers can be disabled to allow manual control over a deployment. The "strategy" determines how the deployment
// is carried out and may be changed at any time. The `latestVersion` field is updated when a new deployment
// is triggered by any means.
type DeploymentConfig struct {
unversioned.TypeMeta `json:",inline"`
// Standard object's metadata.
kapi.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Spec represents a desired deployment state and how to deploy to it.
Spec DeploymentConfigSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
// Status represents the current deployment state.
Status DeploymentConfigStatus `json:"status" protobuf:"bytes,3,opt,name=status"`
}
// DeploymentConfigSpec represents the desired state of the deployment.
type DeploymentConfigSpec struct {
// Strategy describes how a deployment is executed.
Strategy DeploymentStrategy `json:"strategy" protobuf:"bytes,1,opt,name=strategy"`
// MinReadySeconds is the 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)
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"`
// Triggers determine how updates to a DeploymentConfig result in new deployments. If no triggers
// are defined, a new deployment can only occur as a result of an explicit client update to the
// DeploymentConfig with a new LatestVersion. If null, defaults to having a config change trigger.
Triggers DeploymentTriggerPolicies `json:"triggers" protobuf:"bytes,2,rep,name=triggers"`
// Replicas is the number of desired replicas.
Replicas int32 `json:"replicas" protobuf:"varint,3,opt,name=replicas"`
// RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks.
// This field is a pointer to allow for differentiation between an explicit zero and not specified.
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,4,opt,name=revisionHistoryLimit"`
// Test ensures that this deployment config will have zero replicas except while a deployment is running. This allows the
// deployment config to be used as a continuous deployment test - triggering on images, running the deployment, and then succeeding
// or failing. Post strategy hooks and After actions can be used to integrate successful deployment with an action.
Test bool `json:"test" protobuf:"varint,5,opt,name=test"`
// Paused indicates that the deployment config is paused resulting in no new deployments on template
// changes or changes in the template caused by other triggers.
Paused bool `json:"paused,omitempty" protobuf:"varint,6,opt,name=paused"`
// Selector is a label query over pods that should match the Replicas count.
Selector map[string]string `json:"selector,omitempty" protobuf:"bytes,7,rep,name=selector"`
// Template is the object that describes the pod that will be created if
// insufficient replicas are detected.
Template *kapi.PodTemplateSpec `json:"template,omitempty" protobuf:"bytes,8,opt,name=template"`
}
// DeploymentStrategy describes how to perform a deployment.
type DeploymentStrategy struct {
// Type is the name of a deployment strategy.
Type DeploymentStrategyType `json:"type,omitempty" protobuf:"bytes,1,opt,name=type,casttype=DeploymentStrategyType"`
// CustomParams are the input to the Custom deployment strategy.
// CustomParams are the input to the Custom deployment strategy, and may also
// be specified for the Recreate and Rolling strategies to customize the execution
// process that runs the deployment.
CustomParams *CustomDeploymentStrategyParams `json:"customParams,omitempty" protobuf:"bytes,2,opt,name=customParams"`
// RecreateParams are the input to the Recreate deployment strategy.
RecreateParams *RecreateDeploymentStrategyParams `json:"recreateParams,omitempty" protobuf:"bytes,3,opt,name=recreateParams"`
// RollingParams are the input to the Rolling deployment strategy.
RollingParams *RollingDeploymentStrategyParams `json:"rollingParams,omitempty" protobuf:"bytes,4,opt,name=rollingParams"`
// Resources contains resource requirements to execute the deployment and any hooks
// Resources contains resource requirements to execute the deployment and any hooks.
Resources kapi.ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,5,opt,name=resources"`
// Labels is a set of key, value pairs added to custom deployer and lifecycle pre/post hook pods.
Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,6,rep,name=labels"`
@@ -85,56 +131,6 @@ type RecreateDeploymentStrategyParams struct {
Post *LifecycleHook `json:"post,omitempty" protobuf:"bytes,4,opt,name=post"`
}
// LifecycleHook defines a specific deployment lifecycle action. Only one type of action may be specified at any time.
type LifecycleHook struct {
// FailurePolicy specifies what action to take if the hook fails.
FailurePolicy LifecycleHookFailurePolicy `json:"failurePolicy" protobuf:"bytes,1,opt,name=failurePolicy,casttype=LifecycleHookFailurePolicy"`
// ExecNewPod specifies the options for a lifecycle hook backed by a pod.
ExecNewPod *ExecNewPodHook `json:"execNewPod,omitempty" protobuf:"bytes,2,opt,name=execNewPod"`
// TagImages instructs the deployer to tag the current image referenced under a container onto an image stream tag.
TagImages []TagImageHook `json:"tagImages,omitempty" protobuf:"bytes,3,rep,name=tagImages"`
}
// LifecycleHookFailurePolicy describes possibles actions to take if a hook fails.
type LifecycleHookFailurePolicy string
const (
// LifecycleHookFailurePolicyRetry means retry the hook until it succeeds.
LifecycleHookFailurePolicyRetry LifecycleHookFailurePolicy = "Retry"
// LifecycleHookFailurePolicyAbort means abort the deployment (if possible).
LifecycleHookFailurePolicyAbort LifecycleHookFailurePolicy = "Abort"
// LifecycleHookFailurePolicyIgnore means ignore failure and continue the deployment.
LifecycleHookFailurePolicyIgnore LifecycleHookFailurePolicy = "Ignore"
)
// ExecNewPodHook is a hook implementation which runs a command in a new pod
// based on the specified container which is assumed to be part of the
// deployment template.
type ExecNewPodHook struct {
// Command is the action command and its arguments.
Command []string `json:"command" protobuf:"bytes,1,rep,name=command"`
// Env is a set of environment variables to supply to the hook pod's container.
Env []kapi.EnvVar `json:"env,omitempty" protobuf:"bytes,2,rep,name=env"`
// ContainerName is the name of a container in the deployment pod template
// whose Docker image will be used for the hook pod's container.
ContainerName string `json:"containerName" protobuf:"bytes,3,opt,name=containerName"`
// Volumes is a list of named volumes from the pod template which should be
// copied to the hook pod. Volumes names not found in pod spec are ignored.
// An empty list means no volumes will be copied.
Volumes []string `json:"volumes,omitempty" protobuf:"bytes,4,rep,name=volumes"`
}
// TagImageHook is a request to tag the image in a particular container onto an ImageStreamTag.
type TagImageHook struct {
// ContainerName is the name of a container in the deployment config whose image value will be used as the source of the tag. If there is only a single
// container this value will be defaulted to the name of that container.
ContainerName string `json:"containerName" protobuf:"bytes,1,opt,name=containerName"`
// To is the target ImageStreamTag to set the container's image onto.
To kapi.ObjectReference `json:"to" protobuf:"bytes,2,opt,name=to"`
}
// RollingDeploymentStrategyParams are the input to the Rolling deployment
// strategy.
type RollingDeploymentStrategyParams struct {
@@ -173,85 +169,63 @@ type RollingDeploymentStrategyParams struct {
// pods running at any time during the update is atmost 130% of original
// pods.
MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty" protobuf:"bytes,5,opt,name=maxSurge"`
// UpdatePercent is the percentage of replicas to scale up or down each
// interval. If nil, one replica will be scaled up and down each interval.
// If negative, the scale order will be down/up instead of up/down.
// DEPRECATED: Use MaxUnavailable/MaxSurge instead.
UpdatePercent *int32 `json:"updatePercent,omitempty" protobuf:"varint,6,opt,name=updatePercent"`
// Pre is a lifecycle hook which is executed before the deployment process
// begins. All LifecycleHookFailurePolicy values are supported.
Pre *LifecycleHook `json:"pre,omitempty" protobuf:"bytes,7,opt,name=pre"`
// Post is a lifecycle hook which is executed after the strategy has
// finished all deployment logic. The LifecycleHookFailurePolicyAbort policy
// is NOT supported.
// finished all deployment logic. All LifecycleHookFailurePolicy values
// are supported.
Post *LifecycleHook `json:"post,omitempty" protobuf:"bytes,8,opt,name=post"`
}
// These constants represent keys used for correlating objects related to deployments.
// LifecycleHook defines a specific deployment lifecycle action. Only one type of action may be specified at any time.
type LifecycleHook struct {
// FailurePolicy specifies what action to take if the hook fails.
FailurePolicy LifecycleHookFailurePolicy `json:"failurePolicy" protobuf:"bytes,1,opt,name=failurePolicy,casttype=LifecycleHookFailurePolicy"`
// ExecNewPod specifies the options for a lifecycle hook backed by a pod.
ExecNewPod *ExecNewPodHook `json:"execNewPod,omitempty" protobuf:"bytes,2,opt,name=execNewPod"`
// TagImages instructs the deployer to tag the current image referenced under a container onto an image stream tag.
TagImages []TagImageHook `json:"tagImages,omitempty" protobuf:"bytes,3,rep,name=tagImages"`
}
// LifecycleHookFailurePolicy describes possibles actions to take if a hook fails.
type LifecycleHookFailurePolicy string
const (
// DeploymentConfigAnnotation is an annotation name used to correlate a deployment with the
// DeploymentConfig on which the deployment is based.
DeploymentConfigAnnotation = "openshift.io/deployment-config.name"
// DeploymentAnnotation is an annotation on a deployer Pod. The annotation value is the name
// of the deployment (a ReplicationController) on which the deployer Pod acts.
DeploymentAnnotation = "openshift.io/deployment.name"
// DeploymentPodAnnotation is an annotation on a deployment (a ReplicationController). The
// annotation value is the name of the deployer Pod which will act upon the ReplicationController
// to implement the deployment behavior.
DeploymentPodAnnotation = "openshift.io/deployer-pod.name"
// DeploymentPodTypeLabel is a label with which contains a type of deployment pod.
DeploymentPodTypeLabel = "openshift.io/deployer-pod.type"
// DeployerPodForDeploymentLabel is a label which groups pods related to a
// deployment. The value is a deployment name. The deployer pod and hook pods
// created by the internal strategies will have this label. Custom
// strategies can apply this label to any pods they create, enabling
// platform-provided cancellation and garbage collection support.
DeployerPodForDeploymentLabel = "openshift.io/deployer-pod-for.name"
// DeploymentPhaseAnnotation is an annotation name used to retrieve the DeploymentPhase of
// a deployment.
DeploymentPhaseAnnotation = "openshift.io/deployment.phase"
// DeploymentEncodedConfigAnnotation is an annotation name used to retrieve specific encoded
// DeploymentConfig on which a given deployment is based.
DeploymentEncodedConfigAnnotation = "openshift.io/encoded-deployment-config"
// DeploymentVersionAnnotation is an annotation on a deployment (a ReplicationController). The
// annotation value is the LatestVersion value of the DeploymentConfig which was the basis for
// the deployment.
DeploymentVersionAnnotation = "openshift.io/deployment-config.latest-version"
// DeploymentLabel is the name of a label used to correlate a deployment with the Pod created
// to execute the deployment logic.
// TODO: This is a workaround for upstream's lack of annotation support on PodTemplate. Once
// annotations are available on PodTemplate, audit this constant with the goal of removing it.
DeploymentLabel = "deployment"
// DeploymentConfigLabel is the name of a label used to correlate a deployment with the
// DeploymentConfigs on which the deployment is based.
DeploymentConfigLabel = "deploymentconfig"
// DeploymentStatusReasonAnnotation represents the reason for deployment being in a given state
// Used for specifying the reason for cancellation or failure of a deployment
DeploymentStatusReasonAnnotation = "openshift.io/deployment.status-reason"
// DeploymentCancelledAnnotation indicates that the deployment has been cancelled
// The annotation value does not matter and its mere presence indicates cancellation
DeploymentCancelledAnnotation = "openshift.io/deployment.cancelled"
// DeploymentInstantiatedAnnotation indicates that the deployment has been instantiated.
// The annotation value does not matter and its mere presence indicates instantiation.
DeploymentInstantiatedAnnotation = "openshift.io/deployment.instantiated"
// LifecycleHookFailurePolicyRetry means retry the hook until it succeeds.
LifecycleHookFailurePolicyRetry LifecycleHookFailurePolicy = "Retry"
// LifecycleHookFailurePolicyAbort means abort the deployment.
LifecycleHookFailurePolicyAbort LifecycleHookFailurePolicy = "Abort"
// LifecycleHookFailurePolicyIgnore means ignore failure and continue the deployment.
LifecycleHookFailurePolicyIgnore LifecycleHookFailurePolicy = "Ignore"
)
// +genclient=true
// ExecNewPodHook is a hook implementation which runs a command in a new pod
// based on the specified container which is assumed to be part of the
// deployment template.
type ExecNewPodHook struct {
// Command is the action command and its arguments.
Command []string `json:"command" protobuf:"bytes,1,rep,name=command"`
// Env is a set of environment variables to supply to the hook pod's container.
Env []kapi.EnvVar `json:"env,omitempty" protobuf:"bytes,2,rep,name=env"`
// ContainerName is the name of a container in the deployment pod template
// whose Docker image will be used for the hook pod's container.
ContainerName string `json:"containerName" protobuf:"bytes,3,opt,name=containerName"`
// Volumes is a list of named volumes from the pod template which should be
// copied to the hook pod. Volumes names not found in pod spec are ignored.
// An empty list means no volumes will be copied.
Volumes []string `json:"volumes,omitempty" protobuf:"bytes,4,rep,name=volumes"`
}
// DeploymentConfig represents a configuration for a single deployment (represented as a
// ReplicationController). It also contains details about changes which resulted in the current
// state of the DeploymentConfig. Each change to the DeploymentConfig which should result in
// a new deployment results in an increment of LatestVersion.
type DeploymentConfig struct {
unversioned.TypeMeta `json:",inline"`
// Standard object's metadata.
kapi.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Spec represents a desired deployment state and how to deploy to it.
Spec DeploymentConfigSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
// Status represents the current deployment state.
Status DeploymentConfigStatus `json:"status" protobuf:"bytes,3,opt,name=status"`
// TagImageHook is a request to tag the image in a particular container onto an ImageStreamTag.
type TagImageHook struct {
// ContainerName is the name of a container in the deployment config whose image value will be used as the source of the tag. If there is only a single
// container this value will be defaulted to the name of that container.
ContainerName string `json:"containerName" protobuf:"bytes,1,opt,name=containerName"`
// To is the target ImageStreamTag to set the container's image onto.
To kapi.ObjectReference `json:"to" protobuf:"bytes,2,opt,name=to"`
}
// DeploymentTriggerPolicies is a list of policies where nil values and different from empty arrays.
@@ -263,66 +237,6 @@ func (t DeploymentTriggerPolicies) String() string {
return fmt.Sprintf("%v", []DeploymentTriggerPolicy(t))
}
// DeploymentConfigSpec represents the desired state of the deployment.
type DeploymentConfigSpec struct {
// Strategy describes how a deployment is executed.
Strategy DeploymentStrategy `json:"strategy" protobuf:"bytes,1,opt,name=strategy"`
// MinReadySeconds is the 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)
MinReadySeconds int32 `json:"minReadySeconds,omitempty" protobuf:"varint,9,opt,name=minReadySeconds"`
// Triggers determine how updates to a DeploymentConfig result in new deployments. If no triggers
// are defined, a new deployment can only occur as a result of an explicit client update to the
// DeploymentConfig with a new LatestVersion. If null, defaults to having a config change trigger.
Triggers DeploymentTriggerPolicies `json:"triggers" protobuf:"bytes,2,rep,name=triggers"`
// Replicas is the number of desired replicas.
Replicas int32 `json:"replicas" protobuf:"varint,3,opt,name=replicas"`
// RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks.
// This field is a pointer to allow for differentiation between an explicit zero and not specified.
RevisionHistoryLimit *int32 `json:"revisionHistoryLimit,omitempty" protobuf:"varint,4,opt,name=revisionHistoryLimit"`
// Test ensures that this deployment config will have zero replicas except while a deployment is running. This allows the
// deployment config to be used as a continuous deployment test - triggering on images, running the deployment, and then succeeding
// or failing. Post strategy hooks and After actions can be used to integrate successful deployment with an action.
Test bool `json:"test" protobuf:"varint,5,opt,name=test"`
// Paused indicates that the deployment config is paused resulting in no new deployments on template
// changes or changes in the template caused by other triggers.
Paused bool `json:"paused,omitempty" protobuf:"varint,6,opt,name=paused"`
// Selector is a label query over pods that should match the Replicas count.
Selector map[string]string `json:"selector,omitempty" protobuf:"bytes,7,rep,name=selector"`
// Template is the object that describes the pod that will be created if
// insufficient replicas are detected.
Template *kapi.PodTemplateSpec `json:"template,omitempty" protobuf:"bytes,8,opt,name=template"`
}
// DeploymentConfigStatus represents the current deployment state.
type DeploymentConfigStatus struct {
// LatestVersion is used to determine whether the current deployment associated with a deployment
// config is out of sync.
LatestVersion int64 `json:"latestVersion,omitempty" protobuf:"varint,1,opt,name=latestVersion"`
// ObservedGeneration is the most recent generation observed by the deployment config controller.
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,2,opt,name=observedGeneration"`
// Replicas is the total number of pods targeted by this deployment config.
Replicas int32 `json:"replicas,omitempty" protobuf:"varint,3,opt,name=replicas"`
// UpdatedReplicas is the total number of non-terminated pods targeted by this deployment config
// that have the desired template spec.
UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,4,opt,name=updatedReplicas"`
// AvailableReplicas is the total number of available pods targeted by this deployment config.
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,5,opt,name=availableReplicas"`
// UnavailableReplicas is the total number of unavailable pods targeted by this deployment config.
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty" protobuf:"varint,6,opt,name=unavailableReplicas"`
// Details are the reasons for the update to this deployment config.
// This could be based on a change made by the user or caused by an automatic trigger
Details *DeploymentDetails `json:"details,omitempty" protobuf:"bytes,7,opt,name=details"`
}
// DeploymentTriggerPolicy describes a policy for a single trigger that results in a new deployment.
type DeploymentTriggerPolicy struct {
// Type of the trigger
@@ -346,9 +260,7 @@ const (
// DeploymentTriggerImageChangeParams represents the parameters to the ImageChange trigger.
type DeploymentTriggerImageChangeParams struct {
// Automatic means that the detection of a new tag value should result in an image update
// inside the pod template. Deployment configs that haven't been deployed yet will always
// have their images updated. Deployment configs that have been deployed at least once, will
// have their images updated only if this is set to true.
// inside the pod template.
Automatic bool `json:"automatic,omitempty" protobuf:"varint,1,opt,name=automatic"`
// ContainerNames is used to restrict tag updates to the specified set of container names in a pod.
ContainerNames []string `json:"containerNames,omitempty" protobuf:"bytes,2,rep,name=containerNames"`
@@ -360,6 +272,29 @@ type DeploymentTriggerImageChangeParams struct {
LastTriggeredImage string `json:"lastTriggeredImage,omitempty" protobuf:"bytes,4,opt,name=lastTriggeredImage"`
}
// DeploymentConfigStatus represents the current deployment state.
type DeploymentConfigStatus struct {
// LatestVersion is used to determine whether the current deployment associated with a deployment
// config is out of sync.
LatestVersion int64 `json:"latestVersion,omitempty" protobuf:"varint,1,opt,name=latestVersion"`
// ObservedGeneration is the most recent generation observed by the deployment config controller.
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,2,opt,name=observedGeneration"`
// Replicas is the total number of pods targeted by this deployment config.
Replicas int32 `json:"replicas,omitempty" protobuf:"varint,3,opt,name=replicas"`
// UpdatedReplicas is the total number of non-terminated pods targeted by this deployment config
// that have the desired template spec.
UpdatedReplicas int32 `json:"updatedReplicas,omitempty" protobuf:"varint,4,opt,name=updatedReplicas"`
// AvailableReplicas is the total number of available pods targeted by this deployment config.
AvailableReplicas int32 `json:"availableReplicas,omitempty" protobuf:"varint,5,opt,name=availableReplicas"`
// UnavailableReplicas is the total number of unavailable pods targeted by this deployment config.
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty" protobuf:"varint,6,opt,name=unavailableReplicas"`
// Details are the reasons for the update to this deployment config.
// This could be based on a change made by the user or caused by an automatic trigger
Details *DeploymentDetails `json:"details,omitempty" protobuf:"bytes,7,opt,name=details"`
// Conditions represents the latest available observations of a deployment config's current state.
Conditions []DeploymentCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,8,rep,name=conditions"`
}
// DeploymentDetails captures information about the causes of a deployment.
type DeploymentDetails struct {
// Message is the user specified change message, if this deployment was triggered manually by the user
@@ -384,6 +319,37 @@ type DeploymentCauseImageTrigger struct {
From kapi.ObjectReference `json:"from" protobuf:"bytes,1,opt,name=from"`
}
type DeploymentConditionType string
// These are valid conditions of a deployment config.
const (
// DeploymentAvailable means the deployment config is available, ie. at least the minimum available
// replicas required are up and running for at least minReadySeconds.
DeploymentAvailable DeploymentConditionType = "Available"
// DeploymentProgressing means the deployment config is progressing. Progress for a deployment
// config is considered when a new replica set is created or adopted, and when new pods scale up or
// old pods scale down. Progress is not estimated for paused deployment configs, when the deployment
// config needs to rollback, or when progressDeadlineSeconds is not specified.
DeploymentProgressing DeploymentConditionType = "Progressing"
// DeploymentReplicaFailure is added in a deployment config when one of its pods
// fails to be created or deleted.
DeploymentReplicaFailure DeploymentConditionType = "ReplicaFailure"
)
// DeploymentCondition describes the state of a deployment config at a certain point.
type DeploymentCondition struct {
// Type of deployment condition.
Type DeploymentConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=DeploymentConditionType"`
// Status of the condition, one of True, False, Unknown.
Status kapi.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status,casttype=k8s.io/kubernetes/pkg/api/v1.ConditionStatus"`
// The last time the condition transitioned from one status to another.
LastTransitionTime unversioned.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"`
// The reason for the condition's last transition.
Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"`
// A human readable message indicating details about the transition.
Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
}
// DeploymentConfigList is a collection of deployment configs.
type DeploymentConfigList struct {
unversioned.TypeMeta `json:",inline"`
@@ -421,6 +387,18 @@ type DeploymentConfigRollbackSpec struct {
IncludeStrategy bool `json:"includeStrategy" protobuf:"varint,6,opt,name=includeStrategy"`
}
// DeploymentRequest is a request to a deployment config for a new deployment.
type DeploymentRequest struct {
unversioned.TypeMeta `json:",inline"`
// Name of the deployment config for requesting a new deployment.
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
// Latest will update the deployment config with the latest state from all triggers.
Latest bool `json:"latest" protobuf:"varint,2,opt,name=latest"`
// Force will try to force a new deployment to run. If the deployment config is paused,
// then setting this to true will return an Invalid error.
Force bool `json:"force" protobuf:"varint,3,opt,name=force"`
}
// DeploymentLog represents the logs for a deployment
type DeploymentLog struct {
unversioned.TypeMeta `json:",inline"`
@@ -26,6 +26,8 @@ func RegisterConversions(scheme *runtime.Scheme) error {
Convert_api_DeploymentCause_To_v1_DeploymentCause,
Convert_v1_DeploymentCauseImageTrigger_To_api_DeploymentCauseImageTrigger,
Convert_api_DeploymentCauseImageTrigger_To_v1_DeploymentCauseImageTrigger,
Convert_v1_DeploymentCondition_To_api_DeploymentCondition,
Convert_api_DeploymentCondition_To_v1_DeploymentCondition,
Convert_v1_DeploymentConfig_To_api_DeploymentConfig,
Convert_api_DeploymentConfig_To_v1_DeploymentConfig,
Convert_v1_DeploymentConfigList_To_api_DeploymentConfigList,
@@ -44,6 +46,8 @@ func RegisterConversions(scheme *runtime.Scheme) error {
Convert_api_DeploymentLog_To_v1_DeploymentLog,
Convert_v1_DeploymentLogOptions_To_api_DeploymentLogOptions,
Convert_api_DeploymentLogOptions_To_v1_DeploymentLogOptions,
Convert_v1_DeploymentRequest_To_api_DeploymentRequest,
Convert_api_DeploymentRequest_To_v1_DeploymentRequest,
Convert_v1_DeploymentStrategy_To_api_DeploymentStrategy,
Convert_api_DeploymentStrategy_To_v1_DeploymentStrategy,
Convert_v1_DeploymentTriggerImageChangeParams_To_api_DeploymentTriggerImageChangeParams,
@@ -163,6 +167,36 @@ func Convert_api_DeploymentCauseImageTrigger_To_v1_DeploymentCauseImageTrigger(i
return autoConvert_api_DeploymentCauseImageTrigger_To_v1_DeploymentCauseImageTrigger(in, out, s)
}
func autoConvert_v1_DeploymentCondition_To_api_DeploymentCondition(in *DeploymentCondition, out *api.DeploymentCondition, s conversion.Scope) error {
out.Type = api.DeploymentConditionType(in.Type)
out.Status = pkg_api.ConditionStatus(in.Status)
if err := pkg_api.Convert_unversioned_Time_To_unversioned_Time(&in.LastTransitionTime, &out.LastTransitionTime, s); err != nil {
return err
}
out.Reason = in.Reason
out.Message = in.Message
return nil
}
func Convert_v1_DeploymentCondition_To_api_DeploymentCondition(in *DeploymentCondition, out *api.DeploymentCondition, s conversion.Scope) error {
return autoConvert_v1_DeploymentCondition_To_api_DeploymentCondition(in, out, s)
}
func autoConvert_api_DeploymentCondition_To_v1_DeploymentCondition(in *api.DeploymentCondition, out *DeploymentCondition, s conversion.Scope) error {
out.Type = DeploymentConditionType(in.Type)
out.Status = api_v1.ConditionStatus(in.Status)
if err := pkg_api.Convert_unversioned_Time_To_unversioned_Time(&in.LastTransitionTime, &out.LastTransitionTime, s); err != nil {
return err
}
out.Reason = in.Reason
out.Message = in.Message
return nil
}
func Convert_api_DeploymentCondition_To_v1_DeploymentCondition(in *api.DeploymentCondition, out *DeploymentCondition, s conversion.Scope) error {
return autoConvert_api_DeploymentCondition_To_v1_DeploymentCondition(in, out, s)
}
func autoConvert_v1_DeploymentConfig_To_api_DeploymentConfig(in *DeploymentConfig, out *api.DeploymentConfig, s conversion.Scope) error {
SetDefaults_DeploymentConfig(in)
if err := pkg_api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
@@ -409,6 +443,17 @@ func autoConvert_v1_DeploymentConfigStatus_To_api_DeploymentConfigStatus(in *Dep
} else {
out.Details = nil
}
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]api.DeploymentCondition, len(*in))
for i := range *in {
if err := Convert_v1_DeploymentCondition_To_api_DeploymentCondition(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Conditions = nil
}
return nil
}
@@ -432,6 +477,17 @@ func autoConvert_api_DeploymentConfigStatus_To_v1_DeploymentConfigStatus(in *api
} else {
out.Details = nil
}
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]DeploymentCondition, len(*in))
for i := range *in {
if err := Convert_api_DeploymentCondition_To_v1_DeploymentCondition(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Conditions = nil
}
return nil
}
@@ -543,6 +599,34 @@ func Convert_api_DeploymentLogOptions_To_v1_DeploymentLogOptions(in *api.Deploym
return autoConvert_api_DeploymentLogOptions_To_v1_DeploymentLogOptions(in, out, s)
}
func autoConvert_v1_DeploymentRequest_To_api_DeploymentRequest(in *DeploymentRequest, out *api.DeploymentRequest, s conversion.Scope) error {
if err := pkg_api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
}
out.Name = in.Name
out.Latest = in.Latest
out.Force = in.Force
return nil
}
func Convert_v1_DeploymentRequest_To_api_DeploymentRequest(in *DeploymentRequest, out *api.DeploymentRequest, s conversion.Scope) error {
return autoConvert_v1_DeploymentRequest_To_api_DeploymentRequest(in, out, s)
}
func autoConvert_api_DeploymentRequest_To_v1_DeploymentRequest(in *api.DeploymentRequest, out *DeploymentRequest, s conversion.Scope) error {
if err := pkg_api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
return err
}
out.Name = in.Name
out.Latest = in.Latest
out.Force = in.Force
return nil
}
func Convert_api_DeploymentRequest_To_v1_DeploymentRequest(in *api.DeploymentRequest, out *DeploymentRequest, s conversion.Scope) error {
return autoConvert_api_DeploymentRequest_To_v1_DeploymentRequest(in, out, s)
}
func autoConvert_v1_DeploymentStrategy_To_api_DeploymentStrategy(in *DeploymentStrategy, out *api.DeploymentStrategy, s conversion.Scope) error {
SetDefaults_DeploymentStrategy(in)
out.Type = api.DeploymentStrategyType(in.Type)
@@ -587,6 +671,15 @@ func Convert_v1_DeploymentStrategy_To_api_DeploymentStrategy(in *DeploymentStrat
func autoConvert_api_DeploymentStrategy_To_v1_DeploymentStrategy(in *api.DeploymentStrategy, out *DeploymentStrategy, s conversion.Scope) error {
out.Type = DeploymentStrategyType(in.Type)
if in.CustomParams != nil {
in, out := &in.CustomParams, &out.CustomParams
*out = new(CustomDeploymentStrategyParams)
if err := Convert_api_CustomDeploymentStrategyParams_To_v1_CustomDeploymentStrategyParams(*in, *out, s); err != nil {
return err
}
} else {
out.CustomParams = nil
}
if in.RecreateParams != nil {
in, out := &in.RecreateParams, &out.RecreateParams
*out = new(RecreateDeploymentStrategyParams)
@@ -605,15 +698,6 @@ func autoConvert_api_DeploymentStrategy_To_v1_DeploymentStrategy(in *api.Deploym
} else {
out.RollingParams = nil
}
if in.CustomParams != nil {
in, out := &in.CustomParams, &out.CustomParams
*out = new(CustomDeploymentStrategyParams)
if err := Convert_api_CustomDeploymentStrategyParams_To_v1_CustomDeploymentStrategyParams(*in, *out, s); err != nil {
return err
}
} else {
out.CustomParams = nil
}
if err := api_v1.Convert_api_ResourceRequirements_To_v1_ResourceRequirements(&in.Resources, &out.Resources, s); err != nil {
return err
}
@@ -24,6 +24,7 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_CustomDeploymentStrategyParams, InType: reflect.TypeOf(&CustomDeploymentStrategyParams{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentCause, InType: reflect.TypeOf(&DeploymentCause{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentCauseImageTrigger, InType: reflect.TypeOf(&DeploymentCauseImageTrigger{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentCondition, InType: reflect.TypeOf(&DeploymentCondition{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentConfig, InType: reflect.TypeOf(&DeploymentConfig{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentConfigList, InType: reflect.TypeOf(&DeploymentConfigList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentConfigRollback, InType: reflect.TypeOf(&DeploymentConfigRollback{})},
@@ -33,6 +34,7 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentDetails, InType: reflect.TypeOf(&DeploymentDetails{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentLog, InType: reflect.TypeOf(&DeploymentLog{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentLogOptions, InType: reflect.TypeOf(&DeploymentLogOptions{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentRequest, InType: reflect.TypeOf(&DeploymentRequest{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentStrategy, InType: reflect.TypeOf(&DeploymentStrategy{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentTriggerImageChangeParams, InType: reflect.TypeOf(&DeploymentTriggerImageChangeParams{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_v1_DeploymentTriggerPolicy, InType: reflect.TypeOf(&DeploymentTriggerPolicy{})},
@@ -96,6 +98,19 @@ func DeepCopy_v1_DeploymentCauseImageTrigger(in interface{}, out interface{}, c
}
}
func DeepCopy_v1_DeploymentCondition(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentCondition)
out := out.(*DeploymentCondition)
out.Type = in.Type
out.Status = in.Status
out.LastTransitionTime = in.LastTransitionTime.DeepCopy()
out.Reason = in.Reason
out.Message = in.Message
return nil
}
}
func DeepCopy_v1_DeploymentConfig(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentConfig)
@@ -239,6 +254,17 @@ func DeepCopy_v1_DeploymentConfigStatus(in interface{}, out interface{}, c *conv
} else {
out.Details = nil
}
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]DeploymentCondition, len(*in))
for i := range *in {
if err := DeepCopy_v1_DeploymentCondition(&(*in)[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.Conditions = nil
}
return nil
}
}
@@ -321,6 +347,18 @@ func DeepCopy_v1_DeploymentLogOptions(in interface{}, out interface{}, c *conver
}
}
func DeepCopy_v1_DeploymentRequest(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentRequest)
out := out.(*DeploymentRequest)
out.TypeMeta = in.TypeMeta
out.Name = in.Name
out.Latest = in.Latest
out.Force = in.Force
return nil
}
}
func DeepCopy_v1_DeploymentStrategy(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentStrategy)
@@ -556,13 +594,6 @@ func DeepCopy_v1_RollingDeploymentStrategyParams(in interface{}, out interface{}
} else {
out.MaxSurge = nil
}
if in.UpdatePercent != nil {
in, out := &in.UpdatePercent, &out.UpdatePercent
*out = new(int32)
**out = **in
} else {
out.UpdatePercent = nil
}
if in.Pre != nil {
in, out := &in.Pre, &out.Pre
*out = new(LifecycleHook)
+47 -16
View File
@@ -24,6 +24,7 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_CustomDeploymentStrategyParams, InType: reflect.TypeOf(&CustomDeploymentStrategyParams{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentCause, InType: reflect.TypeOf(&DeploymentCause{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentCauseImageTrigger, InType: reflect.TypeOf(&DeploymentCauseImageTrigger{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentCondition, InType: reflect.TypeOf(&DeploymentCondition{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentConfig, InType: reflect.TypeOf(&DeploymentConfig{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentConfigList, InType: reflect.TypeOf(&DeploymentConfigList{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentConfigRollback, InType: reflect.TypeOf(&DeploymentConfigRollback{})},
@@ -33,6 +34,7 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentDetails, InType: reflect.TypeOf(&DeploymentDetails{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentLog, InType: reflect.TypeOf(&DeploymentLog{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentLogOptions, InType: reflect.TypeOf(&DeploymentLogOptions{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentRequest, InType: reflect.TypeOf(&DeploymentRequest{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentStrategy, InType: reflect.TypeOf(&DeploymentStrategy{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentTriggerImageChangeParams, InType: reflect.TypeOf(&DeploymentTriggerImageChangeParams{})},
conversion.GeneratedDeepCopyFunc{Fn: DeepCopy_api_DeploymentTriggerPolicy, InType: reflect.TypeOf(&DeploymentTriggerPolicy{})},
@@ -97,6 +99,19 @@ func DeepCopy_api_DeploymentCauseImageTrigger(in interface{}, out interface{}, c
}
}
func DeepCopy_api_DeploymentCondition(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentCondition)
out := out.(*DeploymentCondition)
out.Type = in.Type
out.Status = in.Status
out.LastTransitionTime = in.LastTransitionTime.DeepCopy()
out.Reason = in.Reason
out.Message = in.Message
return nil
}
}
func DeepCopy_api_DeploymentConfig(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentConfig)
@@ -240,6 +255,17 @@ func DeepCopy_api_DeploymentConfigStatus(in interface{}, out interface{}, c *con
} else {
out.Details = nil
}
if in.Conditions != nil {
in, out := &in.Conditions, &out.Conditions
*out = make([]DeploymentCondition, len(*in))
for i := range *in {
if err := DeepCopy_api_DeploymentCondition(&(*in)[i], &(*out)[i], c); err != nil {
return err
}
}
} else {
out.Conditions = nil
}
return nil
}
}
@@ -322,11 +348,32 @@ func DeepCopy_api_DeploymentLogOptions(in interface{}, out interface{}, c *conve
}
}
func DeepCopy_api_DeploymentRequest(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentRequest)
out := out.(*DeploymentRequest)
out.TypeMeta = in.TypeMeta
out.Name = in.Name
out.Latest = in.Latest
out.Force = in.Force
return nil
}
}
func DeepCopy_api_DeploymentStrategy(in interface{}, out interface{}, c *conversion.Cloner) error {
{
in := in.(*DeploymentStrategy)
out := out.(*DeploymentStrategy)
out.Type = in.Type
if in.CustomParams != nil {
in, out := &in.CustomParams, &out.CustomParams
*out = new(CustomDeploymentStrategyParams)
if err := DeepCopy_api_CustomDeploymentStrategyParams(*in, *out, c); err != nil {
return err
}
} else {
out.CustomParams = nil
}
if in.RecreateParams != nil {
in, out := &in.RecreateParams, &out.RecreateParams
*out = new(RecreateDeploymentStrategyParams)
@@ -345,15 +392,6 @@ func DeepCopy_api_DeploymentStrategy(in interface{}, out interface{}, c *convers
} else {
out.RollingParams = nil
}
if in.CustomParams != nil {
in, out := &in.CustomParams, &out.CustomParams
*out = new(CustomDeploymentStrategyParams)
if err := DeepCopy_api_CustomDeploymentStrategyParams(*in, *out, c); err != nil {
return err
}
} else {
out.CustomParams = nil
}
if err := pkg_api.DeepCopy_api_ResourceRequirements(&in.Resources, &out.Resources, c); err != nil {
return err
}
@@ -545,13 +583,6 @@ func DeepCopy_api_RollingDeploymentStrategyParams(in interface{}, out interface{
}
out.MaxUnavailable = in.MaxUnavailable
out.MaxSurge = in.MaxSurge
if in.UpdatePercent != nil {
in, out := &in.UpdatePercent, &out.UpdatePercent
*out = new(int32)
**out = **in
} else {
out.UpdatePercent = nil
}
if in.Pre != nil {
in, out := &in.Pre, &out.Pre
*out = new(LifecycleHook)
-136
View File
@@ -1,136 +0,0 @@
package cmd
import (
"time"
"github.com/golang/glog"
kapi "k8s.io/kubernetes/pkg/api"
kerrors "k8s.io/kubernetes/pkg/api/errors"
kclient "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/kubectl"
kutil "k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/wait"
"github.com/openshift/origin/pkg/client"
deployapi "github.com/openshift/origin/pkg/deploy/api"
"github.com/openshift/origin/pkg/deploy/util"
)
// NewDeploymentConfigReaper returns a new reaper for deploymentConfigs
func NewDeploymentConfigReaper(oc client.Interface, kc kclient.Interface) kubectl.Reaper {
return &DeploymentConfigReaper{oc: oc, kc: kc, pollInterval: kubectl.Interval, timeout: kubectl.Timeout}
}
// DeploymentConfigReaper implements the Reaper interface for deploymentConfigs
type DeploymentConfigReaper struct {
oc client.Interface
kc kclient.Interface
pollInterval, timeout time.Duration
}
// pause marks the deployment configuration as paused to avoid triggering new
// deployments.
func (reaper *DeploymentConfigReaper) pause(namespace, name string) (*deployapi.DeploymentConfig, error) {
return client.UpdateConfigWithRetries(reaper.oc, namespace, name, func(d *deployapi.DeploymentConfig) {
d.Spec.RevisionHistoryLimit = kutil.Int32Ptr(0)
d.Spec.Replicas = 0
d.Spec.Paused = true
})
}
// Stop scales a replication controller via its deployment configuration down to
// zero replicas, waits for all of them to get deleted and then deletes both the
// replication controller and its deployment configuration.
func (reaper *DeploymentConfigReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *kapi.DeleteOptions) error {
// Pause the deployment configuration to prevent the new deployments from
// being triggered.
config, err := reaper.pause(namespace, name)
configNotFound := kerrors.IsNotFound(err)
if err != nil && !configNotFound {
return err
}
var (
isPaused bool
legacy bool
)
// Determine if the deployment config controller noticed the pause.
if !configNotFound {
if err := wait.Poll(1*time.Second, 1*time.Minute, func() (bool, error) {
dc, err := reaper.oc.DeploymentConfigs(namespace).Get(name)
if err != nil {
return false, err
}
isPaused = dc.Spec.Paused
return dc.Status.ObservedGeneration >= config.Generation, nil
}); err != nil {
return err
}
// If we failed to pause the deployment config, it means we are talking to
// old API that does not support pausing. In that case, we delete the
// deployment config to stay backward compatible.
if !isPaused {
if err := reaper.oc.DeploymentConfigs(namespace).Delete(name); err != nil {
return err
}
// Setting this to true avoid deleting the config at the end.
legacy = true
}
}
// Clean up deployments related to the config. Even if the deployment
// configuration has been deleted, we want to sweep the existing replication
// controllers and clean them up.
options := kapi.ListOptions{LabelSelector: util.ConfigSelector(name)}
rcList, err := reaper.kc.ReplicationControllers(namespace).List(options)
if err != nil {
return err
}
rcReaper, err := kubectl.ReaperFor(kapi.Kind("ReplicationController"), reaper.kc)
if err != nil {
return err
}
// If there is neither a config nor any deployments, nor any deployer pods, we can return NotFound.
deployments := rcList.Items
if configNotFound && len(deployments) == 0 {
return kerrors.NewNotFound(kapi.Resource("deploymentconfig"), name)
}
for _, rc := range deployments {
if err = rcReaper.Stop(rc.Namespace, rc.Name, timeout, gracePeriod); err != nil {
// Better not error out here...
glog.Infof("Cannot delete ReplicationController %s/%s for deployment config %s/%s: %v", rc.Namespace, rc.Name, namespace, name, err)
}
// Only remove deployer pods when the deployment was failed. For completed
// deployment the pods should be already deleted.
if !util.IsFailedDeployment(&rc) {
continue
}
// Delete all deployer and hook pods
options = kapi.ListOptions{LabelSelector: util.DeployerPodSelector(rc.Name)}
podList, err := reaper.kc.Pods(rc.Namespace).List(options)
if err != nil {
return err
}
for _, pod := range podList.Items {
err := reaper.kc.Pods(pod.Namespace).Delete(pod.Name, gracePeriod)
if err != nil {
// Better not error out here...
glog.Infof("Cannot delete lifecycle Pod %s/%s for deployment config %s/%s: %v", pod.Namespace, pod.Name, namespace, name, err)
}
}
}
// Nothing to delete or we already deleted the deployment config because we
// failed to pause.
if configNotFound || legacy {
return nil
}
return reaper.oc.DeploymentConfigs(namespace).Delete(name)
}
-3
View File
@@ -1,3 +0,0 @@
// Package cmd contains various interface implementations for command-line tools
// associated with deploymentconfigs.
package cmd
-41
View File
@@ -1,41 +0,0 @@
package cmd
import (
"fmt"
"reflect"
kapi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/runtime"
deployapi "github.com/openshift/origin/pkg/deploy/api"
)
var basic = kubectl.BasicReplicationController{}
type BasicDeploymentConfigController struct{}
func (BasicDeploymentConfigController) ParamNames() []kubectl.GeneratorParam {
return basic.ParamNames()
}
func (BasicDeploymentConfigController) Generate(genericParams map[string]interface{}) (runtime.Object, error) {
obj, err := basic.Generate(genericParams)
if err != nil {
return nil, err
}
switch t := obj.(type) {
case *kapi.ReplicationController:
obj = &deployapi.DeploymentConfig{
ObjectMeta: t.ObjectMeta,
Spec: deployapi.DeploymentConfigSpec{
Selector: t.Spec.Selector,
Replicas: t.Spec.Replicas,
Template: t.Spec.Template,
},
}
default:
return nil, fmt.Errorf("unrecognized object type: %v", reflect.TypeOf(t))
}
return obj, nil
}
-99
View File
@@ -1,99 +0,0 @@
package cmd
import (
"bytes"
"fmt"
"sort"
"text/tabwriter"
kapi "k8s.io/kubernetes/pkg/api"
kclient "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/kubectl"
"github.com/openshift/origin/pkg/client"
deployapi "github.com/openshift/origin/pkg/deploy/api"
deployutil "github.com/openshift/origin/pkg/deploy/util"
)
func NewDeploymentConfigHistoryViewer(oc client.Interface, kc kclient.Interface) kubectl.HistoryViewer {
return &DeploymentConfigHistoryViewer{dn: oc, rn: kc}
}
// DeploymentConfigHistoryViewer is an implementation of the kubectl HistoryViewer interface
// for deployment configs.
type DeploymentConfigHistoryViewer struct {
rn kclient.ReplicationControllersNamespacer
dn client.DeploymentConfigsNamespacer
}
var _ kubectl.HistoryViewer = &DeploymentConfigHistoryViewer{}
// ViewHistory returns a description of all the history it can find for a deployment config.
func (h *DeploymentConfigHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error) {
opts := kapi.ListOptions{LabelSelector: deployutil.ConfigSelector(name)}
deploymentList, err := h.rn.ReplicationControllers(namespace).List(opts)
if err != nil {
return "", err
}
history := deploymentList.Items
if len(deploymentList.Items) == 0 {
return "No rollout history found.", nil
}
// Print details of a specific revision
if revision > 0 {
var desired *kapi.PodTemplateSpec
// We could use a binary search here but brute-force is always faster to write
for i := range history {
rc := history[i]
if deployutil.DeploymentVersionFor(&rc) == revision {
desired = rc.Spec.Template
break
}
}
if desired == nil {
return "", fmt.Errorf("unable to find the specified revision")
}
buf := bytes.NewBuffer([]byte{})
kubectl.DescribePodTemplate(desired, buf)
return buf.String(), nil
}
sort.Sort(deployutil.ByLatestVersionAsc(history))
return tabbedString(func(out *tabwriter.Writer) error {
fmt.Fprintf(out, "REVISION\tSTATUS\tCAUSE\n")
for i := range history {
rc := history[i]
rev := deployutil.DeploymentVersionFor(&rc)
status := deployutil.DeploymentStatusFor(&rc)
cause := rc.Annotations[deployapi.DeploymentStatusReasonAnnotation]
if len(cause) == 0 {
cause = "<unknown>"
}
fmt.Fprintf(out, "%d\t%s\t%s\n", rev, status, cause)
}
return nil
})
}
// TODO: Re-use from an utility package
func tabbedString(f func(*tabwriter.Writer) error) (string, error) {
out := new(tabwriter.Writer)
buf := &bytes.Buffer{}
out.Init(buf, 0, 8, 1, '\t', 0)
err := f(out)
if err != nil {
return "", err
}
out.Flush()
str := string(buf.String())
return str, nil
}
-56
View File
@@ -1,56 +0,0 @@
package cmd
import (
"fmt"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/runtime"
"github.com/openshift/origin/pkg/client"
deployapi "github.com/openshift/origin/pkg/deploy/api"
)
func NewDeploymentConfigRollbacker(oc client.Interface) kubectl.Rollbacker {
return &DeploymentConfigRollbacker{dn: oc}
}
// DeploymentConfigRollbacker is an implementation of the kubectl Rollbacker interface
// for deployment configs.
type DeploymentConfigRollbacker struct {
dn client.DeploymentConfigsNamespacer
}
var _ kubectl.Rollbacker = &DeploymentConfigRollbacker{}
// Rollback the provided deployment config to a specific revision. If revision is zero, we will
// rollback to the previous deployment.
func (r *DeploymentConfigRollbacker) Rollback(obj runtime.Object, updatedAnnotations map[string]string, toRevision int64) (string, error) {
config, ok := obj.(*deployapi.DeploymentConfig)
if !ok {
return "", fmt.Errorf("passed object is not a deployment config: %#v", obj)
}
if config.Spec.Paused {
return "", fmt.Errorf("cannot rollback a paused config; resume it first with 'rollout resume dc/%s' and try again", config.Name)
}
rollback := &deployapi.DeploymentConfigRollback{
Name: config.Name,
UpdatedAnnotations: updatedAnnotations,
Spec: deployapi.DeploymentConfigRollbackSpec{
Revision: toRevision,
IncludeTemplate: true,
},
}
rolledback, err := r.dn.DeploymentConfigs(config.Namespace).Rollback(rollback)
if err != nil {
return "", err
}
_, err = r.dn.DeploymentConfigs(config.Namespace).Update(rolledback)
if err != nil {
return "", err
}
return "rolled back", nil
}
-98
View File
@@ -1,98 +0,0 @@
package cmd
import (
"time"
kapi "k8s.io/kubernetes/pkg/api"
kclient "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/util/wait"
"github.com/openshift/origin/pkg/client"
"github.com/openshift/origin/pkg/deploy/util"
)
// NewDeploymentConfigScaler returns a new scaler for deploymentConfigs
func NewDeploymentConfigScaler(oc client.Interface, kc kclient.Interface) kubectl.Scaler {
return &DeploymentConfigScaler{rcClient: kc, dcClient: oc, clientInterface: kc}
}
// DeploymentConfigScaler is a wrapper for the kubectl Scaler client
type DeploymentConfigScaler struct {
rcClient kclient.ReplicationControllersNamespacer
dcClient client.DeploymentConfigsNamespacer
clientInterface kclient.Interface
}
// Scale updates the DeploymentConfig with the provided namespace/name, to a
// new size, with optional precondition check (if preconditions is not nil),
// optional retries (if retry is not nil), and then optionally waits for its
// deployment replica count to reach the new value (if wait is not nil).
func (scaler *DeploymentConfigScaler) Scale(namespace, name string, newSize uint, preconditions *kubectl.ScalePrecondition, retry, waitForReplicas *kubectl.RetryParams) error {
if preconditions == nil {
preconditions = &kubectl.ScalePrecondition{Size: -1, ResourceVersion: ""}
}
if retry == nil {
// Make it try only once, immediately
retry = &kubectl.RetryParams{Interval: time.Millisecond, Timeout: time.Millisecond}
}
cond := kubectl.ScaleCondition(scaler, preconditions, namespace, name, newSize, nil)
if err := wait.Poll(retry.Interval, retry.Timeout, cond); err != nil {
return err
}
// TODO: convert to a watch and use resource version from the ScaleCondition - kubernetes/kubernetes#31051
if waitForReplicas != nil {
dc, err := scaler.dcClient.DeploymentConfigs(namespace).Get(name)
if err != nil {
return err
}
rc, err := scaler.rcClient.ReplicationControllers(namespace).Get(util.LatestDeploymentNameForConfig(dc))
if err != nil {
return err
}
return wait.Poll(waitForReplicas.Interval, waitForReplicas.Timeout, controllerHasSpecifiedReplicas(scaler.clientInterface, rc, dc.Spec.Replicas))
}
return nil
}
// ScaleSimple does a simple one-shot attempt at scaling - not useful on its
// own, but a necessary building block for Scale.
func (scaler *DeploymentConfigScaler) ScaleSimple(namespace, name string, preconditions *kubectl.ScalePrecondition, newSize uint) (string, error) {
scale, err := scaler.dcClient.DeploymentConfigs(namespace).GetScale(name)
if err != nil {
return "", err
}
scale.Spec.Replicas = int32(newSize)
updated, err := scaler.dcClient.DeploymentConfigs(namespace).UpdateScale(scale)
if err != nil {
return "", kubectl.ScaleError{FailureType: kubectl.ScaleUpdateFailure, ResourceVersion: "Unknown", ActualError: err}
}
return updated.ResourceVersion, nil
}
// controllerHasSpecifiedReplicas returns a condition that will be true if and
// only if the specified replica count for a controller's ReplicaSelector
// equals the Replicas count.
//
// This is a slightly modified version of
// unversioned.ControllerHasDesiredReplicas. This is necessary because when
// scaling an RC via a DC, the RC spec replica count is not immediately
// updated to match the owning DC.
func controllerHasSpecifiedReplicas(c kclient.Interface, controller *kapi.ReplicationController, specifiedReplicas int32) wait.ConditionFunc {
// If we're given a controller where the status lags the spec, it either means that the controller is stale,
// or that the rc manager hasn't noticed the update yet. Polling status.Replicas is not safe in the latter case.
desiredGeneration := controller.Generation
return func() (bool, error) {
ctrl, err := c.ReplicationControllers(controller.Namespace).Get(controller.Name)
if err != nil {
return false, err
}
// There's a chance a concurrent update modifies the Spec.Replicas causing this check to pass,
// or, after this check has passed, a modification causes the rc manager to create more pods.
// This will not be an issue once we've implemented graceful delete for rcs, but till then
// concurrent stop operations on the same rc might have unintended side effects.
return ctrl.Status.ObservedGeneration >= desiredGeneration && ctrl.Status.Replicas == specifiedReplicas, nil
}
}
-126
View File
@@ -1,126 +0,0 @@
package analysis
import (
"fmt"
"github.com/gonum/graph"
osgraph "github.com/openshift/origin/pkg/api/graph"
buildedges "github.com/openshift/origin/pkg/build/graph"
buildutil "github.com/openshift/origin/pkg/build/util"
deployedges "github.com/openshift/origin/pkg/deploy/graph"
deploygraph "github.com/openshift/origin/pkg/deploy/graph/nodes"
imageedges "github.com/openshift/origin/pkg/image/graph"
imagegraph "github.com/openshift/origin/pkg/image/graph/nodes"
)
const (
MissingImageStreamErr = "MissingImageStream"
MissingImageStreamTagWarning = "MissingImageStreamTag"
MissingReadinessProbeWarning = "MissingReadinessProbe"
)
// FindDeploymentConfigTriggerErrors checks for possible failures in deployment config
// image change triggers.
//
// Precedence of failures:
// 1. The image stream for the tag of interest does not exist.
// 2. The image stream tag does not exist.
func FindDeploymentConfigTriggerErrors(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
markers := []osgraph.Marker{}
for _, uncastDcNode := range g.NodesByKind(deploygraph.DeploymentConfigNodeKind) {
dcNode := uncastDcNode.(*deploygraph.DeploymentConfigNode)
marker := ictMarker(g, f, dcNode)
if marker != nil {
markers = append(markers, *marker)
}
}
return markers
}
// ictMarker inspects the image change triggers for the provided deploymentconfig and returns
// a marker in case of the following two scenarios:
//
// 1. The image stream pointed by the dc trigger doen not exist.
// 2. The image stream tag pointed by the dc trigger does not exist and there is no build in
// flight that could push to the tag.
func ictMarker(g osgraph.Graph, f osgraph.Namer, dcNode *deploygraph.DeploymentConfigNode) *osgraph.Marker {
for _, uncastIstNode := range g.PredecessorNodesByEdgeKind(dcNode, deployedges.TriggersDeploymentEdgeKind) {
if istNode := uncastIstNode.(*imagegraph.ImageStreamTagNode); !istNode.Found() {
// The image stream for the tag of interest does not exist.
if isNode, exists := doesImageStreamExist(g, uncastIstNode); !exists {
return &osgraph.Marker{
Node: dcNode,
RelatedNodes: []graph.Node{uncastIstNode, isNode},
Severity: osgraph.ErrorSeverity,
Key: MissingImageStreamErr,
Message: fmt.Sprintf("The image trigger for %s will have no effect because %s does not exist.",
f.ResourceName(dcNode), f.ResourceName(isNode)),
// TODO: Suggest `oc create imagestream` once we have that.
}
}
for _, bcNode := range buildedges.BuildConfigsForTag(g, istNode) {
// Avoid warning for the dc image trigger in case there is a build in flight.
if latestBuild := buildedges.GetLatestBuild(g, bcNode); latestBuild != nil && !buildutil.IsBuildComplete(latestBuild.Build) {
return nil
}
}
// The image stream tag of interest does not exist.
return &osgraph.Marker{
Node: dcNode,
RelatedNodes: []graph.Node{uncastIstNode},
Severity: osgraph.WarningSeverity,
Key: MissingImageStreamTagWarning,
Message: fmt.Sprintf("The image trigger for %s will have no effect until %s is imported or created by a build.",
f.ResourceName(dcNode), f.ResourceName(istNode)),
}
}
}
return nil
}
func doesImageStreamExist(g osgraph.Graph, istag graph.Node) (graph.Node, bool) {
for _, imagestream := range g.SuccessorNodesByEdgeKind(istag, imageedges.ReferencedImageStreamGraphEdgeKind) {
return imagestream, imagestream.(*imagegraph.ImageStreamNode).Found()
}
for _, imagestream := range g.SuccessorNodesByEdgeKind(istag, imageedges.ReferencedImageStreamImageGraphEdgeKind) {
return imagestream, imagestream.(*imagegraph.ImageStreamNode).Found()
}
return nil, false
}
// FindDeploymentConfigReadinessWarnings inspects deploymentconfigs and reports those that
// don't have readiness probes set up.
func FindDeploymentConfigReadinessWarnings(g osgraph.Graph, f osgraph.Namer, setProbeCommand string) []osgraph.Marker {
markers := []osgraph.Marker{}
Node:
for _, uncastDcNode := range g.NodesByKind(deploygraph.DeploymentConfigNodeKind) {
dcNode := uncastDcNode.(*deploygraph.DeploymentConfigNode)
if t := dcNode.DeploymentConfig.Spec.Template; t != nil && len(t.Spec.Containers) > 0 {
for _, container := range t.Spec.Containers {
if container.ReadinessProbe != nil {
continue Node
}
}
// All of the containers in the deployment config lack a readiness probe
markers = append(markers, osgraph.Marker{
Node: uncastDcNode,
Severity: osgraph.WarningSeverity,
Key: MissingReadinessProbeWarning,
Message: fmt.Sprintf("%s has no readiness probe to verify pods are ready to accept traffic or ensure deployment is successful.",
f.ResourceName(dcNode)),
Suggestion: osgraph.Suggestion(fmt.Sprintf("%s %s --readiness ...", setProbeCommand, f.ResourceName(dcNode))),
})
continue Node
}
}
return markers
}
-3
View File
@@ -1,3 +0,0 @@
// Package analysis provides functions that analyse deployment configurations and setup markers
// that will be reported by oc status
package analysis
-85
View File
@@ -1,85 +0,0 @@
package graph
import (
"github.com/gonum/graph"
osgraph "github.com/openshift/origin/pkg/api/graph"
kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes"
deployapi "github.com/openshift/origin/pkg/deploy/api"
deploygraph "github.com/openshift/origin/pkg/deploy/graph/nodes"
imageapi "github.com/openshift/origin/pkg/image/api"
imagegraph "github.com/openshift/origin/pkg/image/graph/nodes"
)
const (
// TriggersDeploymentEdgeKind points from DeploymentConfigs to ImageStreamTags that trigger the deployment
TriggersDeploymentEdgeKind = "TriggersDeployment"
// UsedInDeploymentEdgeKind points from DeploymentConfigs to DockerImageReferences that are used in the deployment
UsedInDeploymentEdgeKind = "UsedInDeployment"
// DeploymentEdgeKind points from DeploymentConfigs to the ReplicationControllers that are fulfilling the deployment
DeploymentEdgeKind = "Deployment"
)
// AddTriggerEdges creates edges that point to named Docker image repositories for each image used in the deployment.
func AddTriggerEdges(g osgraph.MutableUniqueGraph, node *deploygraph.DeploymentConfigNode) *deploygraph.DeploymentConfigNode {
podTemplate := node.DeploymentConfig.Spec.Template
if podTemplate == nil {
return node
}
deployapi.EachTemplateImage(
&podTemplate.Spec,
deployapi.DeploymentConfigHasTrigger(node.DeploymentConfig),
func(image deployapi.TemplateImage, err error) {
if err != nil {
return
}
if image.From != nil {
if len(image.From.Name) == 0 {
return
}
name, tag, _ := imageapi.SplitImageStreamTag(image.From.Name)
in := imagegraph.FindOrCreateSyntheticImageStreamTagNode(g, imagegraph.MakeImageStreamTagObjectMeta(image.From.Namespace, name, tag))
g.AddEdge(in, node, TriggersDeploymentEdgeKind)
return
}
tag := image.Ref.Tag
image.Ref.Tag = ""
in := imagegraph.EnsureDockerRepositoryNode(g, image.Ref.String(), tag)
g.AddEdge(in, node, UsedInDeploymentEdgeKind)
})
return node
}
func AddAllTriggerEdges(g osgraph.MutableUniqueGraph) {
for _, node := range g.(graph.Graph).Nodes() {
if dcNode, ok := node.(*deploygraph.DeploymentConfigNode); ok {
AddTriggerEdges(g, dcNode)
}
}
}
func AddDeploymentEdges(g osgraph.MutableUniqueGraph, node *deploygraph.DeploymentConfigNode) *deploygraph.DeploymentConfigNode {
for _, n := range g.(graph.Graph).Nodes() {
if rcNode, ok := n.(*kubegraph.ReplicationControllerNode); ok {
if rcNode.ReplicationController.Namespace != node.DeploymentConfig.Namespace {
continue
}
if BelongsToDeploymentConfig(node.DeploymentConfig, rcNode.ReplicationController) {
g.AddEdge(node, rcNode, DeploymentEdgeKind)
}
}
}
return node
}
func AddAllDeploymentEdges(g osgraph.MutableUniqueGraph) {
for _, node := range g.(graph.Graph).Nodes() {
if dcNode, ok := node.(*deploygraph.DeploymentConfigNode); ok {
AddDeploymentEdges(g, dcNode)
}
}
}
-49
View File
@@ -1,49 +0,0 @@
package graph
import (
"sort"
kapi "k8s.io/kubernetes/pkg/api"
osgraph "github.com/openshift/origin/pkg/api/graph"
kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes"
deployapi "github.com/openshift/origin/pkg/deploy/api"
deploygraph "github.com/openshift/origin/pkg/deploy/graph/nodes"
deployutil "github.com/openshift/origin/pkg/deploy/util"
)
// RelevantDeployments returns the active deployment and a list of inactive deployments (in order from newest to oldest)
func RelevantDeployments(g osgraph.Graph, dcNode *deploygraph.DeploymentConfigNode) (*kubegraph.ReplicationControllerNode, []*kubegraph.ReplicationControllerNode) {
allDeployments := []*kubegraph.ReplicationControllerNode{}
uncastDeployments := g.SuccessorNodesByEdgeKind(dcNode, DeploymentEdgeKind)
if len(uncastDeployments) == 0 {
return nil, []*kubegraph.ReplicationControllerNode{}
}
for i := range uncastDeployments {
allDeployments = append(allDeployments, uncastDeployments[i].(*kubegraph.ReplicationControllerNode))
}
sort.Sort(RecentDeploymentReferences(allDeployments))
if dcNode.DeploymentConfig.Status.LatestVersion == deployutil.DeploymentVersionFor(allDeployments[0].ReplicationController) {
return allDeployments[0], allDeployments[1:]
}
return nil, allDeployments
}
func BelongsToDeploymentConfig(config *deployapi.DeploymentConfig, b *kapi.ReplicationController) bool {
if b.Annotations != nil {
return config.Name == deployutil.DeploymentConfigNameFor(b)
}
return false
}
type RecentDeploymentReferences []*kubegraph.ReplicationControllerNode
func (m RecentDeploymentReferences) Len() int { return len(m) }
func (m RecentDeploymentReferences) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
func (m RecentDeploymentReferences) Less(i, j int) bool {
return deployutil.DeploymentVersionFor(m[i].ReplicationController) > deployutil.DeploymentVersionFor(m[j].ReplicationController)
}
-38
View File
@@ -1,38 +0,0 @@
package nodes
import (
"github.com/gonum/graph"
osgraph "github.com/openshift/origin/pkg/api/graph"
kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes"
depoyapi "github.com/openshift/origin/pkg/deploy/api"
)
// EnsureDeploymentConfigNode adds the provided deployment config to the graph if it does not exist
func EnsureDeploymentConfigNode(g osgraph.MutableUniqueGraph, dc *depoyapi.DeploymentConfig) *DeploymentConfigNode {
dcName := DeploymentConfigNodeName(dc)
dcNode := osgraph.EnsureUnique(
g,
dcName,
func(node osgraph.Node) graph.Node {
return &DeploymentConfigNode{Node: node, DeploymentConfig: dc, IsFound: true}
},
).(*DeploymentConfigNode)
if dc.Spec.Template != nil {
podTemplateSpecNode := kubegraph.EnsurePodTemplateSpecNode(g, dc.Spec.Template, dc.Namespace, dcName)
g.AddEdge(dcNode, podTemplateSpecNode, osgraph.ContainsEdgeKind)
}
return dcNode
}
func FindOrCreateSyntheticDeploymentConfigNode(g osgraph.MutableUniqueGraph, dc *depoyapi.DeploymentConfig) *DeploymentConfigNode {
return osgraph.EnsureUnique(
g,
DeploymentConfigNodeName(dc),
func(node osgraph.Node) graph.Node {
return &DeploymentConfigNode{Node: node, DeploymentConfig: dc, IsFound: false}
},
).(*DeploymentConfigNode)
}
-39
View File
@@ -1,39 +0,0 @@
package nodes
import (
"reflect"
osgraph "github.com/openshift/origin/pkg/api/graph"
deployapi "github.com/openshift/origin/pkg/deploy/api"
)
var (
DeploymentConfigNodeKind = reflect.TypeOf(deployapi.DeploymentConfig{}).Name()
)
func DeploymentConfigNodeName(o *deployapi.DeploymentConfig) osgraph.UniqueName {
return osgraph.GetUniqueRuntimeObjectNodeName(DeploymentConfigNodeKind, o)
}
type DeploymentConfigNode struct {
osgraph.Node
DeploymentConfig *deployapi.DeploymentConfig
IsFound bool
}
func (n DeploymentConfigNode) Found() bool {
return n.IsFound
}
func (n DeploymentConfigNode) Object() interface{} {
return n.DeploymentConfig
}
func (n DeploymentConfigNode) String() string {
return string(DeploymentConfigNodeName(n.DeploymentConfig))
}
func (*DeploymentConfigNode) Kind() string {
return DeploymentConfigNodeKind
}
-496
View File
@@ -1,496 +0,0 @@
package util
import (
"errors"
"fmt"
"sort"
"strconv"
"strings"
"time"
"k8s.io/kubernetes/pkg/api"
kdeplutil "k8s.io/kubernetes/pkg/controller/deployment/util"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
deployapi "github.com/openshift/origin/pkg/deploy/api"
"github.com/openshift/origin/pkg/util/namer"
kclient "k8s.io/kubernetes/pkg/client/unversioned"
)
// LatestDeploymentNameForConfig returns a stable identifier for config based on its version.
func LatestDeploymentNameForConfig(config *deployapi.DeploymentConfig) string {
return fmt.Sprintf("%s-%d", config.Name, config.Status.LatestVersion)
}
// 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 LatestDeploymentInfo(config *deployapi.DeploymentConfig, deployments []api.ReplicationController) (bool, *api.ReplicationController) {
if config.Status.LatestVersion == 0 || len(deployments) == 0 {
return false, nil
}
sort.Sort(ByLatestVersionDesc(deployments))
candidate := &deployments[0]
return DeploymentVersionFor(candidate) == config.Status.LatestVersion, candidate
}
// 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 ActiveDeployment(config *deployapi.DeploymentConfig, input []api.ReplicationController) *api.ReplicationController {
var activeDeployment *api.ReplicationController
var lastCompleteDeploymentVersion int64 = 0
for i := range input {
deployment := &input[i]
deploymentVersion := DeploymentVersionFor(deployment)
if DeploymentStatusFor(deployment) == deployapi.DeploymentStatusComplete && deploymentVersion > lastCompleteDeploymentVersion {
activeDeployment = deployment
lastCompleteDeploymentVersion = deploymentVersion
}
}
return activeDeployment
}
// DeployerPodSuffix is the suffix added to pods created from a deployment
const DeployerPodSuffix = "deploy"
// DeployerPodNameForDeployment returns the name of a pod for a given deployment
func DeployerPodNameForDeployment(deployment string) string {
return namer.GetPodName(deployment, DeployerPodSuffix)
}
// LabelForDeployment builds a string identifier for a Deployment.
func LabelForDeployment(deployment *api.ReplicationController) string {
return fmt.Sprintf("%s/%s", deployment.Namespace, deployment.Name)
}
// LabelForDeploymentConfig builds a string identifier for a DeploymentConfig.
func LabelForDeploymentConfig(config *deployapi.DeploymentConfig) string {
return fmt.Sprintf("%s/%s", config.Namespace, config.Name)
}
// DeploymentNameForConfigVersion returns the name of the version-th deployment
// for the config that has the provided name
func DeploymentNameForConfigVersion(name string, version int64) string {
return fmt.Sprintf("%s-%d", name, version)
}
// 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 ConfigSelector(name string) labels.Selector {
return labels.Set{deployapi.DeploymentConfigAnnotation: name}.AsSelector()
}
// DeployerPodSelector returns a label Selector which can be used to find all
// deployer pods associated with a deployment with name.
func DeployerPodSelector(name string) labels.Selector {
return labels.Set{deployapi.DeployerPodForDeploymentLabel: name}.AsSelector()
}
// AnyDeployerPodSelector returns a label Selector which can be used to find
// all deployer pods across all deployments, including hook and custom
// deployer pods.
func AnyDeployerPodSelector() labels.Selector {
sel, _ := labels.Parse(deployapi.DeployerPodForDeploymentLabel)
return sel
}
// HasChangeTrigger returns whether the provided deployment configuration has
// a config change trigger or not
func HasChangeTrigger(config *deployapi.DeploymentConfig) bool {
for _, trigger := range config.Spec.Triggers {
if trigger.Type == deployapi.DeploymentTriggerOnConfigChange {
return true
}
}
return false
}
func DeploymentConfigDeepCopy(dc *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) {
objCopy, err := api.Scheme.DeepCopy(dc)
if err != nil {
return nil, err
}
copied, ok := objCopy.(*deployapi.DeploymentConfig)
if !ok {
return nil, fmt.Errorf("expected DeploymentConfig, got %#v", objCopy)
}
return copied, nil
}
func DeploymentDeepCopy(rc *api.ReplicationController) (*api.ReplicationController, error) {
objCopy, err := api.Scheme.DeepCopy(rc)
if err != nil {
return nil, err
}
copied, ok := objCopy.(*api.ReplicationController)
if !ok {
return nil, fmt.Errorf("expected ReplicationController, got %#v", objCopy)
}
return copied, nil
}
// DecodeDeploymentConfig decodes a DeploymentConfig from controller using codec. An error is returned
// if the controller doesn't contain an encoded config.
func DecodeDeploymentConfig(controller *api.ReplicationController, decoder runtime.Decoder) (*deployapi.DeploymentConfig, error) {
encodedConfig := []byte(EncodedDeploymentConfigFor(controller))
decoded, err := runtime.Decode(decoder, encodedConfig)
if err != nil {
return nil, fmt.Errorf("failed to decode DeploymentConfig from controller: %v", err)
}
config, ok := decoded.(*deployapi.DeploymentConfig)
if !ok {
return nil, fmt.Errorf("decoded object from controller is not a DeploymentConfig")
}
return config, nil
}
// EncodeDeploymentConfig encodes config as a string using codec.
func EncodeDeploymentConfig(config *deployapi.DeploymentConfig, codec runtime.Codec) (string, error) {
bytes, err := runtime.Encode(codec, config)
if err != nil {
return "", err
}
return string(bytes[:]), nil
}
// MakeDeployment creates a deployment represented as a ReplicationController and based on the given
// DeploymentConfig. The controller replica count will be zero.
func MakeDeployment(config *deployapi.DeploymentConfig, codec runtime.Codec) (*api.ReplicationController, error) {
var err error
var encodedConfig string
if encodedConfig, err = EncodeDeploymentConfig(config, codec); err != nil {
return nil, err
}
deploymentName := LatestDeploymentNameForConfig(config)
podSpec := api.PodSpec{}
if err := api.Scheme.Convert(&config.Spec.Template.Spec, &podSpec, nil); err != nil {
return nil, fmt.Errorf("couldn't clone podSpec: %v", err)
}
controllerLabels := make(labels.Set)
for k, v := range config.Labels {
controllerLabels[k] = v
}
// Correlate the deployment with the config.
// TODO: Using the annotation constant for now since the value is correct
// but we could consider adding a new constant to the public types.
controllerLabels[deployapi.DeploymentConfigAnnotation] = config.Name
// Ensure that pods created by this deployment controller can be safely associated back
// to the controller, and that multiple deployment controllers for the same config don't
// manipulate each others' pods.
selector := map[string]string{}
for k, v := range config.Spec.Selector {
selector[k] = v
}
selector[deployapi.DeploymentConfigLabel] = config.Name
selector[deployapi.DeploymentLabel] = deploymentName
podLabels := make(labels.Set)
for k, v := range config.Spec.Template.Labels {
podLabels[k] = v
}
podLabels[deployapi.DeploymentConfigLabel] = config.Name
podLabels[deployapi.DeploymentLabel] = deploymentName
podAnnotations := make(labels.Set)
for k, v := range config.Spec.Template.Annotations {
podAnnotations[k] = v
}
podAnnotations[deployapi.DeploymentAnnotation] = deploymentName
podAnnotations[deployapi.DeploymentConfigAnnotation] = config.Name
podAnnotations[deployapi.DeploymentVersionAnnotation] = strconv.FormatInt(config.Status.LatestVersion, 10)
deployment := &api.ReplicationController{
ObjectMeta: api.ObjectMeta{
Name: deploymentName,
Namespace: config.Namespace,
Annotations: map[string]string{
deployapi.DeploymentConfigAnnotation: config.Name,
deployapi.DeploymentStatusAnnotation: string(deployapi.DeploymentStatusNew),
deployapi.DeploymentEncodedConfigAnnotation: encodedConfig,
deployapi.DeploymentVersionAnnotation: strconv.FormatInt(config.Status.LatestVersion, 10),
// This is the target replica count for the new deployment.
deployapi.DesiredReplicasAnnotation: strconv.Itoa(int(config.Spec.Replicas)),
deployapi.DeploymentReplicasAnnotation: strconv.Itoa(0),
},
Labels: controllerLabels,
},
Spec: api.ReplicationControllerSpec{
// The deployment should be inactive initially
Replicas: 0,
Selector: selector,
Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: podLabels,
Annotations: podAnnotations,
},
Spec: podSpec,
},
},
}
if config.Status.Details != nil && len(config.Status.Details.Message) > 0 {
deployment.Annotations[deployapi.DeploymentStatusReasonAnnotation] = config.Status.Details.Message
}
if value, ok := config.Annotations[deployapi.DeploymentIgnorePodAnnotation]; ok {
deployment.Annotations[deployapi.DeploymentIgnorePodAnnotation] = value
}
return deployment, nil
}
// GetReplicaCountForDeployments returns the sum of all replicas for the
// given deployments.
func GetReplicaCountForDeployments(deployments []api.ReplicationController) int32 {
totalReplicaCount := int32(0)
for _, deployment := range deployments {
totalReplicaCount += deployment.Spec.Replicas
}
return totalReplicaCount
}
// GetStatusReplicaCountForDeployments returns the sum of the replicas reported in the
// status of the given deployments.
func GetStatusReplicaCountForDeployments(deployments []api.ReplicationController) int32 {
totalReplicaCount := int32(0)
for _, deployment := range deployments {
totalReplicaCount += deployment.Status.Replicas
}
return totalReplicaCount
}
// GetAvailablePods returns all the available pods from the provided pod list.
func GetAvailablePods(pods []*api.Pod, minReadySeconds int32) int32 {
available := int32(0)
for i := range pods {
pod := pods[i]
if kdeplutil.IsPodAvailable(pod, minReadySeconds, time.Now()) {
available++
}
}
return available
}
func DeploymentConfigNameFor(obj runtime.Object) string {
return annotationFor(obj, deployapi.DeploymentConfigAnnotation)
}
func DeploymentNameFor(obj runtime.Object) string {
return annotationFor(obj, deployapi.DeploymentAnnotation)
}
func DeployerPodNameFor(obj runtime.Object) string {
return annotationFor(obj, deployapi.DeploymentPodAnnotation)
}
func DeploymentStatusFor(obj runtime.Object) deployapi.DeploymentStatus {
return deployapi.DeploymentStatus(annotationFor(obj, deployapi.DeploymentStatusAnnotation))
}
func DeploymentStatusReasonFor(obj runtime.Object) string {
return annotationFor(obj, deployapi.DeploymentStatusReasonAnnotation)
}
func DeploymentDesiredReplicas(obj runtime.Object) (int32, bool) {
return int32AnnotationFor(obj, deployapi.DesiredReplicasAnnotation)
}
func DeploymentReplicas(obj runtime.Object) (int32, bool) {
return int32AnnotationFor(obj, deployapi.DeploymentReplicasAnnotation)
}
func EncodedDeploymentConfigFor(obj runtime.Object) string {
return annotationFor(obj, deployapi.DeploymentEncodedConfigAnnotation)
}
func DeploymentVersionFor(obj runtime.Object) int64 {
v, err := strconv.ParseInt(annotationFor(obj, deployapi.DeploymentVersionAnnotation), 10, 64)
if err != nil {
return -1
}
return v
}
func IsDeploymentCancelled(deployment *api.ReplicationController) bool {
value := annotationFor(deployment, deployapi.DeploymentCancelledAnnotation)
return strings.EqualFold(value, deployapi.DeploymentCancelledAnnotationValue)
}
func HasSynced(dc *deployapi.DeploymentConfig) bool {
return dc.Status.ObservedGeneration >= dc.Generation
}
// 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 IsOwnedByConfig(deployment *api.ReplicationController) bool {
_, ok := deployment.Annotations[deployapi.DeploymentConfigAnnotation]
return ok
}
// IsTerminatedDeployment returns true if the passed deployment has terminated (either
// complete or failed).
func IsTerminatedDeployment(deployment *api.ReplicationController) bool {
current := DeploymentStatusFor(deployment)
return current == deployapi.DeploymentStatusComplete || current == deployapi.DeploymentStatusFailed
}
// IsFailedDeployment returns true if the passed deployment failed.
func IsFailedDeployment(deployment *api.ReplicationController) bool {
current := DeploymentStatusFor(deployment)
return current == deployapi.DeploymentStatusFailed
}
// CanTransitionPhase returns whether it is allowed to go from the current to the next phase.
func CanTransitionPhase(current, next deployapi.DeploymentStatus) bool {
switch current {
case deployapi.DeploymentStatusNew:
switch next {
case deployapi.DeploymentStatusPending,
deployapi.DeploymentStatusRunning,
deployapi.DeploymentStatusFailed,
deployapi.DeploymentStatusComplete:
return true
}
case deployapi.DeploymentStatusPending:
switch next {
case deployapi.DeploymentStatusRunning,
deployapi.DeploymentStatusFailed,
deployapi.DeploymentStatusComplete:
return true
}
case deployapi.DeploymentStatusRunning:
switch next {
case deployapi.DeploymentStatusFailed, deployapi.DeploymentStatusComplete:
return true
}
}
return false
}
// annotationFor returns the annotation with key for obj.
func annotationFor(obj runtime.Object, key string) string {
meta, err := api.ObjectMetaFor(obj)
if err != nil {
return ""
}
return meta.Annotations[key]
}
func int32AnnotationFor(obj runtime.Object, key string) (int32, bool) {
s := annotationFor(obj, key)
if len(s) == 0 {
return 0, false
}
i, err := strconv.ParseInt(s, 10, 32)
if err != nil {
return 0, false
}
return int32(i), true
}
// DeploymentsForCleanup determines which deployments for a configuration are relevant for the
// revision history limit quota
func DeploymentsForCleanup(configuration *deployapi.DeploymentConfig, deployments []api.ReplicationController) []api.ReplicationController {
// if the past deployment quota has been exceeded, we need to prune the oldest deployments
// until we are not exceeding the quota any longer, so we sort oldest first
sort.Sort(ByLatestVersionAsc(deployments))
relevantDeployments := []api.ReplicationController{}
activeDeployment := ActiveDeployment(configuration, deployments)
if activeDeployment == nil {
// if cleanup policy is set but no successful deployments have happened, there will be
// no active deployment. We can consider all of the deployments in this case except for
// the latest one
for i := range deployments {
deployment := &deployments[i]
if DeploymentVersionFor(deployment) != configuration.Status.LatestVersion {
relevantDeployments = append(relevantDeployments, *deployment)
}
}
} else {
// if there is an active deployment, we need to filter out any deployments that we don't
// care about, namely the active deployment and any newer deployments
for i := range deployments {
deployment := &deployments[i]
if deployment != activeDeployment && DeploymentVersionFor(deployment) < DeploymentVersionFor(activeDeployment) {
relevantDeployments = append(relevantDeployments, *deployment)
}
}
}
return relevantDeployments
}
// WaitForRunningDeployerPod waits a given period of time until the deployer pod
// for given replication controller is not running.
func WaitForRunningDeployerPod(podClient kclient.PodsNamespacer, rc *api.ReplicationController, timeout time.Duration) error {
podName := DeployerPodNameForDeployment(rc.Name)
canGetLogs := func(p *api.Pod) bool {
return api.PodSucceeded == p.Status.Phase || api.PodFailed == p.Status.Phase || api.PodRunning == p.Status.Phase
}
pod, err := podClient.Pods(rc.Namespace).Get(podName)
if err == nil && canGetLogs(pod) {
return nil
}
watcher, err := podClient.Pods(rc.Namespace).Watch(
api.ListOptions{
FieldSelector: fields.Set{"metadata.name": podName}.AsSelector(),
},
)
if err != nil {
return err
}
defer watcher.Stop()
if _, err := watch.Until(timeout, watcher, func(e watch.Event) (bool, error) {
if e.Type == watch.Error {
return false, fmt.Errorf("encountered error while watching for pod: %v", e.Object)
}
obj, isPod := e.Object.(*api.Pod)
if !isPod {
return false, errors.New("received unknown object while watching for pods")
}
return canGetLogs(obj), nil
}); err != nil {
return err
}
return nil
}
// ByLatestVersionAsc sorts deployments by LatestVersion ascending.
type ByLatestVersionAsc []api.ReplicationController
func (d ByLatestVersionAsc) Len() int { return len(d) }
func (d ByLatestVersionAsc) Swap(i, j int) { d[i], d[j] = d[j], d[i] }
func (d ByLatestVersionAsc) Less(i, j int) bool {
return DeploymentVersionFor(&d[i]) < DeploymentVersionFor(&d[j])
}
// ByLatestVersionDesc sorts deployments by LatestVersion descending.
type ByLatestVersionDesc []api.ReplicationController
func (d ByLatestVersionDesc) Len() int { return len(d) }
func (d ByLatestVersionDesc) Swap(i, j int) { d[i], d[j] = d[j], d[i] }
func (d ByLatestVersionDesc) Less(i, j int) bool {
return DeploymentVersionFor(&d[j]) < DeploymentVersionFor(&d[i])
}
// ByMostRecent sorts deployments by most recently created.
type ByMostRecent []*api.ReplicationController
func (s ByMostRecent) Len() int { return len(s) }
func (s ByMostRecent) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s ByMostRecent) Less(i, j int) bool {
return !s[i].CreationTimestamp.Before(s[j].CreationTimestamp)
}