Skip to content

Commit

Permalink
feat(core): Add endpoint to get current pipeline definition (#644)
Browse files Browse the repository at this point in the history
There's currently no endpoint in front50 to get the current
pipeline definition; consumers need to call the history endpoint
with a limit of 1 and take the single returned element.

Let's make the API simpler for consumers who just want the current
definition by giving them an endpoint to return it.

Forcing consumers to call the /history endpoint has led to performance
issues, as that endpoint is often much slower than a call to get the
current definition. Some backing stores have optimized to short-circuit
the limit=1 case (s3 in #316), but others (including GCS) are still very
slow even in the limit=1 case.

We could (and potentially should) make the same optimization to other
backing stores. But I think the fundamental issue here is that we
have rare, slow history-type requests and frequent (ideally) fast
current-state requests going to the same endpoint. This PR creates
that distinction, and consumers can elect to use the new endpoint
going forward.
  • Loading branch information
ezimanyi authored and mergify[bot] committed Dec 5, 2019
1 parent e34a7c5 commit 444366b
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.netflix.spinnaker.kork.web.exceptions.ValidationException
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.security.access.prepost.PostAuthorize
import org.springframework.security.access.prepost.PostFilter
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.web.bind.annotation.*
Expand Down Expand Up @@ -99,6 +100,13 @@ class PipelineController {
return pipelineDAO.history(id, limit)
}

@PreAuthorize("@fiatPermissionEvaluator.storeWholePermission()")
@PostAuthorize("hasPermission(returnObject.application, 'APPLICATION', 'READ')")
@RequestMapping(value = '{id:.+}/get', method = RequestMethod.GET)
Pipeline get(@PathVariable String id) {
return pipelineDAO.findById(id)
}

@PreAuthorize("@fiatPermissionEvaluator.storeWholePermission() and hasPermission(#pipeline.application, 'APPLICATION', 'WRITE') and @authorizationSupport.hasRunAsUserPermission(#pipeline)")
@RequestMapping(value = '', method = RequestMethod.POST)
Pipeline save(@RequestBody Pipeline pipeline) {
Expand Down

0 comments on commit 444366b

Please sign in to comment.