Skip to content

Commit

Permalink
feat(strategies): wait period before disable for rolling push and rol…
Browse files Browse the repository at this point in the history
…ling red black (spinnaker#1587)
  • Loading branch information
tomaslin authored Sep 1, 2017
1 parent 1dfc2df commit e9c0550
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.netflix.spinnaker.orca.clouddriver.pipeline.cluster.DisableClusterSta
import com.netflix.spinnaker.orca.clouddriver.pipeline.cluster.ScaleDownClusterStage
import com.netflix.spinnaker.orca.clouddriver.pipeline.cluster.ShrinkClusterStage
import com.netflix.spinnaker.orca.kato.pipeline.support.StageData
import com.netflix.spinnaker.orca.pipeline.WaitStage
import com.netflix.spinnaker.orca.pipeline.model.Execution
import com.netflix.spinnaker.orca.pipeline.model.Stage
import com.netflix.spinnaker.orca.pipeline.model.SyntheticStageOwner
Expand All @@ -43,6 +44,9 @@ class RedBlackStrategy implements Strategy, ApplicationContextAware {
@Autowired
DisableClusterStage disableClusterStage

@Autowired
WaitStage waitStage

ApplicationContext applicationContext

@Override
Expand Down Expand Up @@ -80,6 +84,18 @@ class RedBlackStrategy implements Strategy, ApplicationContextAware {
)
}

if(stageData?.delayBeforeDisableSec) {
def waitContext = [waitTime: stageData?.delayBeforeDisableSec]
stages << newStage(
stage.execution,
waitStage.type,
"wait",
waitContext,
stage,
SyntheticStageOwner.STAGE_AFTER
)
}

def disableContext = baseContext + [
remainingEnabledServerGroups: 1,
preferLargerOverNewer : false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.support.Deter
import com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.support.TargetServerGroup
import com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.support.TargetServerGroupResolver
import com.netflix.spinnaker.orca.kato.pipeline.support.SourceResolver
import com.netflix.spinnaker.orca.pipeline.WaitStage
import com.netflix.spinnaker.orca.pipeline.model.Execution
import com.netflix.spinnaker.orca.pipeline.model.Stage
import com.netflix.spinnaker.orca.pipeline.model.SyntheticStageOwner
Expand All @@ -27,6 +28,9 @@ class RollingRedBlackStrategy implements Strategy, ApplicationContextAware {
@Autowired
ResizeServerGroupStage resizeServerGroupStage

@Autowired
WaitStage waitStage

@Autowired
DetermineTargetServerGroupStage determineTargetServerGroupStage

Expand Down Expand Up @@ -116,6 +120,18 @@ class RollingRedBlackStrategy implements Strategy, ApplicationContextAware {
preferLargerOverNewer : false
]

if(stageData?.delayBeforeDisableSec) {
def waitContext = [waitTime: stageData?.delayBeforeDisableSec]
stages << newStage(
stage.execution,
waitStage.type,
"wait",
waitContext,
stage,
SyntheticStageOwner.STAGE_AFTER
)
}

stages << newStage(
stage.execution,
disableClusterStage.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class StageData {
Boolean useSourceCapacity
Boolean preferSourceCapacity
Source source
long delayBeforeDisableSec

String getCluster() {
def builder = new AutoScalingGroupNameBuilder()
Expand Down

0 comments on commit e9c0550

Please sign in to comment.