| ... | ... |
@@ -3,7 +3,6 @@ package deploymentconfig |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"reflect" |
| 6 |
- "strconv" |
|
| 7 | 6 |
|
| 8 | 7 |
"github.com/golang/glog" |
| 9 | 8 |
|
| ... | ... |
@@ -110,35 +109,34 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) |
| 110 | 110 |
} |
| 111 | 111 |
// Cancel running deployments. |
| 112 | 112 |
awaitingCancellations = true |
| 113 |
- if !deployutil.IsDeploymentCancelled(&deployment) {
|
|
| 114 |
- |
|
| 115 |
- // Retry faster on conflicts |
|
| 116 |
- var updatedDeployment *kapi.ReplicationController |
|
| 117 |
- if err := kclient.RetryOnConflict(kclient.DefaultBackoff, func() error {
|
|
| 118 |
- rc, err := c.rcStore.ReplicationControllers(deployment.Namespace).Get(deployment.Name) |
|
| 119 |
- if kapierrors.IsNotFound(err) {
|
|
| 120 |
- return nil |
|
| 121 |
- } |
|
| 122 |
- if err != nil {
|
|
| 123 |
- return err |
|
| 124 |
- } |
|
| 125 |
- copied, err := deployutil.DeploymentDeepCopy(rc) |
|
| 126 |
- if err != nil {
|
|
| 127 |
- return err |
|
| 128 |
- } |
|
| 129 |
- copied.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue |
|
| 130 |
- copied.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledNewerDeploymentExists |
|
| 131 |
- updatedDeployment, err = c.rn.ReplicationControllers(copied.Namespace).Update(copied) |
|
| 113 |
+ if deployutil.IsDeploymentCancelled(&deployment) {
|
|
| 114 |
+ continue |
|
| 115 |
+ } |
|
| 116 |
+ |
|
| 117 |
+ // Retry faster on conflicts |
|
| 118 |
+ var updatedDeployment *kapi.ReplicationController |
|
| 119 |
+ if err := kclient.RetryOnConflict(kclient.DefaultBackoff, func() error {
|
|
| 120 |
+ rc, err := c.rcStore.ReplicationControllers(deployment.Namespace).Get(deployment.Name) |
|
| 121 |
+ if kapierrors.IsNotFound(err) {
|
|
| 122 |
+ return nil |
|
| 123 |
+ } |
|
| 124 |
+ if err != nil {
|
|
| 132 | 125 |
return err |
| 133 |
- }); err != nil {
|
|
| 134 |
- c.recorder.Eventf(config, kapi.EventTypeWarning, "DeploymentCancellationFailed", "Failed to cancel deployment %q superceded by version %d: %s", deployment.Name, config.Status.LatestVersion, err) |
|
| 135 |
- } else {
|
|
| 136 |
- if updatedDeployment != nil {
|
|
| 137 |
- // replace the current deployment with the updated copy so that a future update has a chance at working |
|
| 138 |
- existingDeployments[i] = *updatedDeployment |
|
| 139 |
- c.recorder.Eventf(config, kapi.EventTypeNormal, "DeploymentCancelled", "Cancelled deployment %q superceded by version %d", deployment.Name, config.Status.LatestVersion) |
|
| 140 |
- } |
|
| 141 | 126 |
} |
| 127 |
+ copied, err := deployutil.DeploymentDeepCopy(rc) |
|
| 128 |
+ if err != nil {
|
|
| 129 |
+ return err |
|
| 130 |
+ } |
|
| 131 |
+ copied.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue |
|
| 132 |
+ copied.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledNewerDeploymentExists |
|
| 133 |
+ updatedDeployment, err = c.rn.ReplicationControllers(copied.Namespace).Update(copied) |
|
| 134 |
+ return err |
|
| 135 |
+ }); err != nil {
|
|
| 136 |
+ c.recorder.Eventf(config, kapi.EventTypeWarning, "DeploymentCancellationFailed", "Failed to cancel deployment %q superceded by version %d: %s", deployment.Name, config.Status.LatestVersion, err) |
|
| 137 |
+ } else if updatedDeployment != nil {
|
|
| 138 |
+ // replace the current deployment with the updated copy so that a future update has a chance at working |
|
| 139 |
+ existingDeployments[i] = *updatedDeployment |
|
| 140 |
+ c.recorder.Eventf(config, kapi.EventTypeNormal, "DeploymentCancelled", "Cancelled deployment %q superceded by version %d", deployment.Name, config.Status.LatestVersion) |
|
| 142 | 141 |
} |
| 143 | 142 |
} |
| 144 | 143 |
} |
| ... | ... |
@@ -208,90 +206,8 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) |
| 208 | 208 |
// successful deployment, not necessarily the latest in terms of the config |
| 209 | 209 |
// version. The active deployment replica count should follow the config, and |
| 210 | 210 |
// all other deployments should be scaled to zero. |
| 211 |
-// |
|
| 212 |
-// Previously, scaling behavior was that the config replica count was used |
|
| 213 |
-// only for initial deployments and the active deployment had to be scaled up |
|
| 214 |
-// directly. To continue supporting that old behavior we must detect when the |
|
| 215 |
-// deployment has been directly manipulated, and if so, preserve the directly |
|
| 216 |
-// updated value and sync the config with the deployment. |
|
| 217 | 211 |
func (c *DeploymentConfigController) reconcileDeployments(existingDeployments []kapi.ReplicationController, config *deployapi.DeploymentConfig) error {
|
| 218 |
- latestIsDeployed, latestDeployment := deployutil.LatestDeploymentInfo(config, existingDeployments) |
|
| 219 |
- if !latestIsDeployed {
|
|
| 220 |
- // We shouldn't be reconciling if the latest deployment hasn't been |
|
| 221 |
- // created; this is enforced on the calling side, but double checking |
|
| 222 |
- // can't hurt. |
|
| 223 |
- return c.updateStatus(config, existingDeployments) |
|
| 224 |
- } |
|
| 225 | 212 |
activeDeployment := deployutil.ActiveDeployment(existingDeployments) |
| 226 |
- // Compute the replica count for the active deployment (even if the active |
|
| 227 |
- // deployment doesn't exist). The active replica count is the value that |
|
| 228 |
- // should be assigned to the config, to allow the replica propagation to |
|
| 229 |
- // flow downward from the config. |
|
| 230 |
- // |
|
| 231 |
- // By default we'll assume the config replicas should be used to update the |
|
| 232 |
- // active deployment except in special cases (like first sync or externally |
|
| 233 |
- // updated deployments.) |
|
| 234 |
- activeReplicas := config.Spec.Replicas |
|
| 235 |
- source := "the deploymentConfig itself (no change)" |
|
| 236 |
- |
|
| 237 |
- activeDeploymentExists := activeDeployment != nil |
|
| 238 |
- activeDeploymentIsLatest := activeDeploymentExists && activeDeployment.Name == latestDeployment.Name |
|
| 239 |
- latestDesiredReplicas, latestHasDesiredReplicas := deployutil.DeploymentDesiredReplicas(latestDeployment) |
|
| 240 |
- |
|
| 241 |
- switch {
|
|
| 242 |
- case activeDeploymentExists && activeDeploymentIsLatest: |
|
| 243 |
- // The active/latest deployment follows the config unless this is its first |
|
| 244 |
- // sync or if an external change to the deployment replicas is detected. |
|
| 245 |
- lastActiveReplicas, hasLastActiveReplicas := deployutil.DeploymentReplicas(activeDeployment) |
|
| 246 |
- if !hasLastActiveReplicas || lastActiveReplicas != activeDeployment.Spec.Replicas {
|
|
| 247 |
- activeReplicas = activeDeployment.Spec.Replicas |
|
| 248 |
- source = fmt.Sprintf("the latest/active deployment %q which was scaled directly or has not previously been synced", deployutil.LabelForDeployment(activeDeployment))
|
|
| 249 |
- } |
|
| 250 |
- case activeDeploymentExists && !activeDeploymentIsLatest: |
|
| 251 |
- // The active/non-latest deployment follows the config if it was |
|
| 252 |
- // previously synced; if this is the first sync, infer what the config |
|
| 253 |
- // value should be based on either the latest desired or whatever the |
|
| 254 |
- // deployment is currently scaled to. |
|
| 255 |
- _, hasLastActiveReplicas := deployutil.DeploymentReplicas(activeDeployment) |
|
| 256 |
- if hasLastActiveReplicas {
|
|
| 257 |
- break |
|
| 258 |
- } |
|
| 259 |
- if latestHasDesiredReplicas {
|
|
| 260 |
- activeReplicas = latestDesiredReplicas |
|
| 261 |
- source = fmt.Sprintf("the desired replicas of latest deployment %q which has not been previously synced", deployutil.LabelForDeployment(latestDeployment))
|
|
| 262 |
- } else if activeDeployment.Spec.Replicas > 0 {
|
|
| 263 |
- activeReplicas = activeDeployment.Spec.Replicas |
|
| 264 |
- source = fmt.Sprintf("the active deployment %q which has not been previously synced", deployutil.LabelForDeployment(activeDeployment))
|
|
| 265 |
- } |
|
| 266 |
- case !activeDeploymentExists && latestHasDesiredReplicas: |
|
| 267 |
- // If there's no active deployment, use the latest desired, if available. |
|
| 268 |
- activeReplicas = latestDesiredReplicas |
|
| 269 |
- source = fmt.Sprintf("the desired replicas of latest deployment %q with no active deployment", deployutil.LabelForDeployment(latestDeployment))
|
|
| 270 |
- } |
|
| 271 |
- |
|
| 272 |
- // Bring the config in sync with the deployment. Once we know the config |
|
| 273 |
- // accurately represents the desired replica count of the active deployment, |
|
| 274 |
- // we can safely reconcile deployments. |
|
| 275 |
- // |
|
| 276 |
- // If the deployment config is test, never update the deployment config based |
|
| 277 |
- // on deployments, since test behavior overrides user scaling. |
|
| 278 |
- switch {
|
|
| 279 |
- case config.Spec.Replicas == activeReplicas: |
|
| 280 |
- case config.Spec.Test: |
|
| 281 |
- glog.V(4).Infof("Detected changed replicas for test deploymentConfig %q, ignoring that change", deployutil.LabelForDeploymentConfig(config))
|
|
| 282 |
- default: |
|
| 283 |
- copied, err := deployutil.DeploymentConfigDeepCopy(config) |
|
| 284 |
- if err != nil {
|
|
| 285 |
- return err |
|
| 286 |
- } |
|
| 287 |
- oldReplicas := copied.Spec.Replicas |
|
| 288 |
- copied.Spec.Replicas = activeReplicas |
|
| 289 |
- config, err = c.dn.DeploymentConfigs(copied.Namespace).Update(copied) |
|
| 290 |
- if err != nil {
|
|
| 291 |
- return err |
|
| 292 |
- } |
|
| 293 |
- glog.V(4).Infof("Synced deploymentConfig %q replicas from %d to %d based on %s", deployutil.LabelForDeploymentConfig(config), oldReplicas, activeReplicas, source)
|
|
| 294 |
- } |
|
| 295 | 213 |
|
| 296 | 214 |
// Reconcile deployments. The active deployment follows the config, and all |
| 297 | 215 |
// other deployments should be scaled to zero. |
| ... | ... |
@@ -305,16 +221,16 @@ func (c *DeploymentConfigController) reconcileDeployments(existingDeployments [] |
| 305 | 305 |
oldReplicaCount := deployment.Spec.Replicas |
| 306 | 306 |
newReplicaCount := int32(0) |
| 307 | 307 |
if isActiveDeployment {
|
| 308 |
- newReplicaCount = activeReplicas |
|
| 308 |
+ newReplicaCount = config.Spec.Replicas |
|
| 309 | 309 |
} |
| 310 | 310 |
if config.Spec.Test {
|
| 311 | 311 |
glog.V(4).Infof("Deployment config %q is test and deployment %q will be scaled down", deployutil.LabelForDeploymentConfig(config), deployutil.LabelForDeployment(&deployment))
|
| 312 | 312 |
newReplicaCount = 0 |
| 313 | 313 |
} |
| 314 |
- lastReplicas, hasLastReplicas := deployutil.DeploymentReplicas(&deployment) |
|
| 314 |
+ |
|
| 315 | 315 |
// Only update if necessary. |
| 316 | 316 |
var copied *kapi.ReplicationController |
| 317 |
- if !hasLastReplicas || newReplicaCount != oldReplicaCount || lastReplicas != newReplicaCount {
|
|
| 317 |
+ if newReplicaCount != oldReplicaCount {
|
|
| 318 | 318 |
if err := kclient.RetryOnConflict(kclient.DefaultBackoff, func() error {
|
| 319 | 319 |
// refresh the replication controller version |
| 320 | 320 |
rc, err := c.rcStore.ReplicationControllers(deployment.Namespace).Get(deployment.Name) |
| ... | ... |
@@ -327,22 +243,15 @@ func (c *DeploymentConfigController) reconcileDeployments(existingDeployments [] |
| 327 | 327 |
return err |
| 328 | 328 |
} |
| 329 | 329 |
copied.Spec.Replicas = newReplicaCount |
| 330 |
- copied.Annotations[deployapi.DeploymentReplicasAnnotation] = strconv.Itoa(int(newReplicaCount)) |
|
| 331 |
- _, err = c.rn.ReplicationControllers(copied.Namespace).Update(copied) |
|
| 330 |
+ copied, err = c.rn.ReplicationControllers(copied.Namespace).Update(copied) |
|
| 332 | 331 |
return err |
| 333 | 332 |
}); err != nil {
|
| 334 |
- c.recorder.Eventf(config, kapi.EventTypeWarning, "DeploymentScaleFailed", |
|
| 335 |
- "Failed to scale deployment %q from %d to %d: %v", deployment.Name, oldReplicaCount, newReplicaCount, err) |
|
| 333 |
+ c.recorder.Eventf(config, kapi.EventTypeWarning, "ReplicationControllerScaleFailed", |
|
| 334 |
+ "Failed to scale replication controler %q from %d to %d: %v", deployment.Name, oldReplicaCount, newReplicaCount, err) |
|
| 336 | 335 |
return err |
| 337 | 336 |
} |
| 338 | 337 |
|
| 339 |
- // Only report scaling events if we changed the replica count. |
|
| 340 |
- if oldReplicaCount != newReplicaCount {
|
|
| 341 |
- c.recorder.Eventf(config, kapi.EventTypeNormal, "DeploymentScaled", |
|
| 342 |
- "Scaled deployment %q from %d to %d", copied.Name, oldReplicaCount, newReplicaCount) |
|
| 343 |
- } else {
|
|
| 344 |
- glog.V(4).Infof("Updated deployment %q replica annotation to match current replica count %d", deployutil.LabelForDeployment(copied), newReplicaCount)
|
|
| 345 |
- } |
|
| 338 |
+ c.recorder.Eventf(config, kapi.EventTypeNormal, "ReplicationControllerScaled", "Scaled replication controller %q from %d to %d", copied.Name, oldReplicaCount, newReplicaCount) |
|
| 346 | 339 |
toAppend = *copied |
| 347 | 340 |
} |
| 348 | 341 |
|
| ... | ... |
@@ -351,8 +260,8 @@ func (c *DeploymentConfigController) reconcileDeployments(existingDeployments [] |
| 351 | 351 |
|
| 352 | 352 |
// As the deployment configuration has changed, we need to make sure to clean |
| 353 | 353 |
// up old deployments if we have now reached our deployment history quota |
| 354 |
- if err := c.cleanupOldDeployments(existingDeployments, config); err != nil {
|
|
| 355 |
- c.recorder.Eventf(config, kapi.EventTypeWarning, "DeploymentCleanupFailed", "Couldn't clean up deployments: %v", err) |
|
| 354 |
+ if err := c.cleanupOldDeployments(updatedDeployments, config); err != nil {
|
|
| 355 |
+ c.recorder.Eventf(config, kapi.EventTypeWarning, "ReplicationControllerCleanupFailed", "Couldn't clean up replication controllers: %v", err) |
|
| 356 | 356 |
} |
| 357 | 357 |
|
| 358 | 358 |
return c.updateStatus(config, updatedDeployments) |
| ... | ... |
@@ -49,11 +49,6 @@ func TestHandleScenarios(t *testing.T) {
|
| 49 | 49 |
deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue |
| 50 | 50 |
deployment.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledNewerDeploymentExists |
| 51 | 51 |
} |
| 52 |
- if d.replicasA != nil {
|
|
| 53 |
- deployment.Annotations[deployapi.DeploymentReplicasAnnotation] = strconv.Itoa(int(*d.replicasA)) |
|
| 54 |
- } else {
|
|
| 55 |
- delete(deployment.Annotations, deployapi.DeploymentReplicasAnnotation) |
|
| 56 |
- } |
|
| 57 | 52 |
if d.desiredA != nil {
|
| 58 | 53 |
deployment.Annotations[deployapi.DesiredReplicasAnnotation] = strconv.Itoa(int(*d.desiredA)) |
| 59 | 54 |
} else {
|
| ... | ... |
@@ -330,295 +325,6 @@ func TestHandleScenarios(t *testing.T) {
|
| 330 | 330 |
}, |
| 331 | 331 |
errExpected: false, |
| 332 | 332 |
}, |
| 333 |
- // The cases below will exercise backwards compatibility for resources |
|
| 334 |
- // which predate the use of the replica annotation. |
|
| 335 |
- {
|
|
| 336 |
- name: "(compat) initial deployment already in progress", |
|
| 337 |
- replicas: 1, |
|
| 338 |
- newVersion: 1, |
|
| 339 |
- expectedReplicas: 1, |
|
| 340 |
- before: []deployment{
|
|
| 341 |
- {version: 1, replicas: 1, desiredA: newInt32(1), status: deployapi.DeploymentStatusNew, cancelled: false},
|
|
| 342 |
- }, |
|
| 343 |
- after: []deployment{
|
|
| 344 |
- {version: 1, replicas: 1, desiredA: newInt32(1), status: deployapi.DeploymentStatusNew, cancelled: false},
|
|
| 345 |
- }, |
|
| 346 |
- errExpected: false, |
|
| 347 |
- }, |
|
| 348 |
- {
|
|
| 349 |
- name: "(compat) new version", |
|
| 350 |
- replicas: 1, |
|
| 351 |
- newVersion: 2, |
|
| 352 |
- expectedReplicas: 1, |
|
| 353 |
- before: []deployment{
|
|
| 354 |
- {version: 1, replicas: 1, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 355 |
- }, |
|
| 356 |
- after: []deployment{
|
|
| 357 |
- {version: 1, replicas: 1, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 358 |
- {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusNew, cancelled: false},
|
|
| 359 |
- }, |
|
| 360 |
- errExpected: false, |
|
| 361 |
- }, |
|
| 362 |
- {
|
|
| 363 |
- name: "(compat) already in progress", |
|
| 364 |
- replicas: 1, |
|
| 365 |
- newVersion: 2, |
|
| 366 |
- expectedReplicas: 1, |
|
| 367 |
- before: []deployment{
|
|
| 368 |
- {version: 1, replicas: 1, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 369 |
- {version: 2, replicas: 0, desiredA: newInt32(1), status: deployapi.DeploymentStatusNew, cancelled: false},
|
|
| 370 |
- }, |
|
| 371 |
- after: []deployment{
|
|
| 372 |
- {version: 1, replicas: 1, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 373 |
- {version: 2, replicas: 0, desiredA: newInt32(1), status: deployapi.DeploymentStatusNew, cancelled: false},
|
|
| 374 |
- }, |
|
| 375 |
- errExpected: false, |
|
| 376 |
- }, |
|
| 377 |
- {
|
|
| 378 |
- name: "(compat) already deployed", |
|
| 379 |
- replicas: 1, |
|
| 380 |
- newVersion: 1, |
|
| 381 |
- expectedReplicas: 1, |
|
| 382 |
- before: []deployment{
|
|
| 383 |
- {version: 1, replicas: 1, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 384 |
- }, |
|
| 385 |
- after: []deployment{
|
|
| 386 |
- {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 387 |
- }, |
|
| 388 |
- errExpected: false, |
|
| 389 |
- }, |
|
| 390 |
- {
|
|
| 391 |
- name: "(compat) awaiting cancellation of older deployments", |
|
| 392 |
- replicas: 1, |
|
| 393 |
- newVersion: 3, |
|
| 394 |
- expectedReplicas: 1, |
|
| 395 |
- before: []deployment{
|
|
| 396 |
- {version: 1, replicas: 1, desiredA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 397 |
- {version: 2, replicas: 1, desiredA: newInt32(1), status: deployapi.DeploymentStatusRunning, cancelled: false},
|
|
| 398 |
- }, |
|
| 399 |
- after: []deployment{
|
|
| 400 |
- {version: 1, replicas: 1, desiredA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 401 |
- {version: 2, replicas: 1, desiredA: newInt32(1), status: deployapi.DeploymentStatusRunning, cancelled: true},
|
|
| 402 |
- }, |
|
| 403 |
- errExpected: true, |
|
| 404 |
- }, |
|
| 405 |
- {
|
|
| 406 |
- name: "(compat) awaiting cancellation of older deployments (already cancelled)", |
|
| 407 |
- replicas: 1, |
|
| 408 |
- newVersion: 2, |
|
| 409 |
- expectedReplicas: 1, |
|
| 410 |
- before: []deployment{
|
|
| 411 |
- {version: 1, replicas: 1, desiredA: newInt32(1), status: deployapi.DeploymentStatusRunning, cancelled: true},
|
|
| 412 |
- }, |
|
| 413 |
- after: []deployment{
|
|
| 414 |
- {version: 1, replicas: 1, desiredA: newInt32(1), status: deployapi.DeploymentStatusRunning, cancelled: true},
|
|
| 415 |
- }, |
|
| 416 |
- errExpected: true, |
|
| 417 |
- }, |
|
| 418 |
- {
|
|
| 419 |
- name: "(compat) steady state replica corrections (latest == active)", |
|
| 420 |
- replicas: 5, |
|
| 421 |
- newVersion: 5, |
|
| 422 |
- expectedReplicas: 1, |
|
| 423 |
- before: []deployment{
|
|
| 424 |
- {version: 1, replicas: 0, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 425 |
- {version: 2, replicas: 1, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 426 |
- {version: 3, replicas: 1, desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 427 |
- {version: 4, replicas: 0, desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false},
|
|
| 428 |
- {version: 5, replicas: 1, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 429 |
- }, |
|
| 430 |
- after: []deployment{
|
|
| 431 |
- {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 432 |
- {version: 2, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 433 |
- {version: 3, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 434 |
- {version: 4, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false},
|
|
| 435 |
- {version: 5, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 436 |
- }, |
|
| 437 |
- errExpected: false, |
|
| 438 |
- }, |
|
| 439 |
- {
|
|
| 440 |
- name: "(compat) steady state replica corrections of a test config (latest == active)", |
|
| 441 |
- test: true, |
|
| 442 |
- replicas: 5, |
|
| 443 |
- newVersion: 5, |
|
| 444 |
- expectedReplicas: 5, |
|
| 445 |
- before: []deployment{
|
|
| 446 |
- {version: 1, replicas: 0, status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 447 |
- {version: 2, replicas: 1, status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 448 |
- {version: 3, replicas: 1, desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true, test: true},
|
|
| 449 |
- {version: 4, replicas: 0, desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false, test: true},
|
|
| 450 |
- {version: 5, replicas: 1, status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 451 |
- }, |
|
| 452 |
- after: []deployment{
|
|
| 453 |
- {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 454 |
- {version: 2, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 455 |
- {version: 3, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true, test: true},
|
|
| 456 |
- {version: 4, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false, test: true},
|
|
| 457 |
- {version: 5, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 458 |
- }, |
|
| 459 |
- errExpected: false, |
|
| 460 |
- }, |
|
| 461 |
- {
|
|
| 462 |
- name: "(compat) steady state replica corrections (latest != active)", |
|
| 463 |
- replicas: 5, |
|
| 464 |
- newVersion: 5, |
|
| 465 |
- expectedReplicas: 1, |
|
| 466 |
- before: []deployment{
|
|
| 467 |
- {version: 1, replicas: 0, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 468 |
- {version: 2, replicas: 1, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 469 |
- {version: 3, replicas: 1, desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 470 |
- {version: 4, replicas: 0, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 471 |
- {version: 5, replicas: 0, desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false},
|
|
| 472 |
- }, |
|
| 473 |
- after: []deployment{
|
|
| 474 |
- {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 475 |
- {version: 2, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 476 |
- {version: 3, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 477 |
- {version: 4, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 478 |
- {version: 5, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false},
|
|
| 479 |
- }, |
|
| 480 |
- errExpected: false, |
|
| 481 |
- }, |
|
| 482 |
- {
|
|
| 483 |
- name: "(compat) already deployed, no active deployment", |
|
| 484 |
- replicas: 2, |
|
| 485 |
- newVersion: 2, |
|
| 486 |
- expectedReplicas: 1, |
|
| 487 |
- before: []deployment{
|
|
| 488 |
- {version: 1, replicas: 0, desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false},
|
|
| 489 |
- {version: 2, replicas: 0, desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false},
|
|
| 490 |
- }, |
|
| 491 |
- after: []deployment{
|
|
| 492 |
- {version: 1, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false},
|
|
| 493 |
- {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false},
|
|
| 494 |
- }, |
|
| 495 |
- errExpected: false, |
|
| 496 |
- }, |
|
| 497 |
- {
|
|
| 498 |
- name: "(compat) scale up latest/active completed deployment", |
|
| 499 |
- replicas: 1, |
|
| 500 |
- newVersion: 2, |
|
| 501 |
- expectedReplicas: 5, |
|
| 502 |
- before: []deployment{
|
|
| 503 |
- {version: 1, replicas: 0, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 504 |
- {version: 2, replicas: 5, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 505 |
- }, |
|
| 506 |
- after: []deployment{
|
|
| 507 |
- {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 508 |
- {version: 2, replicas: 5, replicasA: newInt32(5), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 509 |
- }, |
|
| 510 |
- errExpected: false, |
|
| 511 |
- }, |
|
| 512 |
- {
|
|
| 513 |
- name: "(compat) scale up latest/active completed test deployment", |
|
| 514 |
- test: true, |
|
| 515 |
- replicas: 1, |
|
| 516 |
- newVersion: 2, |
|
| 517 |
- expectedReplicas: 1, |
|
| 518 |
- before: []deployment{
|
|
| 519 |
- {version: 1, replicas: 0, status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 520 |
- {version: 2, replicas: 5, status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 521 |
- }, |
|
| 522 |
- after: []deployment{
|
|
| 523 |
- {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 524 |
- {version: 2, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 525 |
- }, |
|
| 526 |
- errExpected: false, |
|
| 527 |
- }, |
|
| 528 |
- {
|
|
| 529 |
- name: "(compat) scale up latest/active running test deployment", |
|
| 530 |
- test: true, |
|
| 531 |
- replicas: 1, |
|
| 532 |
- newVersion: 2, |
|
| 533 |
- expectedReplicas: 1, |
|
| 534 |
- before: []deployment{
|
|
| 535 |
- {version: 1, replicas: 0, status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 536 |
- {version: 2, replicas: 5, status: deployapi.DeploymentStatusRunning, cancelled: false, test: true},
|
|
| 537 |
- }, |
|
| 538 |
- after: []deployment{
|
|
| 539 |
- {version: 1, replicas: 0, replicasA: nil, status: deployapi.DeploymentStatusComplete, cancelled: false, test: true},
|
|
| 540 |
- {version: 2, replicas: 5, replicasA: nil, status: deployapi.DeploymentStatusRunning, cancelled: false, test: true},
|
|
| 541 |
- }, |
|
| 542 |
- errExpected: false, |
|
| 543 |
- }, |
|
| 544 |
- // No longer supported. |
|
| 545 |
- {
|
|
| 546 |
- name: "(compat) scale up active (not latest) completed deployment (RC targetted directly)", |
|
| 547 |
- replicas: 2, |
|
| 548 |
- newVersion: 2, |
|
| 549 |
- expectedReplicas: 1, |
|
| 550 |
- before: []deployment{
|
|
| 551 |
- {version: 1, replicas: 5, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 552 |
- {version: 2, replicas: 0, desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 553 |
- }, |
|
| 554 |
- after: []deployment{
|
|
| 555 |
- {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 556 |
- {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 557 |
- }, |
|
| 558 |
- errExpected: false, |
|
| 559 |
- }, |
|
| 560 |
- {
|
|
| 561 |
- name: "(compat) scale up active (not latest) completed deployment (RC targetted via oc)", |
|
| 562 |
- replicas: 1, |
|
| 563 |
- newVersion: 2, |
|
| 564 |
- expectedReplicas: 2, |
|
| 565 |
- before: []deployment{
|
|
| 566 |
- {version: 1, replicas: 2, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 567 |
- {version: 2, replicas: 5, desiredA: newInt32(2), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 568 |
- }, |
|
| 569 |
- after: []deployment{
|
|
| 570 |
- {version: 1, replicas: 2, replicasA: newInt32(2), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 571 |
- {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(2), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 572 |
- }, |
|
| 573 |
- errExpected: false, |
|
| 574 |
- }, |
|
| 575 |
- {
|
|
| 576 |
- name: "(compat) fallback to last completed deployment", |
|
| 577 |
- replicas: 3, |
|
| 578 |
- newVersion: 2, |
|
| 579 |
- expectedReplicas: 1, |
|
| 580 |
- before: []deployment{
|
|
| 581 |
- {version: 1, replicas: 0, status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 582 |
- {version: 2, replicas: 0, desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 583 |
- }, |
|
| 584 |
- after: []deployment{
|
|
| 585 |
- {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 586 |
- {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 587 |
- }, |
|
| 588 |
- errExpected: false, |
|
| 589 |
- }, |
|
| 590 |
- // The cases below exercise old clients performing scaling operations |
|
| 591 |
- // against new resources and controller behavior. |
|
| 592 |
- {
|
|
| 593 |
- name: "(compat-2) scale up latest/active completed deployment (via oc)", |
|
| 594 |
- replicas: 1, |
|
| 595 |
- newVersion: 2, |
|
| 596 |
- expectedReplicas: 2, |
|
| 597 |
- before: []deployment{
|
|
| 598 |
- {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 599 |
- {version: 2, replicas: 2, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 600 |
- }, |
|
| 601 |
- after: []deployment{
|
|
| 602 |
- {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 603 |
- {version: 2, replicas: 2, replicasA: newInt32(2), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 604 |
- }, |
|
| 605 |
- errExpected: false, |
|
| 606 |
- }, |
|
| 607 |
- {
|
|
| 608 |
- name: "(compat-2) scale up active (not latest) completed deployment (via oc)", |
|
| 609 |
- replicas: 1, |
|
| 610 |
- newVersion: 2, |
|
| 611 |
- expectedReplicas: 1, |
|
| 612 |
- before: []deployment{
|
|
| 613 |
- {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 614 |
- {version: 2, replicas: 2, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 615 |
- }, |
|
| 616 |
- after: []deployment{
|
|
| 617 |
- {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false},
|
|
| 618 |
- {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true},
|
|
| 619 |
- }, |
|
| 620 |
- errExpected: false, |
|
| 621 |
- }, |
|
| 622 | 333 |
} |
| 623 | 334 |
|
| 624 | 335 |
for _, test := range tests {
|