From 3fea9a7e8ad2cef990058b3bee56f5d114616051 Mon Sep 17 00:00:00 2001 From: Daniel Reynaud Date: Wed, 29 Jan 2020 10:04:08 -0800 Subject: [PATCH 1/3] feat(selector): select based on kork's RequestContext --- .editorconfig | 1 + .../spinnaker/gate/config/GateConfig.groovy | 20 ++++++-- .../controllers/CapabilitiesController.java | 9 ++-- .../gate/controllers/ConcourseController.java | 5 +- .../controllers/ExecutionsController.java | 11 ++--- .../PipelineConfigController.groovy | 4 +- .../gate/controllers/SubnetController.groovy | 5 +- .../interceptors/RequestIdInterceptor.java | 2 +- .../gate/services/ArtifactService.java | 10 ++-- .../gate/services/CertificateService.groovy | 4 +- .../gate/services/CloudMetricService.groovy | 4 +- .../gate/services/ClusterService.groovy | 10 ++-- .../gate/services/DataService.groovy | 4 +- .../gate/services/EntityTagsService.groovy | 4 +- .../services/ExecutionHistoryService.groovy | 11 ++--- .../gate/services/ImageService.groovy | 6 +-- .../gate/services/InstanceService.groovy | 4 +- .../spinnaker/gate/services/JobService.groovy | 4 +- .../gate/services/LoadBalancerService.groovy | 10 ++-- .../gate/services/NetworkService.groovy | 4 +- .../gate/services/PipelineService.groovy | 26 +++++------ .../services/PipelineTemplateService.groovy | 2 +- .../gate/services/ProjectService.groovy | 4 +- .../gate/services/SearchService.groovy | 2 +- .../gate/services/SecurityGroupService.groovy | 10 ++-- .../gate/services/ServerGroupService.groovy | 8 ++-- .../gate/services/TaskService.groovy | 18 ++++---- .../services/V2PipelineTemplateService.java | 3 +- .../gate/services/WebhookService.groovy | 2 +- .../appengine/StorageAccountService.java | 3 +- .../services/aws/InfrastructureService.groovy | 12 ++--- .../internal/ClouddriverServiceSelector.java | 46 ++++++++----------- .../internal/OrcaServiceSelector.java | 21 +++++---- .../spinnaker/gate/FunctionalSpec.groovy | 24 +++------- .../gate/services/InstanceServiceSpec.groovy | 2 +- .../gate/services/PipelineServiceSpec.groovy | 6 +-- .../services/ServerGroupServiceSpec.groovy | 2 +- gradle.properties | 2 +- 38 files changed, 154 insertions(+), 171 deletions(-) diff --git a/.editorconfig b/.editorconfig index 79621be8e4..726377da60 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,3 +7,4 @@ insert_final_newline = true trim_trailing_whitespace = true indent_style = space indent_size = 2 +continuation_indent_size = 4 \ No newline at end of file diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy index ca04e8ca29..c6a06afd58 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy @@ -37,6 +37,8 @@ import com.netflix.spinnaker.gate.retrofit.Slf4jRetrofitLogger import com.netflix.spinnaker.gate.services.EurekaLookupService import com.netflix.spinnaker.gate.services.internal.* import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService +import com.netflix.spinnaker.kork.web.context.AuthenticatedRequestContextProvider +import com.netflix.spinnaker.kork.web.context.RequestContextProvider import com.netflix.spinnaker.kork.web.selector.DefaultServiceSelector import com.netflix.spinnaker.kork.web.selector.SelectableService import com.netflix.spinnaker.kork.web.selector.ServiceSelector @@ -161,8 +163,13 @@ class GateConfig extends RedisHttpSessionConfiguration { } @Bean - OrcaServiceSelector orcaServiceSelector(OkHttpClient okHttpClient) { - return new OrcaServiceSelector(createClientSelector("orca", OrcaService, okHttpClient)) + RequestContextProvider requestContextProvider() { + return new AuthenticatedRequestContextProvider(); + } + + @Bean + OrcaServiceSelector orcaServiceSelector(OkHttpClient okHttpClient, RequestContextProvider contextProvider) { + return new OrcaServiceSelector(createClientSelector("orca", OrcaService, okHttpClient), contextProvider) } @Bean @@ -191,7 +198,9 @@ class GateConfig extends RedisHttpSessionConfiguration { ClouddriverServiceSelector clouddriverServiceSelector(ClouddriverService defaultClouddriverService, OkHttpClient okHttpClient, DynamicConfigService dynamicConfigService, - DynamicRoutingConfigProperties properties) { + DynamicRoutingConfigProperties properties, + RequestContextProvider contextProvider + ) { if (serviceConfiguration.getService("clouddriver").getConfig().containsKey("dynamicEndpoints")) { def endpoints = (Map) serviceConfiguration.getService("clouddriver").getConfig().get("dynamicEndpoints") // translates the following config: @@ -217,11 +226,12 @@ class GateConfig extends RedisHttpSessionConfiguration { selectors << new ByUserOriginSelector(service, 2, sourceApp) } - return new ClouddriverServiceSelector(new SelectableService(selectors + defaultSelector), dynamicConfigService) + return new ClouddriverServiceSelector( + new SelectableService(selectors + defaultSelector), dynamicConfigService, contextProvider) } SelectableService selectableService = createClientSelector("clouddriver", ClouddriverService, okHttpClient) - return new ClouddriverServiceSelector(selectableService, dynamicConfigService) + return new ClouddriverServiceSelector(selectableService, dynamicConfigService, contextProvider) } //---- semi-optional components: diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/CapabilitiesController.java b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/CapabilitiesController.java index 82a62cc51b..df3ae496c6 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/CapabilitiesController.java +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/CapabilitiesController.java @@ -16,13 +16,14 @@ package com.netflix.spinnaker.gate.controllers; -import com.netflix.spinnaker.gate.security.RequestContext; import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector; import io.swagger.annotations.ApiOperation; import java.util.List; import java.util.Map; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/capabilities") @@ -34,7 +35,7 @@ public class CapabilitiesController { @ApiOperation(value = "Retrieve the list configured deployment monitors", response = List.class) @GetMapping(value = "/deploymentMonitors") List getDeploymentMonitors() { - return orcaService.withContext(RequestContext.get()).getDeploymentMonitors(); + return orcaService.select().getDeploymentMonitors(); } @ApiOperation( @@ -42,6 +43,6 @@ List getDeploymentMonitors() { response = Map.class) @GetMapping(value = "/expressions") Map getExpressionCapabilities() { - return orcaService.withContext(RequestContext.get()).getExpressionCapabilities(); + return orcaService.select().getExpressionCapabilities(); } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/ConcourseController.java b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/ConcourseController.java index ae43201a7d..fc7afcec32 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/ConcourseController.java +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/ConcourseController.java @@ -16,7 +16,6 @@ package com.netflix.spinnaker.gate.controllers; -import com.netflix.spinnaker.gate.security.RequestContext; import com.netflix.spinnaker.gate.services.internal.IgorService; import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector; import io.swagger.annotations.ApiOperation; @@ -81,8 +80,6 @@ void stageExecution( @RequestParam("stageId") String stageId, @RequestParam("job") String job, @RequestParam("buildNumber") Integer buildNumber) { - orcaService - .withContext(RequestContext.get()) - .concourseStageExecution(stageId, job, buildNumber, ""); + orcaService.select().concourseStageExecution(stageId, job, buildNumber, ""); } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/ExecutionsController.java b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/ExecutionsController.java index 5a12a0842a..11089bdec2 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/ExecutionsController.java +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/ExecutionsController.java @@ -15,18 +15,13 @@ */ package com.netflix.spinnaker.gate.controllers; -import com.netflix.spinnaker.gate.security.RequestContext; import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import java.util.Collections; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RestController public class ExecutionsController { @@ -74,7 +69,7 @@ List getLatestExecutionsByConfigIds( } return orcaServiceSelector - .withContext(RequestContext.get()) + .select() .getSubsetOfExecutions(pipelineConfigIds, executionIds, limit, statuses, expand); } @@ -151,7 +146,7 @@ List searchForPipelineExecutionsByTrigger( @RequestParam(value = "expand", defaultValue = "false") boolean expand) { return orcaServiceSelector - .withContext(RequestContext.get()) + .select() .searchForPipelineExecutionsByTrigger( application, triggerTypes, diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/PipelineConfigController.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/PipelineConfigController.groovy index 7883ab15b2..cd6f2e534f 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/PipelineConfigController.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/PipelineConfigController.groovy @@ -17,7 +17,7 @@ package com.netflix.spinnaker.gate.controllers -import com.netflix.spinnaker.gate.security.RequestContext + import com.netflix.spinnaker.gate.services.commands.HystrixFactory import com.netflix.spinnaker.gate.services.internal.Front50Service import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector @@ -67,7 +67,7 @@ class PipelineConfigController { if (pipelineConfig == null) { throw new NotFoundException("Pipeline config '${pipelineConfigId}' could not be found") } - String template = orcaServiceSelector.withContext(RequestContext.get()).convertToPipelineTemplate(pipelineConfig).body.in().text + String template = orcaServiceSelector.select().convertToPipelineTemplate(pipelineConfig).body.in().text return template } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SubnetController.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SubnetController.groovy index b3a2b36683..bfa896d928 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SubnetController.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/SubnetController.groovy @@ -30,8 +30,7 @@ class SubnetController { @ApiOperation(value = "Retrieve a list of subnets for a given cloud provider", response = List.class) @RequestMapping(value = "/{cloudProvider}", method = RequestMethod.GET) - List allByCloudProvider(@PathVariable String cloudProvider, - @RequestHeader(value = "X-RateLimit-App", required = false) String sourceApp) { - clouddriverServiceSelector.select(sourceApp).getSubnets(cloudProvider) + List allByCloudProvider(@PathVariable String cloudProvider) { + clouddriverServiceSelector.select().getSubnets(cloudProvider) } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/interceptors/RequestIdInterceptor.java b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/interceptors/RequestIdInterceptor.java index 2487f6ac6a..af0c619f85 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/interceptors/RequestIdInterceptor.java +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/interceptors/RequestIdInterceptor.java @@ -16,7 +16,7 @@ package com.netflix.spinnaker.gate.interceptors; -import static com.netflix.spinnaker.security.AuthenticatedRequest.Header.REQUEST_ID; +import static com.netflix.spinnaker.kork.common.Header.REQUEST_ID; import com.netflix.spinnaker.security.AuthenticatedRequest; import javax.servlet.http.HttpServletRequest; diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ArtifactService.java b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ArtifactService.java index 3e15ab6adb..a83cd3fbbb 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ArtifactService.java +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ArtifactService.java @@ -66,16 +66,14 @@ private static HystrixCommand> mapCommand( public List getArtifactCredentials(String selectorKey) { return mapListCommand( - "artifactCredentials", - clouddriverServiceSelector.select(selectorKey)::getArtifactCredentials) + "artifactCredentials", clouddriverServiceSelector.select()::getArtifactCredentials) .execute(); } public List getArtifactNames(String selectorKey, String accountName, String type) { return stringListCommand( "artifactNames", - () -> - clouddriverServiceSelector.select(selectorKey).getArtifactNames(accountName, type)) + () -> clouddriverServiceSelector.select().getArtifactNames(accountName, type)) .execute(); } @@ -85,7 +83,7 @@ public List getArtifactVersions( "artifactVersions", () -> clouddriverServiceSelector - .select(selectorKey) + .select() .getArtifactVersions(accountName, type, artifactName)) .execute(); } @@ -96,7 +94,7 @@ public Void getArtifactContents( "artifactContents", () -> { Response contentResponse = - clouddriverServiceSelector.select(selectorKey).getArtifactContent(artifact); + clouddriverServiceSelector.select().getArtifactContent(artifact); IOUtils.copy(contentResponse.getBody().in(), outputStream); return null; }) diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/CertificateService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/CertificateService.groovy index fdf7fb1edb..111a628bcb 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/CertificateService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/CertificateService.groovy @@ -44,13 +44,13 @@ class CertificateService { List getCertificates(String selectorKey) { listCommand("certificates") { - clouddriverServiceSelector.select(selectorKey).getCertificates() + clouddriverServiceSelector.select().getCertificates() } execute() } List getCertificates(String cloudProvider, String selectorKey) { listCommand("certificates-$cloudProvider") { - clouddriverServiceSelector.select(selectorKey).getCertificates(cloudProvider) + clouddriverServiceSelector.select().getCertificates(cloudProvider) } execute() } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/CloudMetricService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/CloudMetricService.groovy index 02e9f8374e..0c81647ad7 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/CloudMetricService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/CloudMetricService.groovy @@ -33,14 +33,14 @@ class CloudMetricService { List findAll(String cloudProvider, String account, String region, Map filters, String selectorKey) { HystrixFactory.newListCommand(GROUP, "$GROUP:$account:$region:findAll") { - clouddriverServiceSelector.select(selectorKey).findAllCloudMetrics(cloudProvider, account, region, filters) + clouddriverServiceSelector.select().findAllCloudMetrics(cloudProvider, account, region, filters) } execute() } Map getStatistics(String cloudProvider, String account, String region, String metricName, Long startTime, Long endTime, Map filters, String selectorKey) { HystrixFactory.newMapCommand(GROUP, "$GROUP:$account:$region:getStatistics") { - clouddriverServiceSelector.select(selectorKey).getCloudMetricStatistics(cloudProvider, account, region, metricName, startTime, endTime, filters) + clouddriverServiceSelector.select().getCloudMetricStatistics(cloudProvider, account, region, metricName, startTime, endTime, filters) } execute() } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ClusterService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ClusterService.groovy index 77198fc1f2..f76d821079 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ClusterService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ClusterService.groovy @@ -40,20 +40,20 @@ class ClusterService { Map getClusters(String app, String selectorKey) { HystrixFactory.newMapCommand(GROUP, "getClustersForApplication") { - clouddriverServiceSelector.select(selectorKey).getClusters(app) + clouddriverServiceSelector.select().getClusters(app) } execute() } List getClustersForAccount(String app, String account, String selectorKey) { HystrixFactory.newListCommand(GROUP, "getClustersForApplicationInAccount-${providerLookupService.providerForAccount(account)}") { - clouddriverServiceSelector.select(selectorKey).getClustersForAccount(app, account) + clouddriverServiceSelector.select().getClustersForAccount(app, account) } execute() } Map getCluster(String app, String account, String clusterName, String selectorKey) { HystrixFactory.newMapCommand(GROUP, "getCluster-${providerLookupService.providerForAccount(account)}") { try { - clouddriverServiceSelector.select(selectorKey).getCluster(app, account, clusterName)?.getAt(0) as Map + clouddriverServiceSelector.select().getCluster(app, account, clusterName)?.getAt(0) as Map } catch (RetrofitError e) { if (e.response?.status == 404) { return [:] @@ -70,14 +70,14 @@ class ClusterService { List getScalingActivities(String app, String account, String clusterName, String serverGroupName, String provider, String region, String selectorKey) { HystrixFactory.newListCommand(GROUP, "getScalingActivitiesForCluster-${providerLookupService.providerForAccount(account)}") { - clouddriverServiceSelector.select(selectorKey).getScalingActivities(app, account, clusterName, provider, serverGroupName, region) + clouddriverServiceSelector.select().getScalingActivities(app, account, clusterName, provider, serverGroupName, region) } execute() } Map getTargetServerGroup(String app, String account, String clusterName, String cloudProviderType, String scope, String target, Boolean onlyEnabled, Boolean validateOldest, String selectorKey) { HystrixFactory.newMapCommand(GROUP, "getTargetServerGroup-${providerLookupService.providerForAccount(account)}") { try { - return clouddriverServiceSelector.select(selectorKey).getTargetServerGroup(app, account, clusterName, cloudProviderType, scope, target, onlyEnabled, validateOldest) + return clouddriverServiceSelector.select().getTargetServerGroup(app, account, clusterName, cloudProviderType, scope, target, onlyEnabled, validateOldest) } catch (RetrofitError re) { if (re.kind == RetrofitError.Kind.HTTP && re.response?.status == 404) { throw new ServerGroupNotFound("unable to find $target in $cloudProviderType/$account/$scope/$clusterName") diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/DataService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/DataService.groovy index 7cb60cd2e4..3e4a5f9a2c 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/DataService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/DataService.groovy @@ -39,14 +39,14 @@ class DataService { void getStaticData(String id, Map filters, OutputStream outputStream) { voidCommand("static", { - def response = clouddriverServiceSelector.select(null).getStaticData(id, filters) + def response = clouddriverServiceSelector.select().getStaticData(id, filters) outputStream << response.getBody().in() }).execute() } void getAdhocData(String groupId, String bucketId, String objectId, OutputStream outputStream) { voidCommand("adhoc", { - def response = clouddriverServiceSelector.select(null).getAdhocData(groupId, bucketId, objectId) + def response = clouddriverServiceSelector.select().getAdhocData(groupId, bucketId, objectId) outputStream << response.getBody().in() }).execute() } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/EntityTagsService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/EntityTagsService.groovy index f7f43d4c68..795c4b48c4 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/EntityTagsService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/EntityTagsService.groovy @@ -34,13 +34,13 @@ class EntityTagsService { List list(@RequestParam Map allParameters, String selectorKey) { HystrixFactory.newListCommand(GROUP, "listEntityTags") { - clouddriverServiceSelector.select(selectorKey).listEntityTags(allParameters) + clouddriverServiceSelector.select().listEntityTags(allParameters) } execute() } Map get(String id, String selectorKey) { HystrixFactory.newMapCommand(GROUP, "getEntityTags") { - clouddriverServiceSelector.select(selectorKey).getEntityTags(id) + clouddriverServiceSelector.select().getEntityTags(id) } execute() } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ExecutionHistoryService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ExecutionHistoryService.groovy index fac3d4352f..9d89c2ee56 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ExecutionHistoryService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ExecutionHistoryService.groovy @@ -17,12 +17,11 @@ package com.netflix.spinnaker.gate.services -import com.netflix.spinnaker.gate.security.RequestContext +import com.google.common.base.Preconditions +import com.netflix.spinnaker.gate.services.commands.HystrixFactory import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector import groovy.transform.CompileStatic import groovy.util.logging.Slf4j -import com.google.common.base.Preconditions -import com.netflix.spinnaker.gate.services.commands.HystrixFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component @@ -36,18 +35,16 @@ class ExecutionHistoryService { List getTasks(String app, Integer page, Integer limit, String statuses) { Preconditions.checkNotNull(app) - RequestContext requestContext = RequestContext.get() def command = HystrixFactory.newListCommand("taskExecutionHistory", "getTasksForApp") { - orcaServiceSelector.withContext(requestContext).getTasks(app, page, limit, statuses) + orcaServiceSelector.select().getTasks(app, page, limit, statuses) } return command.execute() } List getPipelines(String app, Integer limit, String statuses, Boolean expand) { Preconditions.checkNotNull(app) - RequestContext requestContext = RequestContext.get() def command = HystrixFactory.newListCommand("pipelineExecutionHistory", "getPipelinesForApp-$app") { - orcaServiceSelector.withContext(requestContext).getPipelines(app, limit, statuses, expand) + orcaServiceSelector.select().getPipelines(app, limit, statuses, expand) } return command.execute() } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ImageService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ImageService.groovy index 2669599359..7b22a131a3 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ImageService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ImageService.groovy @@ -36,19 +36,19 @@ class ImageService { List getForAccountAndRegion(String provider, String account, String region, String imageId, String selectorKey) { HystrixFactory.newListCommand(GROUP, "getImagesForAccountAndRegion-${providerLookupService.providerForAccount(account)}") { - clouddriverServiceSelector.select(selectorKey).getImageDetails(provider, account, region, imageId) + clouddriverServiceSelector.select().getImageDetails(provider, account, region, imageId) } execute() } List search(String provider, String query, String region, String account, Integer count, Map additionalFilters, String selectorKey) { HystrixFactory.newListCommand(GROUP, "searchImages-${providerLookupService.providerForAccount(account)}") { - clouddriverServiceSelector.select(selectorKey).findImages(provider, query, region, account, count, additionalFilters) + clouddriverServiceSelector.select().findImages(provider, query, region, account, count, additionalFilters) } execute() } List findTags(String provider, String account, String repository, String selectorKey) { HystrixFactory.newListCommand(GROUP, "getTags-${providerLookupService.providerForAccount(account)}") { - clouddriverServiceSelector.select(selectorKey).findTags(provider, account, repository) + clouddriverServiceSelector.select().findTags(provider, account, repository) } execute() } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/InstanceService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/InstanceService.groovy index 523f30fc75..53f08f2327 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/InstanceService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/InstanceService.groovy @@ -45,7 +45,7 @@ class InstanceService { Map getForAccountAndRegion(String account, String region, String instanceId, String selectorKey) { HystrixFactory.newMapCommand(GROUP, "getInstancesForAccountAndRegion-${providerLookupService.providerForAccount(account)}") { - def service = clouddriverServiceSelector.select(selectorKey) + def service = clouddriverServiceSelector.select() def accountDetails = objectMapper.convertValue(service.getAccount(account), Map) def instanceDetails = service.getInstanceDetails(account, region, instanceId) def instanceContext = instanceDetails.collectEntries { @@ -64,7 +64,7 @@ class InstanceService { Map getConsoleOutput(String account, String region, String instanceId, String provider, String selectorKey) { HystrixFactory.newMapCommand(GROUP, "getConsoleOutput-${providerLookupService.providerForAccount(account)}") { - return clouddriverServiceSelector.select(selectorKey).getConsoleOutput(account, region, instanceId, provider) + return clouddriverServiceSelector.select().getConsoleOutput(account, region, instanceId, provider) } execute() } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/JobService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/JobService.groovy index 10fe34c8ff..3ea65b73f6 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/JobService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/JobService.groovy @@ -47,7 +47,7 @@ class JobService { List getPreconfiguredJobs() { RequestContext requestContext = RequestContext.get() HystrixFactory.newListCommand(GROUP, "getPreconfiguredJobs") { - orcaServiceSelector.withContext(requestContext).getPreconfiguredJobs() + orcaServiceSelector.select().getPreconfiguredJobs() } execute() } @@ -55,7 +55,7 @@ class JobService { HystrixFactory.newMapCommand(GROUP, "getJobsForApplicationAccountAndRegion-${providerLookupService.providerForAccount(account)}", { try { def context = getContext(applicationName, account, region, name) - return clouddriverServiceSelector.select(selectorKey).getJobDetails(applicationName, account, region, name, "") + [ + return clouddriverServiceSelector.select().getJobDetails(applicationName, account, region, name, "") + [ "insightActions": insightConfiguration.job.collect { it.applyContext(context) } ] } catch (RetrofitError e) { diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/LoadBalancerService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/LoadBalancerService.groovy index 303ae4a5d6..42de2260a0 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/LoadBalancerService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/LoadBalancerService.groovy @@ -41,20 +41,20 @@ class LoadBalancerService { List getAll(String provider = "aws", String selectorKey) { HystrixFactory.newListCommand(GROUP, "getAllLoadBalancersForProvider-$provider") { - clouddriverServiceSelector.select(selectorKey).getLoadBalancers(provider) + clouddriverServiceSelector.select().getLoadBalancers(provider) } execute() } Map get(String name, String selectorKey, String provider = "aws") { HystrixFactory.newMapCommand(GROUP, "getLoadBalancer-$provider") { - clouddriverServiceSelector.select(selectorKey).getLoadBalancer(provider, name) + clouddriverServiceSelector.select().getLoadBalancer(provider, name) } execute() } List getDetailsForAccountAndRegion(String account, String region, String name, String selectorKey, String provider = "aws") { HystrixFactory.newListCommand(GROUP, "getLoadBalancerDetails-$provider") { try { - def service = clouddriverServiceSelector.select(selectorKey) + def service = clouddriverServiceSelector.select() def accountDetails = objectMapper.convertValue(service.getAccount(account), Map) def loadBalancerDetails = service.getLoadBalancerDetails(provider, account, region, name) @@ -82,14 +82,14 @@ class LoadBalancerService { List getClusterLoadBalancers(String appName, String account, String provider, String clusterName, String selectorKey) { HystrixFactory.newListCommand(GROUP, "getClusterLoadBalancers-$provider") { - clouddriverServiceSelector.select(selectorKey).getClusterLoadBalancers(appName, account, clusterName, provider) + clouddriverServiceSelector.select().getClusterLoadBalancers(appName, account, clusterName, provider) } execute() } List getApplicationLoadBalancers(String appName, String selectorKey) { HystrixFactory.newListCommand(GROUP, "getApplicationLoadBalancers") { - clouddriverServiceSelector.select(selectorKey).getApplicationLoadBalancers(appName) + clouddriverServiceSelector.select().getApplicationLoadBalancers(appName) } execute() } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/NetworkService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/NetworkService.groovy index 6233b62d6f..edcf012258 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/NetworkService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/NetworkService.groovy @@ -44,13 +44,13 @@ class NetworkService { Map getNetworks(String selectorKey) { mapCommand("networks") { - clouddriverServiceSelector.select(selectorKey).getNetworks() + clouddriverServiceSelector.select().getNetworks() } execute() } List getNetworks(String cloudProvider, String selectorKey) { listCommand("networks-$cloudProvider") { - clouddriverServiceSelector.select(selectorKey).getNetworks(cloudProvider) + clouddriverServiceSelector.select().getNetworks(cloudProvider) } execute() } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineService.groovy index b1b1accf0d..ba64413cde 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineService.groovy @@ -17,7 +17,7 @@ package com.netflix.spinnaker.gate.services -import com.netflix.spinnaker.gate.security.RequestContext + import com.netflix.spinnaker.gate.services.commands.HystrixFactory import com.netflix.spinnaker.gate.services.internal.EchoService import com.netflix.spinnaker.gate.services.internal.Front50Service @@ -95,7 +95,7 @@ class PipelineService { } } } - orcaServiceSelector.withContext(RequestContext.get()).startPipeline(pipelineConfig, trigger.user?.toString()) + orcaServiceSelector.select().startPipeline(pipelineConfig, trigger.user?.toString()) } Map triggerViaEcho(String application, String pipelineNameOrId, Map parameters) { @@ -123,53 +123,53 @@ class PipelineService { } Map startPipeline(Map pipelineConfig, String user) { - orcaServiceSelector.withContext(RequestContext.get()).startPipeline(pipelineConfig, user) + orcaServiceSelector.select().startPipeline(pipelineConfig, user) } Map getPipeline(String id) { - orcaServiceSelector.withContext(RequestContext.get()).getPipeline(id) + orcaServiceSelector.select().getPipeline(id) } Map cancelPipeline(String id, String reason, boolean force) { setApplicationForExecution(id) - orcaServiceSelector.withContext(RequestContext.get()).cancelPipeline(id, reason, force, "") + orcaServiceSelector.select().cancelPipeline(id, reason, force, "") } Map pausePipeline(String id) { setApplicationForExecution(id) - orcaServiceSelector.withContext(RequestContext.get()).pausePipeline(id, "") + orcaServiceSelector.select().pausePipeline(id, "") } Map resumePipeline(String id) { setApplicationForExecution(id) - orcaServiceSelector.withContext(RequestContext.get()).resumePipeline(id, "") + orcaServiceSelector.select().resumePipeline(id, "") } Map deletePipeline(String id) { setApplicationForExecution(id) - orcaServiceSelector.withContext(RequestContext.get()).deletePipeline(id) + orcaServiceSelector.select().deletePipeline(id) } Map updatePipelineStage(String executionId, String stageId, Map context) { setApplicationForExecution(executionId) - orcaServiceSelector.withContext(RequestContext.get()).updatePipelineStage(executionId, stageId, context) + orcaServiceSelector.select().updatePipelineStage(executionId, stageId, context) } Map restartPipelineStage(String executionId, String stageId, Map context) { setApplicationForExecution(executionId) - orcaServiceSelector.withContext(RequestContext.get()).restartPipelineStage(executionId, stageId, context) + orcaServiceSelector.select().restartPipelineStage(executionId, stageId, context) } Map evaluateExpressionForExecution(String executionId, String pipelineExpression) { - orcaServiceSelector.withContext(RequestContext.get()).evaluateExpressionForExecution(executionId, pipelineExpression) + orcaServiceSelector.select().evaluateExpressionForExecution(executionId, pipelineExpression) } Map evaluateExpressionForExecutionAtStage(String executionId, String stageId, String pipelineExpression) { - orcaServiceSelector.withContext(RequestContext.get()).evaluateExpressionForExecutionAtStage(executionId, stageId, pipelineExpression) + orcaServiceSelector.select().evaluateExpressionForExecutionAtStage(executionId, stageId, pipelineExpression) } Map evaluateVariables(String executionId, String requisiteStageRefIds, String spelVersionOverride, List> expressions) { - orcaServiceSelector.withContext(RequestContext.get()).evaluateVariables(executionId, requisiteStageRefIds, spelVersionOverride, expressions) + orcaServiceSelector.select().evaluateVariables(executionId, requisiteStageRefIds, spelVersionOverride, expressions) } /** diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineTemplateService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineTemplateService.groovy index 6da61fef5b..985c178cfe 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineTemplateService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineTemplateService.groovy @@ -53,7 +53,7 @@ class PipelineTemplateService { } Map resolve(String source, String executionId, String pipelineConfigId) { - orcaServiceSelector.withContext(RequestContext.get()).resolvePipelineTemplate(source, executionId, pipelineConfigId) + orcaServiceSelector.select().resolvePipelineTemplate(source, executionId, pipelineConfigId) } List getTemplateDependents(@Nonnull String templateId, boolean recursive) { diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ProjectService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ProjectService.groovy index a270dc1900..cd281d233c 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ProjectService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ProjectService.groovy @@ -57,13 +57,13 @@ class ProjectService { List getAllPipelines(String projectId, int limit, String statuses) { RequestContext requestContext = RequestContext.get() HystrixFactory.newListCommand(GROUP, "getAllPipelines") { - return orcaServiceSelector.withContext(requestContext).getPipelinesForProject(projectId, limit, statuses) + return orcaServiceSelector.select().getPipelinesForProject(projectId, limit, statuses) } execute() } List getClusters(String projectId, String selectorKey) { HystrixFactory.newListCommand(GROUP, "getClusters") { - return clouddriverServiceSelector.select(selectorKey).getProjectClusters(projectId) + return clouddriverServiceSelector.select().getProjectClusters(projectId) } execute() } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SearchService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SearchService.groovy index c157602f89..c271b4e081 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SearchService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SearchService.groovy @@ -33,7 +33,7 @@ class SearchService { List search(String query, String type, String platform, String selectorKey, int pageSize = 10000, int page = 1, Map filters) { HystrixFactory.newListCommand(GROUP, "search-${type}") { - return clouddriverServiceSelector.select(selectorKey).search(query, type, platform, pageSize, page, filters) + return clouddriverServiceSelector.select().search(query, type, platform, pageSize, page, filters) } execute() } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SecurityGroupService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SecurityGroupService.groovy index 77e4604faf..2896780da5 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SecurityGroupService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/SecurityGroupService.groovy @@ -35,7 +35,7 @@ class SecurityGroupService { */ Map getAll(String selectorKey) { HystrixFactory.newMapCommand(GROUP, "getAllSecurityGroups") { - clouddriverServiceSelector.select(selectorKey).securityGroups + clouddriverServiceSelector.select().securityGroups } execute() } @@ -47,7 +47,7 @@ class SecurityGroupService { */ Map getById(String id, String selectorKey) { HystrixFactory.newMapCommand(GROUP, "getSecurityGroupById".toString()) { - def result = clouddriverServiceSelector.select(selectorKey).search(id, "securityGroups", null, 10000, 1, [:])[0] + def result = clouddriverServiceSelector.select().search(id, "securityGroups", null, 10000, 1, [:])[0] if (result.results) { Map firstResult = ((List)result.results)[0] String uriString = firstResult.url @@ -74,13 +74,13 @@ class SecurityGroupService { */ Map getForAccountAndProvider(String account, String provider, String selectorKey) { HystrixFactory.newMapCommand(GROUP, "getSecurityGroupsForAccountAndProvider-$provider") { - clouddriverServiceSelector.select(selectorKey).getSecurityGroups(account, provider) + clouddriverServiceSelector.select().getSecurityGroups(account, provider) } execute() } List getForAccountAndProviderAndRegion(String account, String provider, String region, String selectorKey) { HystrixFactory.newListCommand(GROUP, "getSecurityGroupsForAccountAndProvider-$provider") { - clouddriverServiceSelector.select(selectorKey).getSecurityGroupsForRegion(account, provider, region) + clouddriverServiceSelector.select().getSecurityGroupsForRegion(account, provider, region) } execute() } @@ -92,7 +92,7 @@ class SecurityGroupService { */ Map getSecurityGroup(String account, String provider, String name, String region, String selectorKey, String vpcId = null) { HystrixFactory.newMapCommand(GROUP, "getSecurityGroupByIdentifiers-$provider") { - clouddriverServiceSelector.select(selectorKey).getSecurityGroup(account, provider, name, region, vpcId) + clouddriverServiceSelector.select().getSecurityGroup(account, provider, name, region, vpcId) } execute() } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ServerGroupService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ServerGroupService.groovy index 434d1c90e5..14f97ef993 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ServerGroupService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ServerGroupService.groovy @@ -47,26 +47,26 @@ class ServerGroupService { List getForApplication(String applicationName, String expand, String cloudProvider, String clusters, String selectorKey) { String commandKey = Boolean.valueOf(expand) ? "getExpandedServerGroupsForApplication" : "getServerGroupsForApplication" HystrixFactory.newListCommand(GROUP, commandKey) { - clouddriverServiceSelector.select(selectorKey).getServerGroups(applicationName, expand, cloudProvider, clusters) + clouddriverServiceSelector.select().getServerGroups(applicationName, expand, cloudProvider, clusters) } execute() } List getForApplications(List applications, String cloudProvider, String selectorKey) { HystrixFactory.newListCommand(GROUP, "getServerGroupsForApplications") { - clouddriverServiceSelector.select(selectorKey).getServerGroups(applications, null, cloudProvider) + clouddriverServiceSelector.select().getServerGroups(applications, null, cloudProvider) } execute() } List getForIds(List ids, String cloudProvider, String selectorKey) { HystrixFactory.newListCommand(GROUP, "getServerGroupsForIds") { - clouddriverServiceSelector.select(selectorKey).getServerGroups(null, ids, cloudProvider) + clouddriverServiceSelector.select().getServerGroups(null, ids, cloudProvider) } execute() } Map getForApplicationAndAccountAndRegion(String applicationName, String account, String region, String serverGroupName, String selectorKey, String includeDetails) { HystrixFactory.newMapCommand(GROUP, "getServerGroupsForApplicationAccountAndRegion-${providerLookupService.providerForAccount(account)}") { try { - def service = clouddriverServiceSelector.select(selectorKey) + def service = clouddriverServiceSelector.select() def accountDetails = objectMapper.convertValue(service.getAccount(account), Map) def serverGroupDetails = service.getServerGroupDetails(applicationName, account, region, serverGroupName, includeDetails) def serverGroupContext = serverGroupDetails.collectEntries { diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy index a94770074e..8989bdc88b 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy @@ -42,26 +42,26 @@ class TaskService { if (body.containsKey("application")) { AuthenticatedRequest.setApplication(body.get("application").toString()) } - orcaServiceSelector.withContext(RequestContext.get()).doOperation(body) + orcaServiceSelector.select().doOperation(body) } Map createAppTask(String app, Map body) { body.application = app AuthenticatedRequest.setApplication(app) - orcaServiceSelector.withContext(RequestContext.get()).doOperation(body) + orcaServiceSelector.select().doOperation(body) } Map createAppTask(Map body) { if (body.containsKey("application")) { AuthenticatedRequest.setApplication(body.get("application").toString()) } - orcaServiceSelector.withContext(RequestContext.get()).doOperation(body) + orcaServiceSelector.select().doOperation(body) } Map getTask(String id) { RequestContext requestContext = RequestContext.get() HystrixFactory.newMapCommand(GROUP, "getTask") { - orcaServiceSelector.withContext(requestContext).getTask(id) + orcaServiceSelector.select().getTask(id) } execute() } @@ -69,13 +69,13 @@ class TaskService { setApplicationForTask(id) RequestContext requestContext = RequestContext.get() HystrixFactory.newMapCommand(GROUP, "deleteTask") { - orcaServiceSelector.withContext(requestContext)deleteTask(id) + orcaServiceSelector.select()deleteTask(id) } execute() } Map getTaskDetails(String taskDetailsId, String selectorKey) { HystrixFactory.newMapCommand(GROUP, "getTaskDetails") { - clouddriverServiceSelector.select(selectorKey).getTaskDetails(taskDetailsId) + clouddriverServiceSelector.select().getTaskDetails(taskDetailsId) } execute() } @@ -83,7 +83,7 @@ class TaskService { setApplicationForTask(id) RequestContext requestContext = RequestContext.get() HystrixFactory.newMapCommand(GROUP, "cancelTask") { - orcaServiceSelector.withContext(requestContext).cancelTask(id, "") + orcaServiceSelector.select().cancelTask(id, "") } execute() } @@ -91,7 +91,7 @@ class TaskService { setApplicationForTask(taskIds.get(0)) RequestContext requestContext = RequestContext.get() HystrixFactory.newMapCommand(GROUP, "cancelTasks") { - orcaServiceSelector.withContext(requestContext).cancelTasks(taskIds) + orcaServiceSelector.select().cancelTasks(taskIds) } execute() } @@ -132,7 +132,7 @@ class TaskService { Map cancelPipeline(String id, String reason) { RequestContext requestContext = RequestContext.get() HystrixFactory.newMapCommand(GROUP, "cancelPipeline") { - orcaServiceSelector.withContext(requestContext).cancelPipeline(id, reason, false, "") + orcaServiceSelector.select().cancelPipeline(id, reason, false, "") } execute() } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/V2PipelineTemplateService.java b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/V2PipelineTemplateService.java index 174fb1bc3a..e8fa43310b 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/V2PipelineTemplateService.java +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/V2PipelineTemplateService.java @@ -16,7 +16,6 @@ package com.netflix.spinnaker.gate.services; -import com.netflix.spinnaker.gate.security.RequestContext; import com.netflix.spinnaker.gate.services.PipelineTemplateService.PipelineTemplateDependent; import com.netflix.spinnaker.gate.services.internal.Front50Service; import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector; @@ -47,7 +46,7 @@ public Map get(String id, String tag, String digest) { } public Map plan(Map pipeline) { - return orcaServiceSelector.withContext(RequestContext.get()).plan(pipeline); + return orcaServiceSelector.select().plan(pipeline); } // TODO(louisjimenez): Deprecated. Will be replaced with /versions endpoint starting with 1.19. diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/WebhookService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/WebhookService.groovy index 19cf70dc40..98bba4e1c0 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/WebhookService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/WebhookService.groovy @@ -56,7 +56,7 @@ class WebhookService { List preconfiguredWebhooks() { return AuthenticatedRequest.allowAnonymous({ - orcaServiceSelector.withContext(RequestContext.get()).preconfiguredWebhooks() + orcaServiceSelector.select().preconfiguredWebhooks() }) } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/appengine/StorageAccountService.java b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/appengine/StorageAccountService.java index 4715a7f796..8d8ae3a8a9 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/appengine/StorageAccountService.java +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/appengine/StorageAccountService.java @@ -41,8 +41,7 @@ private static HystrixCommand> listCommand( public List getAppengineStorageAccounts(String selectorKey) { return listCommand( - "appengineStorageAccounts", - clouddriverServiceSelector.select(selectorKey)::getStorageAccounts) + "appengineStorageAccounts", clouddriverServiceSelector.select()::getStorageAccounts) .execute(); } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/aws/InfrastructureService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/aws/InfrastructureService.groovy index f7dabc1d4f..9344513653 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/aws/InfrastructureService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/aws/InfrastructureService.groovy @@ -40,39 +40,39 @@ class InfrastructureService { List getInstanceTypes(String selectorKey = null) { command("instanceTypes") { - clouddriverServiceSelector.select(selectorKey).instanceTypes + clouddriverServiceSelector.select().instanceTypes } execute() } List getKeyPairs(String selectorKey = null) { command("keyPairs") { - clouddriverServiceSelector.select(selectorKey).keyPairs + clouddriverServiceSelector.select().keyPairs } execute() } @Deprecated List getSubnets(String selectorKey = null) { command("subnets") { - clouddriverServiceSelector.select(selectorKey).getSubnets('aws') + clouddriverServiceSelector.select().getSubnets('aws') } execute() } @Deprecated List getVpcs(String selectorKey = null) { command("vpcs") { - clouddriverServiceSelector.select(selectorKey).getNetworks('aws') + clouddriverServiceSelector.select().getNetworks('aws') } execute() } List getFunctions(String selectorKey = null, String functionName, String region, String account) { command("functions") { - clouddriverServiceSelector.select(selectorKey).getFunctions(functionName,region, account) + clouddriverServiceSelector.select().getFunctions(functionName,region, account) } execute() } List getApplicationFunctions(String selectorKey = null, String application) { command("functions") { - clouddriverServiceSelector.select(selectorKey).getApplicationFunctions(application) + clouddriverServiceSelector.select().getApplicationFunctions(application) } execute() } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/internal/ClouddriverServiceSelector.java b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/internal/ClouddriverServiceSelector.java index 553616d6d0..3145f8d8bb 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/internal/ClouddriverServiceSelector.java +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/internal/ClouddriverServiceSelector.java @@ -15,55 +15,47 @@ */ package com.netflix.spinnaker.gate.services.internal; +import static com.netflix.spinnaker.gate.config.DynamicRoutingConfigProperties.ClouddriverConfigProperties; + import com.netflix.spinnaker.gate.config.DynamicRoutingConfigProperties; -import com.netflix.spinnaker.gate.security.RequestContext; import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService; +import com.netflix.spinnaker.kork.web.context.RequestContext; +import com.netflix.spinnaker.kork.web.context.RequestContextProvider; import com.netflix.spinnaker.kork.web.selector.SelectableService; import lombok.extern.slf4j.Slf4j; @Slf4j public class ClouddriverServiceSelector { - private final SelectableService selectableService; + private final SelectableService selectableService; private final DynamicConfigService dynamicConfigService; + private final RequestContextProvider contextProvider; public ClouddriverServiceSelector( - SelectableService selectableService, DynamicConfigService dynamicConfigService) { + SelectableService selectableService, + DynamicConfigService dynamicConfigService, + RequestContextProvider contextProvider) { this.selectableService = selectableService; this.dynamicConfigService = dynamicConfigService; + this.contextProvider = contextProvider; } - /** @deprecated see {@link #withContext(RequestContext)} */ - @Deprecated - public ClouddriverService select(String key) { + public ClouddriverService select() { SelectableService.Criteria criteria = new SelectableService.Criteria(); - - if (key != null && shouldSelect()) { - criteria = criteria.withOrigin(key); - } - - ClouddriverService selected = (ClouddriverService) selectableService.getService(criteria); - return selected; - } - - public ClouddriverService withContext(RequestContext context) { - SelectableService.Criteria criteria = new SelectableService.Criteria(); - + RequestContext context = contextProvider.get(); if (context != null && shouldSelect()) { criteria = criteria - .withApplication(context.getApplication()) - .withAuthenticatedUser(context.getAuthenticatedUser()) - .withExecutionId(context.getExecutionId()) - .withOrigin(context.getOrigin()) - .withExecutionType(context.getExecutionType()); + .withApplication(context.getApplication().orElse(null)) + .withAuthenticatedUser(context.getUser().orElse(null)) + .withExecutionId(context.getExecutionId().orElse(null)) + .withOrigin(context.getUserOrigin().orElse(null)) + .withExecutionType(context.getExecutionType().orElse(null)); } - - return (ClouddriverService) selectableService.getService(criteria); + return selectableService.getService(criteria); } private boolean shouldSelect() { return dynamicConfigService.isEnabled(DynamicRoutingConfigProperties.ENABLED_PROPERTY, false) - && dynamicConfigService.isEnabled( - DynamicRoutingConfigProperties.ClouddriverConfigProperties.ENABLED_PROPERTY, false); + && dynamicConfigService.isEnabled(ClouddriverConfigProperties.ENABLED_PROPERTY, false); } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/internal/OrcaServiceSelector.java b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/internal/OrcaServiceSelector.java index d0e3136853..2ce771e652 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/internal/OrcaServiceSelector.java +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/internal/OrcaServiceSelector.java @@ -16,26 +16,31 @@ package com.netflix.spinnaker.gate.services.internal; -import com.netflix.spinnaker.gate.security.RequestContext; +import com.netflix.spinnaker.kork.web.context.RequestContext; +import com.netflix.spinnaker.kork.web.context.RequestContextProvider; import com.netflix.spinnaker.kork.web.selector.SelectableService; public class OrcaServiceSelector { private final SelectableService selectableService; + private final RequestContextProvider contextProvider; - public OrcaServiceSelector(SelectableService selectableService) { + public OrcaServiceSelector( + SelectableService selectableService, RequestContextProvider contextProvider) { this.selectableService = selectableService; + this.contextProvider = contextProvider; } - public OrcaService withContext(RequestContext context) { + public OrcaService select() { SelectableService.Criteria criteria = new SelectableService.Criteria(); + RequestContext context = contextProvider.get(); if (context != null) { criteria = criteria - .withApplication(context.getApplication()) - .withAuthenticatedUser(context.getAuthenticatedUser()) - .withExecutionId(context.getExecutionId()) - .withOrigin(context.getOrigin()) - .withExecutionType(context.getExecutionType()); + .withApplication(context.getApplication().orElse(null)) + .withAuthenticatedUser(context.getUser().orElse(null)) + .withExecutionId(context.getExecutionId().orElse(null)) + .withOrigin(context.getUserOrigin().orElse(null)) + .withExecutionType(context.getExecutionType().orElse(null)); } return selectableService.getService(criteria); } diff --git a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/FunctionalSpec.groovy b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/FunctionalSpec.groovy index f290aec86d..56795bdf19 100644 --- a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/FunctionalSpec.groovy +++ b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/FunctionalSpec.groovy @@ -23,24 +23,14 @@ import com.netflix.spinnaker.fiat.shared.FiatStatus import com.netflix.spinnaker.gate.config.ServiceConfiguration import com.netflix.spinnaker.gate.controllers.ApplicationController import com.netflix.spinnaker.gate.controllers.PipelineController -import com.netflix.spinnaker.gate.services.AccountLookupService -import com.netflix.spinnaker.gate.services.ApplicationService -import com.netflix.spinnaker.gate.services.CredentialsService -import com.netflix.spinnaker.gate.services.ExecutionHistoryService -import com.netflix.spinnaker.gate.services.PipelineService -import com.netflix.spinnaker.gate.services.TaskService +import com.netflix.spinnaker.gate.services.* import com.netflix.spinnaker.gate.services.commands.ServerErrorException import com.netflix.spinnaker.gate.services.commands.ServiceUnavailableException import com.netflix.spinnaker.gate.services.commands.ThrottledRequestException -import com.netflix.spinnaker.gate.services.internal.ClouddriverService -import com.netflix.spinnaker.gate.services.internal.ClouddriverServiceSelector -import com.netflix.spinnaker.gate.services.internal.Front50Service -import com.netflix.spinnaker.gate.services.internal.OrcaService -import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector +import com.netflix.spinnaker.gate.services.internal.* import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService import com.netflix.spinnaker.kork.dynamicconfig.SpringDynamicConfigService import com.netflix.spinnaker.kork.web.exceptions.GenericExceptionHandlers -import com.netflix.spinnaker.kork.web.selector.SelectableService import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration @@ -91,7 +81,7 @@ class FunctionalSpec extends Specification { executorService = Mock(ExecutorService) taskService = Mock(TaskService) clouddriverService = Mock(ClouddriverService) - clouddriverServiceSelector = new ClouddriverServiceSelector(Mock(SelectableService), new SpringDynamicConfigService()) + clouddriverServiceSelector = Mock(ClouddriverServiceSelector) orcaService = Mock(OrcaService) credentialsService = Mock(CredentialsService) accountLookupService = Mock(AccountLookupService) @@ -204,7 +194,7 @@ class FunctionalSpec extends Specification { api.getTasks(name, null, null, "RUNNING,TERMINAL") then: - 1 * orcaServiceSelector.withContext(_) >> { orcaService } + 1 * orcaServiceSelector.select() >> { orcaService } 1 * orcaService.getTasks(name, null, null, "RUNNING,TERMINAL") >> [] where: @@ -228,7 +218,7 @@ class FunctionalSpec extends Specification { def tasks = executionHistoryService.getTasks("app", null, 5, null) then: - 1 * orcaServiceSelector.withContext(_) >> { orcaService } + 1 * orcaServiceSelector.select() >> { orcaService } 1 * orcaService.getTasks("app", null, 5, null) >> { return ["1"] } tasks == ["1"] @@ -236,7 +226,7 @@ class FunctionalSpec extends Specification { executionHistoryService.getTasks("app", null, 10, "RUNNING") then: - 1 * orcaServiceSelector.withContext(_) >> { orcaService } + 1 * orcaServiceSelector.select() >> { orcaService } 1 * orcaService.getTasks("app", null, 10, "RUNNING") >> { throw new IllegalStateException() } thrown(ServerErrorException) @@ -244,7 +234,7 @@ class FunctionalSpec extends Specification { executionHistoryService.getPipelines("app", 5, "TERMINAL", false) then: - 1 * orcaServiceSelector.withContext(_) >> { orcaService } + 1 * orcaServiceSelector.select() >> { orcaService } 1 * orcaService.getPipelines("app", 5, "TERMINAL", false) >> { throw new IllegalStateException() } thrown(ServerErrorException) } diff --git a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/InstanceServiceSpec.groovy b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/InstanceServiceSpec.groovy index 9f87f227b9..d323f22f07 100644 --- a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/InstanceServiceSpec.groovy +++ b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/InstanceServiceSpec.groovy @@ -29,7 +29,7 @@ class InstanceServiceSpec extends Specification { def service = new InstanceService( objectMapper: new ObjectMapper(), clouddriverServiceSelector: Mock(ClouddriverServiceSelector) { - 1 * select(_) >> { + 1 * select() >> { Mock(ClouddriverService) { 1 * getInstanceDetails(_, _, _) >> { return [privateIpAddress: "10.0.0.1", map: [:]] } 1 * getAccount(_) >> { return [awsAccount: "prod"] } diff --git a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/PipelineServiceSpec.groovy b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/PipelineServiceSpec.groovy index 843bf99738..8dcd009c05 100644 --- a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/PipelineServiceSpec.groovy +++ b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/PipelineServiceSpec.groovy @@ -39,7 +39,7 @@ class PipelineServiceSpec extends Specification { service.trigger('app', 'p-id', [notifications: [[type: 'sms']]]) then: - 1 * orcaServiceSelector.withContext(_) >> { orcaService } + 1 * orcaServiceSelector.select() >> { orcaService } 1 * orcaService.startPipeline({ p -> p.notifications.type == ['email', 'sms'] }, _) } @@ -60,7 +60,7 @@ class PipelineServiceSpec extends Specification { service.trigger('app', 'p-id', [notifications: trigger]) then: - 1 * orcaServiceSelector.withContext(_) >> { orcaService } + 1 * orcaServiceSelector.select() >> { orcaService } 1 * orcaService.startPipeline({ p -> p.notifications == expected }, _) where: @@ -91,7 +91,7 @@ class PipelineServiceSpec extends Specification { orcaServiceSelector: orcaServiceSelector ) when: - orcaServiceSelector.withContext(_) >> { orcaService } + orcaServiceSelector.select() >> { orcaService } def didThrow = false try { service.trigger('app', 'p-id', trigger) diff --git a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/ServerGroupServiceSpec.groovy b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/ServerGroupServiceSpec.groovy index 165725953a..91ad464f87 100644 --- a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/ServerGroupServiceSpec.groovy +++ b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/services/ServerGroupServiceSpec.groovy @@ -29,7 +29,7 @@ class ServerGroupServiceSpec extends Specification { def service = new ServerGroupService( objectMapper: new ObjectMapper(), clouddriverServiceSelector: Mock(ClouddriverServiceSelector) { - 1 * select(_) >> { + 1 * select() >> { Mock(ClouddriverService) { 1 * getServerGroupDetails(_, _, _, _ ,_) >> { return [cloudProvider: "aws"] } 1 * getAccount(_) >> { return [awsAccount: "prod"] } diff --git a/gradle.properties b/gradle.properties index cb30965b34..45c69397ab 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,6 +2,6 @@ fiatVersion=1.13.0 enablePublishing=false spinnakerGradleVersion=7.0.1 -korkVersion=7.15.0 +korkVersion=7.16.0 includeProviders=basic,iap,ldap,oauth2,saml,x509 org.gradle.parallel=true From ef358e661b95374b9bc8203d63c94195e1ba40ea Mon Sep 17 00:00:00 2001 From: Daniel Reynaud Date: Wed, 29 Jan 2020 10:11:58 -0800 Subject: [PATCH 2/3] chore(context): RequestContext is now unused, delete it --- .../gate/security/RequestContext.java | 86 ------------------- .../spinnaker/gate/services/JobService.groovy | 2 - .../services/PipelineTemplateService.groovy | 2 - .../gate/services/ProjectService.groovy | 3 +- .../gate/services/TaskService.groovy | 7 +- .../gate/services/WebhookService.groovy | 1 - 6 files changed, 2 insertions(+), 99 deletions(-) delete mode 100644 gate-core/src/main/groovy/com/netflix/spinnaker/gate/security/RequestContext.java diff --git a/gate-core/src/main/groovy/com/netflix/spinnaker/gate/security/RequestContext.java b/gate-core/src/main/groovy/com/netflix/spinnaker/gate/security/RequestContext.java deleted file mode 100644 index 2f15b8ce22..0000000000 --- a/gate-core/src/main/groovy/com/netflix/spinnaker/gate/security/RequestContext.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2018 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License") - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.netflix.spinnaker.gate.security; - -import com.netflix.spinnaker.security.AuthenticatedRequest; -import lombok.extern.slf4j.Slf4j; - -/** - * No longer backed by a thread local, this is now a readonly proxy to {@link AuthenticatedRequest}, - * which is the only source of truth for context values. This is to avoid the situation where - * RequestContext and {@link AuthenticatedRequest} provide an inconsistent view of the context or - * lose it across thread boundaries. - */ -@Slf4j -public class RequestContext { - private static final RequestContext placeholder = new RequestContext(); - - private RequestContext() {} - - public RequestContext(String origin, String authenticatedUser) { - log.warn("call to deprecated RequestContext's constructor"); - } - - @Deprecated - public static void set(RequestContext requestContext) { - log.warn("call to deprecated method RequestContext::set"); - } - - @Deprecated - public static void setApplication(String application) { - log.warn("call to deprecated method RequestContext::setApplication"); - } - - @Deprecated - public static void setExecutionType(String executionType) { - log.warn("call to deprecated method RequestContext::setExecutionType"); - } - - @Deprecated - public static void setExecutionId(String executionId) { - log.warn("call to deprecated method RequestContext::setExecutionId"); - } - - @Deprecated - public static void clear() { - log.warn("call to deprecated method RequestContext::clear"); - } - - public static RequestContext get() { - return placeholder; - } - - public String getApplication() { - return AuthenticatedRequest.getSpinnakerApplication().orElse(null); - } - - public String getAuthenticatedUser() { - return AuthenticatedRequest.getSpinnakerUser().orElse(null); - } - - public String getExecutionType() { - return AuthenticatedRequest.getSpinnakerExecutionType().orElse(null); - } - - public String getExecutionId() { - return AuthenticatedRequest.getSpinnakerExecutionId().orElse(null); - } - - public String getOrigin() { - return AuthenticatedRequest.getSpinnakerUserOrigin().orElse(null); - } -} diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/JobService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/JobService.groovy index 3ea65b73f6..91144b6927 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/JobService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/JobService.groovy @@ -17,7 +17,6 @@ package com.netflix.spinnaker.gate.services import com.netflix.spinnaker.gate.config.InsightConfiguration -import com.netflix.spinnaker.gate.security.RequestContext import com.netflix.spinnaker.gate.services.commands.HystrixFactory import com.netflix.spinnaker.gate.services.internal.ClouddriverServiceSelector import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector @@ -45,7 +44,6 @@ class JobService { ProviderLookupService providerLookupService List getPreconfiguredJobs() { - RequestContext requestContext = RequestContext.get() HystrixFactory.newListCommand(GROUP, "getPreconfiguredJobs") { orcaServiceSelector.select().getPreconfiguredJobs() } execute() diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineTemplateService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineTemplateService.groovy index 985c178cfe..1bd8f71708 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineTemplateService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/PipelineTemplateService.groovy @@ -16,12 +16,10 @@ package com.netflix.spinnaker.gate.services import com.fasterxml.jackson.annotation.JsonProperty -import com.netflix.spinnaker.gate.security.RequestContext import com.netflix.spinnaker.gate.services.internal.Front50Service import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector import groovy.transform.CompileStatic import groovy.util.logging.Slf4j -import lombok.Data import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ProjectService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ProjectService.groovy index cd281d233c..5b5d9a921f 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ProjectService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/ProjectService.groovy @@ -17,7 +17,7 @@ package com.netflix.spinnaker.gate.services -import com.netflix.spinnaker.gate.security.RequestContext + import com.netflix.spinnaker.gate.services.commands.HystrixFactory import com.netflix.spinnaker.gate.services.internal.ClouddriverServiceSelector import com.netflix.spinnaker.gate.services.internal.Front50Service @@ -55,7 +55,6 @@ class ProjectService { } List getAllPipelines(String projectId, int limit, String statuses) { - RequestContext requestContext = RequestContext.get() HystrixFactory.newListCommand(GROUP, "getAllPipelines") { return orcaServiceSelector.select().getPipelinesForProject(projectId, limit, statuses) } execute() diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy index 8989bdc88b..332df822fb 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy @@ -16,7 +16,7 @@ package com.netflix.spinnaker.gate.services -import com.netflix.spinnaker.gate.security.RequestContext + import com.netflix.spinnaker.gate.services.commands.HystrixFactory import com.netflix.spinnaker.gate.services.internal.ClouddriverServiceSelector import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector @@ -59,7 +59,6 @@ class TaskService { } Map getTask(String id) { - RequestContext requestContext = RequestContext.get() HystrixFactory.newMapCommand(GROUP, "getTask") { orcaServiceSelector.select().getTask(id) } execute() @@ -67,7 +66,6 @@ class TaskService { Map deleteTask(String id) { setApplicationForTask(id) - RequestContext requestContext = RequestContext.get() HystrixFactory.newMapCommand(GROUP, "deleteTask") { orcaServiceSelector.select()deleteTask(id) } execute() @@ -81,7 +79,6 @@ class TaskService { Map cancelTask(String id) { setApplicationForTask(id) - RequestContext requestContext = RequestContext.get() HystrixFactory.newMapCommand(GROUP, "cancelTask") { orcaServiceSelector.select().cancelTask(id, "") } execute() @@ -89,7 +86,6 @@ class TaskService { Map cancelTasks(List taskIds) { setApplicationForTask(taskIds.get(0)) - RequestContext requestContext = RequestContext.get() HystrixFactory.newMapCommand(GROUP, "cancelTasks") { orcaServiceSelector.select().cancelTasks(taskIds) } execute() @@ -130,7 +126,6 @@ class TaskService { */ @Deprecated Map cancelPipeline(String id, String reason) { - RequestContext requestContext = RequestContext.get() HystrixFactory.newMapCommand(GROUP, "cancelPipeline") { orcaServiceSelector.select().cancelPipeline(id, reason, false, "") } execute() diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/WebhookService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/WebhookService.groovy index 98bba4e1c0..4a0394a9d1 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/WebhookService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/WebhookService.groovy @@ -16,7 +16,6 @@ package com.netflix.spinnaker.gate.services -import com.netflix.spinnaker.gate.security.RequestContext import com.netflix.spinnaker.gate.services.internal.EchoService import com.netflix.spinnaker.gate.services.internal.OrcaServiceSelector import com.netflix.spinnaker.security.AuthenticatedRequest From 09a98fb3c596db521e2375aeb99c73dc0b6a4d07 Mon Sep 17 00:00:00 2001 From: Daniel Reynaud Date: Thu, 30 Jan 2020 15:58:47 -0800 Subject: [PATCH 3/3] fix(selector): fix typo and add log statement --- .../groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy | 1 + .../com/netflix/spinnaker/gate/services/TaskService.groovy | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy index c6a06afd58..628dc8a07e 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/config/GateConfig.groovy @@ -357,6 +357,7 @@ class GateConfig extends RedisHttpSessionConfiguration { def selectorClass = it.config?.selectorClass as Class if (selectorClass) { + log.debug("Initializing selector class {} with baseUrl={}, priority={}, config={}", selectorClass, it.baseUrl, it.priority, it.config) selector = selectorClass.getConstructors()[0].newInstance( selector.service, it.priority, it.config ) diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy index 332df822fb..a63275faf5 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/TaskService.groovy @@ -67,7 +67,7 @@ class TaskService { Map deleteTask(String id) { setApplicationForTask(id) HystrixFactory.newMapCommand(GROUP, "deleteTask") { - orcaServiceSelector.select()deleteTask(id) + orcaServiceSelector.select().deleteTask(id) } execute() }