Skip to content

Commit

Permalink
feat(clouddriver): Look ahead region detection for "aws" can be disab…
Browse files Browse the repository at this point in the history
…led (spinnaker#3959)

Similar to the bake stage, `skipRegionDetection` can be used to determine
whether or not additional regions are inferred from downstream deploy stages.

The default value is `false` which preserves the existing behavior.

```
{
  ...
  "skipRegionDetection": true
}

```
  • Loading branch information
ajordens authored Oct 8, 2020
1 parent 308d0be commit b6e3811
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class FindImageFromClusterTask extends AbstractCloudProviderAwareTask implements
List<String> zones
List<String> namespaces
Boolean onlyEnabled = true
Boolean skipRegionDetection = false
Boolean resolveMissingLocations
SelectionStrategy selectionStrategy = SelectionStrategy.NEWEST
String imageNamePattern
Expand Down Expand Up @@ -124,7 +125,7 @@ class FindImageFromClusterTask extends AbstractCloudProviderAwareTask implements
Map<Location, String> imageIds = [:]
Set<String> inferredRegions = new HashSet<>()

if (cloudProvider == 'aws') {
if (cloudProvider == 'aws' && !config.skipRegionDetection) {
// Supplement config with regions from subsequent deploy/canary stages:
def deployRegions = regionCollector.getRegionsFromChildStages(stage)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,24 @@ class FindImageFromClusterTaskSpec extends Specification {
['foo-x86_64-201603232351'] | ['foo-x86_64-201603232351'] as Set
}

@Unroll
// @Unroll
def "should resolve images via find if not all regions exist in source server group"() {
given:
def pipe = pipeline {
application = "contextAppName" // Should be ignored.
}
def stage = new StageExecutionImpl(pipe, "findImage", [
resolveMissingLocations: true,
cloudProvider : cloudProvider,
cluster : "foo-test",
account : "test",
selectionStrategy : "LARGEST",
onlyEnabled : "false",
regions : [
location1.value
//Note: location2.value will come from regionCollectorResponse below
]
resolveMissingLocations: true,
cloudProvider : cloudProvider,
cluster : "foo-test",
account : "test",
selectionStrategy : "LARGEST",
onlyEnabled : "false",
skipRegionDetection : shouldSkipRegionDetection,
regions : [
location1.value
//Note: location2.value will come from regionCollectorResponse below
]
])

when:
Expand All @@ -218,7 +219,7 @@ class FindImageFromClusterTaskSpec extends Specification {
it.region == "north"
} as Map, [imageName: "ami-012-name-ebs"])

if (cloudProvider == "aws") {
if (cloudProvider == "aws" && !shouldSkipRegionDetection) {
assertSouth(result.outputs?.deploymentDetails?.find {
it.region == "south"
} as Map, [sourceServerGroup: "foo-test", imageName: "ami-012-name-ebs1", foo: "bar"])
Expand Down Expand Up @@ -259,9 +260,10 @@ class FindImageFromClusterTaskSpec extends Specification {
]
]

cloudProvider || findCalls
"aws" || 1
"gcp" || 0
cloudProvider | shouldSkipRegionDetection || findCalls
"aws" | false || 1
"aws" | true || 0
"gcp" | false || 0
}

def "should resolve images via find if not all regions exist in source server group without build info"() {
Expand Down

0 comments on commit b6e3811

Please sign in to comment.