-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Kayenta): Support canaryConfigName as canary identifier (#3215)
- Allow canaries to be specified via canaryConfigName, in addition to canaryConfigId. - canaryConfigId is still the default, and if it is provided, no additional work is necessary. - if canaryConfigId is null, then if a canaryConfigName is provided, it can be used, together with the currentApplication name, to resolve a valid canaryConfigId using the Kayenta `/canaryConfig` end point. - Once a list of candidate canaryConfigIds is produced, an additional check is performed to ensure only one candidate was returned. If no candidates were found, an error is thrown, and likewise if more than one candidate matches on both canaryConfigName and the current application name, an error is thrown.
- Loading branch information
nisanharamati
committed
Oct 4, 2019
1 parent
109c3b2
commit 3d9eaf5
Showing
7 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ta/src/main/kotlin/com/netflix/spinnaker/orca/kayenta/tasks/ResolveKayentaConfigIdTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.netflix.spinnaker.orca.kayenta.tasks | ||
|
||
import com.netflix.spinnaker.orca.ExecutionStatus.SUCCEEDED | ||
import com.netflix.spinnaker.orca.Task | ||
import com.netflix.spinnaker.orca.TaskResult | ||
import com.netflix.spinnaker.orca.ext.mapTo | ||
import com.netflix.spinnaker.orca.kayenta.KayentaService | ||
import com.netflix.spinnaker.orca.pipeline.model.Stage | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class ResolveKayentaConfigIdTask( | ||
private val kayentaService: KayentaService | ||
) : Task { | ||
|
||
private val log = LoggerFactory.getLogger(javaClass) | ||
|
||
override fun execute(stage: Stage): TaskResult { | ||
val configName = stage.mapTo<String?>("/canaryConfigName") | ||
val currentApplication = stage.execution.application | ||
val canaryConfigList = kayentaService.getAllCanaryConfigs() | ||
val candidates = canaryConfigList.asSequence() | ||
.filter { it.name == configName && it.applications.contains(currentApplication) } | ||
.toList() | ||
|
||
if (candidates.size == 0) { | ||
throw NoSuchElementException("Couldn't find a configId for configName $configName and application $currentApplication") | ||
} else if (candidates.size > 1) { | ||
throw IllegalArgumentException("Found more than one configId for configName $configName and application $currentApplication") | ||
} | ||
return TaskResult.builder(SUCCEEDED).context("canaryConfigId", candidates[0].id).build() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters