934 Commits

Author SHA1 Message Date
Phillip Webb
56711d678a Merge branch '2.2.x'
Closes gh-21083
2020-04-22 11:59:22 -07:00
Phillip Webb
102729b5e1 Merge branch '2.1.x' into 2.2.x
Closes gh-21082
2020-04-22 11:58:39 -07:00
Phillip Webb
b3d33754a5 Remove outdated FIXMEs from tests
Closes gh-19782
2020-04-22 11:55:35 -07:00
Phillip Webb
bf41da5322 Update copyright year of changed files 2020-04-21 18:12:27 -07:00
Scott Frederick
70d4994502 Disable exception details on default error views
Prior to this commit, default error responses included the message
from a handled exception. When the exception was a BindException, the
error responses could also include an errors attribute containing the
details of the binding failure. These details could leak information
about the application.

This commit removes the exception message and binding errors detail
from error responses by default, and introduces a
`server.error.include-details` property that can be used to cause
these details to be included in the response.

Fixes gh-20505
2020-04-16 10:46:36 -05:00
dreis2211
b0eea26260 Prevent shaded imports from Datastax
See gh-20967
2020-04-15 09:21:56 +02:00
Phillip Webb
5311c04437 Change HealthEndpointGroups customization support
Update the `HealthEndpointGroups` customization support to use a
post-processor rather than a mutable registry. Although this approach
is slightly less flexible, it removes a lot of complexity from the
`HealthEndpointGroups` code. Specifically, it allows us to drop the
`HealthEndpointGroupsRegistry` interface entirely.

The probe health groups are now added via the post-processor if they
aren't already defined. Unlike the previous implementation, users are
no longer able to customize status aggregation and http status code
mapping rules _unless_ they also re-define the health indicators that
are members of the group.

See gh-20962
2020-04-14 16:40:36 -07:00
Phillip Webb
82cfd7c6c9 Restructure probes auto-configuration
Relocate probe auto-configuration from the `kubernetes` package to
`availability` since probes could also be used on other platforms.

The classes have also been renamed to named to `AvailabilityProbes...`

See gh-20962
2020-04-14 16:40:36 -07:00
Phillip Webb
71e4801e68 Rename probe health indicators
Rename `LivenessProbeHealthIndicator` to `LivenessStateHealthIndicator`
and `ReadinessProbeHealthIndicator` to `ReadinessStateHealthIndicator`.

Also introduce a general purpose `AvailabilityStateHealthIndicator`
class.

See gh-20962
2020-04-14 16:40:36 -07:00
Phillip Webb
bb79c847b2 Allow custom availability states
Create a general purpose `AvailabilityState` interface and refactor
the existing `LivenessState` and `ReadinessState` to use it. A single
`AvailabilityChangeEvent` is now used to carry all availability state
updates.

This commit also renames `ApplicationAvailabilityProvider` to
`ApplicationAvailabilityBean` and extracts an `ApplicationAvailability`
interface that other beans can inject. The helps to hide the event
listener method, which is really internal.

Finally the state enums have been renamed as follows:

 - `LivenessState.LIVE` -> `LivenessState.CORRECT`
 - `ReadinessState.READY` -> `ReadinessState.ACCEPTING_TRAFFIC`
 - `ReadinessState.UNREADY` -> `ReadinessState.REFUSING_TRAFFIC`

See gh-20962
2020-04-14 16:40:36 -07:00
Phillip Webb
1604cb2a1e Polish 2020-04-13 14:05:48 -07:00
dreis2211
4b9986d790 Remove unused fields in tests
See gh-20926
2020-04-13 13:46:43 +02:00
Brian Clozel
ce653059c8 Improve recording of cancellation signal in WebClient
With its initial fix in gh-18444, the `WebClient` instrumentation would
record all CANCEL signals, including:

* when a `timeout` expires and the response has not been received
* when the client partially consumes the response body

Since the second use case is arguable intentional, this commit restricts
the instrumentation and thus avoids recording two events for a single
request in that case.

Closes gh-18444
2020-04-11 21:52:18 +02:00
Brian Clozel
3879a7505c Record cancelled client requests in WebClient
Prior to this commit, cancelled client requests (for example as a result
of a `timeout()` reactor operator would not be recorded by Micrometer.

This commit instruments the cancelled signal for outgoing client
requests and assigns a status `CLIENT_ERROR`.
The cancellation can be intentional (triggering a timeout and falling
back on a faster alternative) or considered as an error. The intent
cannot be derived from the signal itself so we're considering it as a
client error.

Closes gh-18444
2020-04-10 22:37:00 +02:00
Phillip Webb
3ca896e63f Polish 2020-04-07 12:10:49 -07:00
Phillip Webb
5d8d0bb159 Update copyright year of changed files 2020-04-01 11:51:29 -07:00
Andy Wilkinson
f238812cea Polish "Improve handling of non-existent path in disk space health check"
See gh-20580
2020-03-31 12:24:10 +01:00
Andreas Born
db565cfc3a Improve handling of non-existent path in disk space health check
See gh-20580
2020-03-31 12:24:10 +01:00
Stephane Nicoll
ef592eaed8 Merge branch '2.2.x'
Closes gh-20726
2020-03-30 13:08:16 +02:00
Stephane Nicoll
ac56db703e Merge branch '2.1.x' into 2.2.x
Closes gh-20725
2020-03-30 13:02:58 +02:00
Stephane Nicoll
88b7b78344 Make sure that cassandra health check reports version
Closes gh-20719
2020-03-30 12:58:41 +02:00
Stephane Nicoll
a7e8829560 Polish 2020-03-29 18:44:48 +02:00
Stephane Nicoll
5ad4de184d Merge branch '2.2.x'
Closes gh-20718
2020-03-29 18:43:35 +02:00
Stephane Nicoll
05f10819c4 Merge branch '2.1.x' into 2.2.x
Closes gh-20717
2020-03-29 18:39:17 +02:00
Stephane Nicoll
c9e32aaa47 Use LOCAL_ONE when querying system.local
This commit is a follow-up of gh-20709 to apply the same consistency
level to the Cassandra reactive health indicator.

Closes gh-20713
2020-03-29 18:37:30 +02:00
Stephane Nicoll
876371e0fd Merge branch '2.2.x'
Closes gh-20712
2020-03-28 16:09:47 +01:00
Stephane Nicoll
a9a6df2ed4 Merge branch '2.1.x' into 2.2.x
Closes gh-20711
2020-03-28 16:05:36 +01:00
Stephane Nicoll
63be1678de Polish "Use LOCAL_ONE when querying system.local"
See gh-20709
2020-03-28 16:02:04 +01:00
Alexandre Dutra
851f631eac Use LOCAL_ONE when querying system.local
The system keyspace has a replication factor of 1 and is local to each
node; it is therefore recommended to query system.local with a
consistency level of ONE or LOCAL_ONE.

Stronger consistency levels may result in an Unavailable error, but this
does not mean that the node is down.

See gh-20709
2020-03-28 16:01:47 +01:00
dreis2211
674f1e77b5 Fix typos
See gh-20704
2020-03-28 08:42:59 +01:00
Brian Clozel
eb70fd952f Turn LivenessState and ReadinessState into enums
Prior to this commit, `LivenessState` and `ReadinessState` were
immutable classes. This was done in order to have additional behavior
and information in those classes.

Because the current implementation doesn't need this, this commit turns
those classes into simple enums.
Additional state and information can be added to the
`*StateChangedEvent` classes.

See gh-19593
2020-03-24 18:25:52 +01:00
dreis2211
25f48cb289 Fix typos in HealthEndpointGroupConfigurer
See gh-20628
2020-03-24 11:18:42 +01:00
Phillip Webb
0717de723f Polish 2020-03-23 20:03:44 -07:00
Phillip Webb
9a33a723fe Update copyright year of changed files 2020-03-23 14:15:08 -07:00
Phillip Webb
16b5ea3414 Update copyright year of changed files 2020-03-23 14:13:33 -07:00
dreis2211
ef9f1d39a3 Remove redundant MockitoAnnotations.initMocks()
See gh-20601
2020-03-22 08:43:50 +01:00
Stephane Nicoll
70aa788747 Merge branch '2.2.x'
Closes gh-20600
2020-03-21 15:15:20 +01:00
Stephane Nicoll
8593270b5b Only remove trailing slash from URI value
This commit upgrades the algorithm when trailing slash are to be
ignored. Previously a root URI (i.e. "/") would result to to empty
string which is an issue for monitoring system that requires tag values
to be non empty. If the URI is a single character, the trailing is not
applied and "/" is left as is.

Closes gh-20536
2020-03-21 15:11:50 +01:00
Brian Clozel
ffdf9a422f Polish Liveness and Readiness support
This commit moves the core Liveness and Readiness support to its own
`availability` package. We've made this a core concept independent of
Kubernetes.

Spring Boot now produces `LivenessStateChanged` and
`ReadinessStateChanged` events as part of the typical application
lifecycle.

Liveness and Readiness Probes (`HealthIndicator` components and health
groups) are still configured only when deployed on Kubernetes.

This commit also improves the documentation around Probes best practices
and container lifecycle considerations.

See gh-19593
2020-03-20 23:54:00 +01:00
Brian Clozel
fd0b2f6695 Add Kubernetes Liveness and Readiness Probes support
Prior to this commit and as of Spring Boot 2.2.0, we would advise
developers to use the Actuator health groups to define custom "liveness"
and "readiness" groups and configure them with subsets of existing
health indicators.

This commit addresses several limitations with that approach.

First, `LivenessState` and `ReadinessState` are promoted to first class
concepts in Spring Boot applications. These states should not only based
on periodic health checks. Applications should be able to track changes
(and adapt their behavior) or update states (when an error happens).

The `ApplicationStateProvider` can be injected and used by applications
components to get the current application state. Components can also
track specific `ApplicationEvent` to be notified of changes, like
`ReadinessStateChangedEvent` and `LivenessStateChangedEvent`.
Components can also publish such events with an
`ApplicationEventPublisher`. Spring Boot will track startup event and
application context state to update the liveness and readiness state of
the application. This infrastructure is available in the
main spring-boot module.

If Spring Boot Actuator is on the classpath, additional
`HealthIndicator` will be contributed to the application:
`"LivenessProveHealthIndicator"` and `"ReadinessProbeHealthIndicator"`.
Also, "liveness" and "readiness" Health groups will be defined if
they're not configured already.

Closes gh-19593
2020-03-19 14:11:00 +01:00
Brian Clozel
b680db6cd8 Add HealthEndpointGroupsRegistry and its Customizer
Prior to this commit, `HealthContributor` would be exposed under the
main `HealthEndpoint` and subgroups, `HealthEndpointGroups`. Groups are
driven by configuration properties and there was no way to contribute
programmatically new groups.

This commit introduces the `HealthEndpointGroupsRegistry` (a mutable
version of `HealthEndpointGroups`) and a
`HealthEndpointGroupsRegistryCustomizer`. This allows configurations to
add/remove groups during Actuator auto-configuration.

Closes gh-20554
2020-03-19 14:11:00 +01:00
Stephane Nicoll
abe43b2e83 Upgrade to Couchbase SDK v3
This commit upgrades to the Couchbase SDK v3 which brings the following
breaking changes:

* Bootstrap hosts have been replaced by a connection string and the
authentication is now mandatory.
* A `Bucket` is no longer auto-configured. The
`spring.couchbase.bucket.*` properties have been removed
* `ClusterInfo` no longer exists and has been replaced by a dedicated
API on `Cluster`.
* `CouchbaseEnvironment` no longer exist in favour of
`ClusterEnvironment`, the customizer has been renamed accordingly.
* The bootstrap-related properties have been removed. Users requiring
custom ports should supply the seed nodes and initialize a Cluster
themselves.
* The endpoints-related configuration has been consolidated in a
single IO configuration.

The Spring Data Couchbase provides an integration with the new SDK. This
leads to the following changes:

* A convenient `CouchbaseClientFactory` is auto-configured.
* Repositories are configured against a bucket and a scope. Those can
be set via configuration in `spring.data.couchbase.*`.
* The default consistency property has been removed in favour of a more
flexible annotation on the repository query methods instead. You can now
specify different query consistency on a per method basis.
* The `CacheManager` implementation is provided, as do other stores for
consistency so a dependency on `couchbase-spring-cache` is no longer
required.

See gh-19893

Co-authored-by: Michael Nitschinger <michael@nitschinger.at>
2020-03-17 17:00:09 +01:00
dreis2211
3e24df3beb Fix method order checkstyle issue
See gh-20525
2020-03-13 15:53:42 +00:00
Andy Wilkinson
0315724126 Cache endpoint responses on a per-principal basis
Previously, any HTTP request to an endpoint that included a principal
would bypass the cache. This prevented authenticated requests from
making use of the cache and its configurable time-to-live.

This commit updates the caching operation invoker to include the
principal, if any, in its cache key. As a result, requests that
include a principal will make use of the cache, potentially returning
the result of a previous invocation of the same endpoint by the same
principal.

Closes gh-19538
2020-03-13 15:31:41 +00:00
Andy Wilkinson
ef9960c69f Allow additional tags to be contributed to WebMvc and WebFlux defaults
Closes gh-20175
2020-03-13 09:38:29 +00:00
Andy Wilkinson
c917b61484 Reinstate leading / in default value for spring.liquibase.change-log
Unfortunately, while redundant for new applications, removing the
leading slash adversely affected existing application upon upgrades as
it caused Liquibase to re-apply every change log.

Closes gh-20177
2020-03-10 21:22:27 +00:00
Stephane Nicoll
278f769f80 Merge branch '2.2.x' 2020-03-08 17:23:56 +01:00
Stephane Nicoll
1fdb08300b Polish 2020-03-08 17:22:22 +01:00
Scott Frederick
185f644877 Remove the body from actuator 404 responses
When a request to the /actuator/env/{toMatch} endpoint does not match a
property, a response status 404 was being returned along with a body
containing the existing property sources. This commit removes the body
from the response to be more consistent with a typical 404 response.

Fixes gh-20314
2020-03-05 17:21:15 -06:00
Stephane Nicoll
fa8a09d46d Merge branch '2.2.x'
Closes gh-20395
2020-03-05 10:31:17 +01:00