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

Config simplifications #1096

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

jvz
Copy link
Contributor

@jvz jvz commented Aug 31, 2023

Provided in multiple commits, I've modernized and simplified several config classes by reusing Kork and Spring Boot things.

`ErrorConfiguration` is already found during component-scanning of `com.netflix.spinnaker.config`.
- Use parameter injection for config properties that are still used
- Delete the unused properties that were injected
- Use a `Jackson2ObjectMapperBuilder` bean to simplify setup of the default `ObjectMapper`
- Implement `WebMvcConfigurer` instead of extending the now deprecated `WebMvcConfigurerAdapter` class
- Use `List::of` instead of `ImmutableList::of`
- Remove call to `ContentNegotiationConfigurer::favorPathExtension` as this value has been the default in Spring for a while now
- Replace `val` with `var` keyword
- Fix some grammar in docs
Use `ServiceClientProvider` from `kork-web` to create Retrofit proxy beans for `Front50Api`, `ClouddriverApi`, and `IgorApi`. Other Retrofit settings repeatedly configured here are already configured in the relevant `ServiceClientFactory` ultimately used by `ServiceClientProvider`.
- Use `ServiceClientProvider` from `kork-web` to create a Retrofit proxy bean for `FiatService`
- Use `Jackson2ObjectMapperBuilder` to create the `ObjectMapper` used for `FiatService`
- Use `withDefaults()` customizer to simplify security configuration chains
.build()
.create(Front50Api.class);
Front50Api front50Api(@Value("${services.front50.base-url}") String front50Endpoint) {
return provider.getService(
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this ends up with RetrofitServiceFactory creating the returned object. At the moment that code doesn't use

.setErrorHandler(SpinnakerRetrofitErrorHandler.getInstance())

so this ends up being a change in behavior. Adding the setErrorHandler call to RetrofitServiceFactory is in the plans, but is gonna take some care (and potentially a config flag controlling whether it happens or not) since I believe both gate and echo use it, and we need to coordinate changes in handling of RetrofitError to Spinnaker*Exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Isn't the new error handler for running in Retrofit2? Right now, ServiceClientFactory implementations check for the use of the Call<T> API for determining which Retrofit version to use.

Copy link
Contributor

Choose a reason for hiding this comment

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

SpinnakerRetrofitErrorHandler is for retrofit1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But Retrofit only throws RetrofitError in the first place?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, retrofit1 throws RetrofitError, and SpinnakerRetrofitErrorHandler turns RetrofitError into SpinnakerServerException (and children).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, so the point of the error handler Bean is to translate the retrofit exception into a spinnaker one?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not a bean, but yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants