Skip to content

Conversation

@mmanciop
Copy link
Contributor

Fix #554

@mmanciop mmanciop force-pushed the hystrix-webclient-timeouts branch from d41cd19 to 2419175 Compare September 19, 2018 10:48
@codecov-io
Copy link

codecov-io commented Sep 19, 2018

Codecov Report

Merging #555 into 2.0.x will increase coverage by 0.01%.
The diff coverage is 42.85%.

Impacted file tree graph

@@             Coverage Diff              @@
##              2.0.x     #555      +/-   ##
============================================
+ Coverage     70.51%   70.52%   +0.01%     
- Complexity      908      910       +2     
============================================
  Files           128      128              
  Lines          3646     3651       +5     
  Branches        256      258       +2     
============================================
+ Hits           2571     2575       +4     
+ Misses          943      941       -2     
- Partials        132      135       +3
Impacted Files Coverage Δ Complexity Δ
...mework/cloud/gateway/support/TimeoutException.java 100% <ø> (+50%) 2 <0> (+1) ⬆️
...ay/filter/factory/HystrixGatewayFilterFactory.java 80.88% <42.85%> (-4.84%) 9 <0> (+1)
...ler/predicate/RemoteAddrRoutePredicateFactory.java 85.36% <0%> (+2.43%) 12% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b42c45f...0276702. Read the comment docs.

@mmanciop
Copy link
Contributor Author

The failure looks like an unrelated failure, and for my local executions is broken also in master.

The tests affected by this change are fine though:

Running org.springframework.cloud.gateway.filter.factory.HystrixGatewayFilterFactoryTests Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 11.927 sec

@mmanciop mmanciop force-pushed the hystrix-webclient-timeouts branch from 2419175 to 6b1adda Compare October 1, 2018 08:52
@spencergibb spencergibb changed the title Treat WebClient timeouts the same as Hystrix timeouts Treat HttpClient timeouts the same as Hystrix timeouts Oct 5, 2018
@spencergibb
Copy link
Member

@mmanciop can you rebase? We're trying to release week after next.

@mmanciop
Copy link
Contributor Author

mmanciop commented Oct 6, 2018

On my machine the builds fail with an seemingly-unrelated redis rate-limit failure, but the Hystrix-related tests pass.

@ryanjbaxter
Copy link
Contributor

Do you have a redis server running on you machine during your build?

@mmanciop
Copy link
Contributor Author

mmanciop commented Oct 6, 2018

No, I have not. This kind of the dependency would be however rather easy to automate with https://github.com/kstyrc/embedded-redis. I think I either have made a quick JUnit rule in the past for it, or used an existing one. I’ll consider contributing the solution to avoid this pitfall woth another PR.

@ryanjbaxter
Copy link
Contributor

@mmanciop can you rebase?

@mmanciop mmanciop force-pushed the hystrix-webclient-timeouts branch from 444355e to 0f6d39c Compare October 9, 2018 14:27
@mmanciop
Copy link
Contributor Author

mmanciop commented Oct 9, 2018

Done. I found out that, due to #558, we have now another case to deal with; so I am wondering if in #558 we dealt with the mapping from TimeoutException to ResponseStatusException at too low a level.

Wouldn't it make sense to declare TimeoutException returning 504 to the client (e.g., by adding a @ResponseStatus annotation to it) and just let the TimeoutException bubble outside of the Hystrix command. Also, poking around about this, I got wondering if #558 broke the default settings of org.springframework.cloud.gateway.filter.factory.RetryGatewayFilterFactory.RetryConfig.

In any case, I believe it makes sense to let ResponseStatusException propagate unscathed out of a HystrixObservableCommand, as that is one of the premiere Spring ways to set status codes with applications; the other way I know being @ResponseStatus, for which we may likely need to add support here in case a filter (gateway or global, makes little difference) propagates one Throwable annotated with @ResponseStatus.

@mmanciop
Copy link
Contributor Author

mmanciop commented Oct 9, 2018

Meanwhile, I found out [1] that @ResponseStatus seems not to be supported by WebFlux, which I am not sure if it is a bug or a feature :-)

So I think this commit is good for the time being.

[1] https://github.com/mmanciop/response-status-repro.git

@mmanciop
Copy link
Contributor Author

mmanciop commented Oct 9, 2018

So, the Spring Cloud Gateway ignores @ResponseStatus but can deal with ResponseStatusException because the propagating exceptions are handled through org.springframework.boot.web.reactive.error.DefaultErrorAttributes#determineHttpStatus. @ryanjbaxter, @spencergibb, would it make sense to extend the DefaultErrorAttributes to deal with @ResponseStatus? I am frankly not so sure, as it may have side-effects when running a mix of plain WebFlux and Spring Cloud Gateway. I see it more as a PR to open upstream to spring-boot, so I'll give that a chance.

@mmanciop
Copy link
Contributor Author

mmanciop commented Oct 9, 2018

About @ResponseStatus, for reference, see spring-projects/spring-boot#14742

Throwable cause = e.getCause();

if (cause instanceof ResponseStatusException) {
/*
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When spring-projects/spring-boot#14742 is fixed upstream, here we should add support for @ResponseStatus using a logic similar to the one of WebFluxResponseStatusExceptionHandler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fundamentally, the condition would change to:
cause instanceof ResponseStatusException || AnnotatedElementUtils.hasAnnotation(cause.getClass(), ResponseStatus.class)

return Mono.error(cause);
}

if (cause instanceof TimeoutException) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When spring-projects/spring-boot#14742 is fixed upstream, we can just add @ResponseStatus to TimeoutException and let the previous case (amended as per comment) take care of propagating the cause outside.

@ryanjbaxter
Copy link
Contributor

Makes sense to me

@mmanciop
Copy link
Contributor Author

As per spring-projects/spring-boot#14744, upstream should be fixed with 2.0.6. What is the timeline to update to a new Spring Boot Release after it becomes available?

@mmanciop
Copy link
Contributor Author

mmanciop commented Oct 12, 2018

@spencergibb I guess the label “waiting for feeback” should be removed :-)

@ryanjbaxter
Copy link
Contributor

It looks like 2.0.6 is scheduled to be released on Oct 16th. There is a chance we might be able to do the Finchley.SR2 release based on that release. It all depends on when we get through the last few issues in our queue.

@ryanjbaxter
Copy link
Contributor

@mmanciop we should now be using Boot 2.0.6 that was released today. We are planning on doing a release soon (probably by the end of the week), so if you update the PR soon to leverage @ResponseStatus we should be able to include it in the release.

@mmanciop mmanciop force-pushed the hystrix-webclient-timeouts branch from 0f6d39c to be17f21 Compare October 17, 2018 21:53
@mmanciop mmanciop changed the base branch from master to 2.0.x October 17, 2018 21:57
@mmanciop mmanciop force-pushed the hystrix-webclient-timeouts branch from be17f21 to d6be3eb Compare October 17, 2018 22:13
@mmanciop
Copy link
Contributor Author

The tests failing in this build are failing for me also for the tip of origin/2.0.x. Any pointers, @ryanjbaxter ?

@ryanjbaxter
Copy link
Contributor

@mmanciop the build should be fixed, can you pull in the latest changes into your branch?

* Treat HttpClient timeouts the same as Hystrix timeouts
* Propagate ResponseStatusException and throwables with
  @ResponseStatus when cause for COMMAND_EXECUTION failure

Fix spring-cloud#554
@mmanciop mmanciop force-pushed the hystrix-webclient-timeouts branch from d6be3eb to 0276702 Compare October 20, 2018 07:57
@mmanciop
Copy link
Contributor Author

@ryanjbaxter done ;-) Thanks for fixing the build.

@ryanjbaxter ryanjbaxter merged commit ded733b into spring-cloud:2.0.x Oct 22, 2018
@mmanciop mmanciop deleted the hystrix-webclient-timeouts branch October 22, 2018 16:34
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.

6 participants