Skip to content

Commit

Permalink
fix(wait for *): Allow min/max/desired to be strings (cos expressions)
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher committed May 21, 2019
1 parent 6c57ca9 commit 79eec77
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@

package com.netflix.spinnaker.orca.clouddriver.tasks.instance

import java.util.concurrent.TimeUnit
import com.netflix.spinnaker.orca.clouddriver.utils.HealthHelper
import com.netflix.spinnaker.orca.clouddriver.utils.HealthHelper.HealthCountSnapshot
import com.netflix.spinnaker.orca.pipeline.model.Stage
import groovy.util.logging.Slf4j
import org.slf4j.MDC
import org.springframework.stereotype.Component

import java.util.concurrent.TimeUnit

@Component
@Slf4j
class WaitForUpInstancesTask extends AbstractWaitingForInstancesTask {
Expand Down Expand Up @@ -120,7 +119,7 @@ class WaitForUpInstancesTask extends AbstractWaitingForInstancesTask {
Integer targetDesiredSize

if (useConfiguredCapacity(stage, currentCapacity)) {
targetDesiredSize = ((Map<String, Integer>) stage.context.capacity).desired
targetDesiredSize = ((Map<String, Integer>) stage.context.capacity).desired as Integer
splainer.add("setting targetDesiredSize=${targetDesiredSize} from the configured stage context.capacity=${stage.context.capacity}")
} else {
targetDesiredSize = currentCapacity.desired as Integer
Expand Down Expand Up @@ -158,7 +157,9 @@ class WaitForUpInstancesTask extends AbstractWaitingForInstancesTask {
// targetDesired from the configured capacity. This relaxes the need for clouddriver onDemand
// cache updates while resizing serverGroups.
static boolean useConfiguredCapacity(Stage stage, Map<String, Integer> current) {
Map<String, Integer> configured = stage.context.getOrDefault("capacity", [:]) as Map<String, Integer>
Map<String, Integer> configured =
(stage.context.getOrDefault("capacity", [:]))
.collectEntries { k, v -> [(k): v as Integer] } as Map<String, Integer>

if (configured.desired == null) {
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class WaitForCapacityMatchTask extends AbstractInstancesCheckTask {
Integer desired

if (WaitForUpInstancesTask.useConfiguredCapacity(stage, serverGroup.capacity as Map<String, Integer>)) {
desired = ((Map<String, Integer>) stage.context.capacity).desired
desired = ((Map<String, Integer>) stage.context.capacity).desired as Integer
splainer.add("using desired from stage.context.capacity ($desired)")
} else {
desired = ((Map<String, Integer>)serverGroup.capacity).desired
Expand Down
Loading

0 comments on commit 79eec77

Please sign in to comment.