-
Notifications
You must be signed in to change notification settings - Fork 811
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
159 additions
and
14 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
52 changes: 52 additions & 0 deletions
52
orca-mine/src/main/groovy/com/netflix/spinnaker/orca/mine/tasks/DisableCanaryTask.groovy
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,52 @@ | ||
package com.netflix.spinnaker.orca.mine.tasks | ||
|
||
import com.netflix.spinnaker.orca.ExecutionStatus | ||
import com.netflix.spinnaker.orca.Task | ||
import com.netflix.spinnaker.orca.TaskResult | ||
import com.netflix.spinnaker.orca.clouddriver.KatoService | ||
import com.netflix.spinnaker.orca.clouddriver.tasks.AbstractCloudProviderAwareTask | ||
import com.netflix.spinnaker.orca.mine.MineService | ||
import com.netflix.spinnaker.orca.pipeline.model.Stage | ||
import groovy.util.logging.Slf4j | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.stereotype.Component | ||
import retrofit.RetrofitError | ||
|
||
@Component | ||
@Slf4j | ||
class DisableCanaryTask extends AbstractCloudProviderAwareTask implements Task { | ||
|
||
@Autowired MineService mineService | ||
@Autowired KatoService katoService | ||
|
||
@Override | ||
TaskResult execute(Stage stage) { | ||
|
||
try { | ||
def canary = mineService.getCanary(stage.context.canary.id) | ||
if (canary.health?.health == 'UNHEALTHY') { | ||
// If unhealthy, already disabled in MonitorCanaryTask | ||
return TaskResult.SUCCEEDED | ||
} | ||
} catch (RetrofitError e) { | ||
log.error("Exception occurred while getting canary status with id {} from mine, continuing with disable", | ||
stage.context.canary.id, e) | ||
} | ||
|
||
def selector = stage.context.containsKey('disabledCluster') ? 'baselineCluster' : 'canaryCluster' | ||
def ops = DeployedClustersUtil.toKatoAsgOperations('disableServerGroup', stage.context, selector) | ||
def dSG = DeployedClustersUtil.getDeployServerGroups(stage.context) | ||
|
||
log.info "Disabling ${selector} in ${stage.id} with ${ops}" | ||
String cloudProvider = ops && !ops.empty ? ops.first()?.values().first()?.cloudProvider : getCloudProvider(stage) ?: 'aws' | ||
def taskId = katoService.requestOperations(cloudProvider, ops).toBlocking().first() | ||
|
||
stage.context.remove('waitTaskState') | ||
return new TaskResult(ExecutionStatus.SUCCEEDED, [ | ||
'kato.last.task.id' : taskId, | ||
'deploy.server.groups' : dSG, | ||
disabledCluster : selector, | ||
waitTime : 120 // Seconds | ||
]) | ||
} | ||
} |
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