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(scattergather): Initial scatter/gather library #3173

Merged
merged 1 commit into from
Nov 26, 2018

Conversation

robzienert
Copy link
Member

Development implementation of a scatter/gather library, for future use in
clouddriver federation, allowing operators to shard write & read traffic
without requiring development work on other services. It's possible this
behavior could be lifted to its own federation service in the future if
other services need the same behavior.

This API is currently coupled to HttpServletRequest, which it will then
fanout into a collection of OkHttp Call objects that will be executed
according to the provided ScatterGather implementation. Currently only a
NaiveScatterGather is available, which performs the calls sequentially
and without any error handling: This is for development purposes only.

Followup PRs will be made to add a ScatterGather implementation that
executes requests in parallel, performs error handling & retries as well
as cancelations in the event of timeouts.

Responses from shards are reduced into a single ReducedResponse by a
pluggable ResponseReducer. The existing implementation is a simple
deep merge reducer.

Better to place this in kork? There's nothing specific to clouddriver in
this library, nor do I expect that there ever will be.

@robzienert
Copy link
Member Author

Looks like I broke all the things when I split this out from the original codebase. 🤦‍♂️

@robzienert robzienert force-pushed the scattergather branch 2 times, most recently from 21cd404 to 7867387 Compare November 21, 2018 18:53
@robzienert robzienert force-pushed the scattergather branch 3 times, most recently from d6b60c2 to 9fc70db Compare November 21, 2018 19:02
Copy link
Contributor

@cfieber cfieber left a comment

Choose a reason for hiding this comment

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

looks pretty straightforward, I like it

the strategy is basically we take a request and pass it everywhere, and the destinations have to be smart enough to noop it if its not applicable to them (e.g. shard on region, we are going to send a get request everywhere and only the shards that handle that region are going to return results, and then the deep merge just merges a bunch of empty results with the actual results?)

} else if (valueToBeUpdated != null && valueToBeUpdated.isObject) {
mergeNodes(valueToBeUpdated, updatedValue)
} else {
// TODO(rz): Replace is not correct behavior
Copy link
Contributor

Choose a reason for hiding this comment

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

what would you expect the correct behaviour to be here? (replace seems legit to me so I am not entirely sure what I am missing)

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 forgot to remove that comment, it was behaving differently before.

distinctCodes.size == 1 -> distinctCodes[0]
distinctCodes.any { it == 404 } -> HttpStatus.NOT_FOUND.value()
distinctCodes.any { it == 429 } -> HttpStatus.TOO_MANY_REQUESTS.value()
else -> distinctCodes.sortedDescending().first()
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure this is the right default case here - thinking that one node returns a 400 for some reason and the others return 200, probably needs to make sure the JSON error response doesn't get merged with the 200 success responses

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'm going to change the logic so that the reducer will extract the response from the highest error code if it's not 2xx.

get { characterEncoding }.isEqualTo("UTF-8")
get { body }.isEqualTo(expectedBody)
get { isError }.isEqualTo(false)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

quality tests 👌

@robzienert
Copy link
Member Author

@cfieber The smarts of what shards do what is really not defined by this library. In the federation implementation, the federator actually has the smarts to determine which shards need to handle a request. That said, yes, all downstream servers will need to at least know about the scatter/gather header if they're also running the federation code.

Development implementation of a scatter/gather library, for future use in
clouddriver federation, allowing operators to shard write & read traffic
without requiring development work on other services. It's possible this
behavior could be lifted to its own federation service in the future if
other services need the same behavior.

This API is currently coupled to `HttpServletRequest`, which it will then
fanout into a collection of OkHttp `Call` objects that will be executed
according to the provided `ScatterGather` implementation. Currently only a
`NaiveScatterGather` is available, which performs the calls sequentially
and without any error handling: This is for development purposes only.

Followup PRs will be made to add a `ScatterGather` implementation that
executes requests in parallel, performs error handling & retries as well
as cancelations in the event of timeouts.

Responses from shards are reduced into a single `ReducedResponse` by a
pluggable `ResponseReducer`. The existing implementation is a simple
deep merge reducer.

Better to place this in kork? There's nothing specific to clouddriver in
this library, nor do I expect that there ever will be.
@robzienert robzienert merged commit c0893eb into spinnaker:master Nov 26, 2018
clanesf pushed a commit to clanesf/clouddriver that referenced this pull request Dec 8, 2018
Development implementation of a scatter/gather library, for future use in
clouddriver federation, allowing operators to shard write & read traffic
without requiring development work on other services. It's possible this
behavior could be lifted to its own federation service in the future if
other services need the same behavior.

This API is currently coupled to `HttpServletRequest`, which it will then
fanout into a collection of OkHttp `Call` objects that will be executed
according to the provided `ScatterGather` implementation. Currently only a
`NaiveScatterGather` is available, which performs the calls sequentially
and without any error handling: This is for development purposes only.

Followup PRs will be made to add a `ScatterGather` implementation that
executes requests in parallel, performs error handling & retries as well
as cancelations in the event of timeouts.

Responses from shards are reduced into a single `ReducedResponse` by a
pluggable `ResponseReducer`. The existing implementation is a simple
deep merge reducer.

Better to place this in kork? There's nothing specific to clouddriver in
this library, nor do I expect that there ever will be.
darshannagaraja pushed a commit to darshannagaraja/clouddriver that referenced this pull request May 17, 2019
Fix for inbound/outbound rules only detected in
apiVersion=network.k8s.io/v1
ezimanyi pushed a commit that referenced this pull request May 17, 2019
…network.k8s.io/v1 (#3684)

* Issue #3173

Fix for inbound/outbound rules only detected in
apiVersion=network.k8s.io/v1

* Fix for Issue 3173

Title: inbound/outbound rules only detected in apiVersion=network.k8s.io/v1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants