Skip to content

Commit

Permalink
feat(destroy): Add a flag to be able to skip the disable of destroy s…
Browse files Browse the repository at this point in the history
…tage (spinnaker#3858)

Add an experimental flag `skipDisableBeforeDestroy` to the `DestroyServerGroupStage` so that applications that don't participate in discovery can skip disable step which should speed up their destruction operation.

Co-authored-by: Adam Jordens <adam@jordens.org>
  • Loading branch information
marchello2000 and ajordens authored Aug 13, 2020
1 parent 9d1ff48 commit 03bb515
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ import com.netflix.spinnaker.orca.clouddriver.tasks.MonitorKatoTask
import com.netflix.spinnaker.orca.clouddriver.tasks.servergroup.DestroyServerGroupTask
import com.netflix.spinnaker.orca.clouddriver.tasks.servergroup.WaitForDestroyedServerGroupTask
import com.netflix.spinnaker.orca.pipeline.graph.StageGraphBuilderImpl
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
class DestroyServerGroupStage extends TargetServerGroupLinearStageSupport implements ForceCacheRefreshAware {
private static final Logger log = LoggerFactory.getLogger(DestroyServerGroupStage.class)

static final String PIPELINE_CONFIG_TYPE = "destroyServerGroup"

private final DynamicConfigService dynamicConfigService
Expand All @@ -40,10 +44,18 @@ class DestroyServerGroupStage extends TargetServerGroupLinearStageSupport implem
}

private static void addDisableStage(Map<String, Object> context, StageGraphBuilderImpl graph) {
graph.add {
it.name = "disableServerGroup"
it.type = getType(DisableServerGroupStage)
it.context.putAll(context)
boolean skipDisable = (boolean)context.getOrDefault("skipDisableBeforeDestroy", false)

if (!skipDisable) {
// conditional opt-out for server groups where an explicit disable is unnecessary
// (ie. they do not register in service discovery or a load balancer)
graph.add {
it.name = "disableServerGroup"
it.type = getType(DisableServerGroupStage)
it.context.putAll(context)
}
} else {
log.info("DisableServerGroupStage has been skipped (skipDisableBeforeDestroy: true)")
}
}

Expand Down

0 comments on commit 03bb515

Please sign in to comment.