Skip to content

Commit

Permalink
Oort get server groups (#1680)
Browse files Browse the repository at this point in the history
* Add new clouddriver getServerGroup endpoint

* Add new clouddriver getServerGroup endpoint

* Removed frigga from oortHelper

* Rename oortService method for clearity

* Overload getServerGroups and deprecate old prototype

* Update test

* Also deprecate on the DelegatedOortService
  • Loading branch information
andrewbackes authored and lwander committed Oct 12, 2017
1 parent 05049ae commit 7c4eccc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ public Response getServerGroups(String app) {
return getService().getServerGroups(app);
}

@Deprecated
@Override
public Response getServerGroup(String app, String account, String region, String serverGroup) {
return getService().getServerGroup(app, account, region, serverGroup);
}

@Override
public Response getServerGroup(String account, String serverGroup, String region) {
return getService().getServerGroup(account, serverGroup, region);
}

@Override
public Response getTargetServerGroup(String app, String account, String cluster, String cloudProvider, String scope, String target) {
return getService().getTargetServerGroup(app, account, cluster, cloudProvider, scope, target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,17 @@ interface OortService {
@Query("region") String region,
@Path("cloudProvider") String cloudProvider)

@Deprecated
@GET("/applications/{app}/serverGroups/{account}/{region}/{serverGroup}")
Response getServerGroup(@Path("app") String app,
@Path("account") String account,
@Path("region") String region,
@Path("serverGroup") String serverGroup)
@Path("account") String account,
@Path("region") String region,
@Path("serverGroup") String serverGroup)

@GET("/serverGroups/{account}/{region}/{serverGroup}")
Response getServerGroup(@Path("account") String account,
@Path("region") String region,
@Path("serverGroup") String serverGroup)

@GET("/applications/{app}/clusters/{account}/{cluster}/{cloudProvider}/{scope}/serverGroups/target/{target}")
Response getTargetServerGroup(@Path("app") String app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.netflix.spinnaker.orca.clouddriver.utils

import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.frigga.Names
import com.netflix.spinnaker.orca.clouddriver.OortService
import com.netflix.spinnaker.orca.clouddriver.pipeline.servergroup.support.TargetServerGroup
import org.springframework.beans.factory.annotation.Autowired
Expand Down Expand Up @@ -59,15 +58,7 @@ class OortHelper {
String serverGroupName,
String location,
String cloudProvider) {
def name = Names.parseName(serverGroupName)
return convertedResponse(List) { oortService.getServerGroupFromCluster(name.app, account, name.cluster, serverGroupName, null, cloudProvider) }
.map({ List<Map> serverGroups ->
serverGroups.find {
it.region == location || it.zones?.contains(location) || it.namespace == location
}
}).map({ Map serverGroup ->
new TargetServerGroup(serverGroup)
})
return new TargetServerGroup(convert(oortService.getServerGroup(account, location, serverGroupName) , Map))
}

public <T> Optional<T> convertedResponse(Class<T> type, Closure<Response> request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class WaitForNewUpInstancesLaunchTask implements RetryableTask {

// similar check in `AbstractInstancesCheckTask`
def response = oortService.getServerGroup(
stageData.application,
stageData.account,
stage.context.region as String,
stage.context.asgName as String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class WaitForNewUpInstancesLaunchTaskSpec extends Specification {
def response = task.execute(stage)

then:
1 * oortService.getServerGroup(application, account, region, serverGroup) >> oortResponse
1 * oortService.getServerGroup(account, region, serverGroup) >> oortResponse
response.status == expectedStatus


Expand Down

0 comments on commit 7c4eccc

Please sign in to comment.