Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Adding pipeline template storage #222

Merged
merged 1 commit into from
Apr 26, 2017

Conversation

robzienert
Copy link
Member

@robzienert robzienert commented Apr 25, 2017

The whole Redis findById iterating and filtering all() pattern feels wrong, and the scope interaction seems janky, but interested in initial feedback.

@spinnaker/netflix-reviewers PTAL

@SuppressWarnings("unchecked")
public List<String> getScope() {
Map<String, Object> metadata = (Map<String, Object>) super.get("metadata");
if (metadata.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty or null maybe?


@JsonIgnore
@SuppressWarnings("unchecked")
public List<String> getScope() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scope vs scopes?

I suspect there's some motivation to the naming ... I just momentarily got caught up scope implying singular and it returning a list.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I debated on this a little bit, then decided to just throw something out there. I suspect that most people will scope templates to a single item (global or a specific app), which is why I chose the singular. Definitely happy to make it plural, since it is a list.


public boolean containsAnyScope(List<String> scope) {
for (String s : scope) {
if (getScope().contains(s)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any worry about case sensitivity wrt to scopes?

@@ -166,6 +169,11 @@ public PipelineDAO pipelineDAO(GcsStorageService service, Registry registry) {
}

@Bean
public PipelineTemplateDAO pipelineTemplateDAO(StorageService storageService, Registry registry) {
return new DefaultPipelineTemplateDAO(storageService, Schedulers.from(Executors.newFixedThreadPool(25)), PIPELINE_TEMPLATE_REFRESH_MS, registry);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps too many threads (depends on how many # of pipeline templates and concurrent calls to getByScope) but I've got a PR in flight that lets this be a little more configurable.

@@ -138,6 +140,11 @@ public PipelineDAO pipelineDAO(StorageService storageService, Registry registry)
}

@Bean
public PipelineTemplateDAO pipelineTemplateDAO(StorageService storageService, Registry registry) {
return new DefaultPipelineTemplateDAO(storageService, Schedulers.from(Executors.newFixedThreadPool(25)), 10000, registry);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically you've got a different refresh interval between S3 and GCS ... my PR will clean this up as well but I'd suggest dropping it down to 60s.

Any call to all() will do an on-demand refresh of any deltas anyways so it's more about having a reasonably fresh cache in the event of a hystrix fallback.


@ExceptionHandler(InvalidPipelineTemplateRequestException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
Map handleInvalidPipelineTemplateRequestException(InvalidPipelineTemplateRequestException e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to do with this PR but I reckon we can do a much better job of exception handling that doesn't require per-controller exception classes ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I'm still getting my bearings on how we do error handling in general in the services. I don't want to run off doing something different until I've got a good handle on how to do it better.

Copy link
Contributor

@ajordens ajordens Apr 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's completely reasonable to do it this way in front50 for now ... and then one of us can do a collective refactor across the board when we've got a more reasonable pattern.

import java.util.List;
import java.util.Map;

public class PipelineTemplate extends HashMap<String, Object> implements Timestamped {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have to extends HashMap<> if it makes more sense to do a concrete object w/ @JsonAnyGetter/JsonAnySetter for the dynamic pipeline bits.

Would let you concretely model the metadata but meh?

@ajordens
Copy link
Contributor

I don't see anything out of the ordinary, lgtm (few comments above but nothing blocking I don't think).

@robzienert robzienert force-pushed the pipelinetemplate-storage branch 2 times, most recently from 8f38884 to e793428 Compare April 25, 2017 18:28
@@ -28,6 +29,7 @@
PROJECT(Project.class, "projects", "project-metadata.json"),
PIPELINE(Pipeline.class, "pipelines", "pipeline-metadata.json"),
STRATEGY(Pipeline.class, "pipeline-strategies", "pipeline-strategy-metadata.json"),
PIPELINE_TEMPLATE(PipelineTemplate.class, "pipelineTemplates", "pipeline-template-metadata.json"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe pipeline-templates vs pipelineTemplates to be consistent with the naming convention of other types.

image

@robzienert robzienert force-pushed the pipelinetemplate-storage branch 2 times, most recently from 47a16f0 to 8dc6897 Compare April 26, 2017 18:10
@robzienert robzienert merged commit e03b778 into spinnaker:master Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants