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

Support for Targeted Property Refresh in /actuator/refresh Endpoint #1370

Open
samuelj90 opened this issue Aug 22, 2024 · 14 comments
Open

Support for Targeted Property Refresh in /actuator/refresh Endpoint #1370

samuelj90 opened this issue Aug 22, 2024 · 14 comments

Comments

@samuelj90
Copy link

samuelj90 commented Aug 22, 2024

Question :

Hello @spring-cloud-issues, @spring-cloud Team,

I'm currently using the Spring Boot Actuator's /actuator/refresh endpoint to refresh my application's properties. However, I've noticed that the endpoint triggers a full refresh of all property sources. The issue with this approach is that some encrypted properties always cause Spring beans to reinitialize.

I wanted to confirm if there's any support for a more granular refresh mechanism, where specific properties or beans can be targeted for refresh instead of reloading the entire property source. If this isn't supported, are there any plans to introduce this feature in future releases?

@ryanjbaxter
Copy link
Contributor

No there is no granular mechanism to do so. I am not entirely sure it would be possible to do so as I believe the refresh endpoint reinitializes the application context. In addition I think this may introduce some problems when we have properties that depend on other properties. If a property contained within a property sources gets refreshed and there is a property within another property source that does not get refreshed but references property's which value was changed it would no longer have the correct value.

@samuelj90
Copy link
Author

samuelj90 commented Aug 24, 2024

@ryanjbaxter / @spring-cloud-issues, @spring-cloud Team,

Thanks for responding. I am quite confused on where to open issue. that's why created on the other project too. Thanks for clearing it out.

In the absence of a granular refresh mechanism, are there any recommended workarounds to minimize the impact of reinitialize beans due to encrypted properties from your end. Are there any detailed resources or documentation that explain the inner workings of the /actuator/refresh endpoint and its impact on the application context? It finds difficult to get more understanding from the documentation.

My understanding on the actuator refresh is as follows

The /actuator/refresh endpoint in Spring Boot Actuator is used to refresh the application context, allowing the application to pick up changes in the configuration properties without restarting the entire application.
When a request is made to the /actuator/refresh endpoint, Spring Boot triggers a refresh of the application context.
The refresh process involves re-binding beans that are annotated with @ConfigurationProperties or @RefreshScope. This means that these beans will be re-initialized with the latest configuration properties. Also the new beans generated after refresh happens will have new value,

I don't understand your concern on the issues that will cause due to the granular mechanism. My ask is simple If we are able to pass an optional request body with the specific properties to be refreshed to the /actuator/refresh endpoint Those values will get updated in the local property sources and rest changes will get un affected. ie it refreshes or recreates @ConfigurationProperties or @RefreshScope beans and newly creating beans. When endpoint /actuator/refresh endpoint without a body it will refreshes all the properties from last hit without affecting the changed properties.

Could you please provide more insights or suggestions on this approach?

@samuelj90
Copy link
Author

samuelj90 commented Aug 28, 2024

@spencergibb /@dwen77 / @zhenbianshu / @qdaxb / @andrew-yang / @spring-projects-issues /@martin-tarjanyi / @FrontierPsychiatrist / @OlgaMaciaszek /@wind57 Do any of you have any recommendations on this? Commenting for better visibility.

@ryanjbaxter
Copy link
Contributor

My main concern would be something like this...

foo=bar
hello=${foo}

What if you only refresh foo without refreshing hello?

Maybe you can be more specific about your concern about the Beans being reinitialized. What is the problem you are experiencing when this happens?

@samuelj90
Copy link
Author

samuelj90 commented Aug 29, 2024

@ryanjbaxter
In addressing this issue, my initial thought is to implement a straightforward solution, although I am cautious about potential consequences. It's crucial to ensure that the environment is re-evaluated after updating the specific properties. This can be accomplished by fetching the entire environment context and re-evaluating only the property placeholders that depend on the inputted values.

My thought process for this feature as it adds values to multiple team managing the configuration concurrently. Where one team update the configuration and hitting refresh will not get impacted to other team's configuration changes.
This especially can happens when cloud config clients integrated to vault.

@ryanjbaxter
Copy link
Contributor

My thought process for this feature as it adds values to multiple team managing the configuration concurrently. Where one team update the configuration and hitting refresh will not get impacted to other team's configuration changes.

So there is shared configuration values between apps/teams? I am confused how eventually all apps won't eventually get the updated configuration.

Or is it the case that multiple teams are updating the configuration of a single app? Again eventually the app will a complete refresh of its configuration once the app restarts at some point.

@samuelj90
Copy link
Author

@ryanjbaxter

For me app restart is out of scope of the refresh endpoint. I mean multiple team updating configuration of a single application.

@ryanjbaxter
Copy link
Contributor

For me app restart is out of scope of the refresh endpoint

Yes but once the apps restarts it will essentially act like a full refresh and all properties will be updated in which case the problem you are trying to avoid will happen.

@samuelj90
Copy link
Author

samuelj90 commented Aug 30, 2024

@ryanjbaxter

Our goal with the refresh endpoint is to avoid restarting the application. Therefore, we prefer not to mix the two approaches.

Additionally, when using the refresh endpoint, we want to ensure that only the intended configuration changes are applied, without incorporating changes made by others.

@ryanjbaxter
Copy link
Contributor

Additionally, when using the refresh endpoint, we want to ensure that only the intended configuration changes are applied, without incorporating changes made by others.

But again EVENTUALLY these changes will be applied. The other teams could use the same selective refresh mechanism to apply their changes for example. The app will also eventually be restarted. So this doesn't really solve the problem.

@samuelj90
Copy link
Author

samuelj90 commented Sep 19, 2024

I still don’t understand why we are mixing two things together.

The primary aim of the actuator refresh endpoint is to make configuration changes in the environment without restarting the application.

Currently, our strategy is to refresh everything at once which is similar to restart itself. One of the main issues with this approach is the uncertain impact on the application.

To mitigate this issue, we can consider a selective refresh instead of a full refresh.

Selective refresh can be done at:

Property source level
Property level, and so on.
I understand your point about restarts, but we are aiming for high availability with minimal restarts. That’s why we rely on the refresh endpoint.

@ryanjbaxter
Copy link
Contributor

ryanjbaxter commented Sep 19, 2024

I mean multiple team updating configuration of a single application.

So when team one updates configuration values and does a partial refresh and then team two updates configuration values and then does a partial refresh won't you run into the same issue as doing a full refresh?

@samuelj90
Copy link
Author

I think we are thinking differently I can explain the ask in a different way.

Configuration is the process of defining and managing the settings that determine how an application operates. These settings, often referred to as parameters or properties, influence various aspects of an application's behavior, such as its functionality, appearance, and performance.

Configuration settings can be adjusted over time to adapt to changing requirements or preferences. This flexibility is essential for maintaining the application's relevance and meeting evolving user needs.

Configuration decisions are typically influenced by a variety of stakeholders, including developers, system administrators, business analysts, and end-users. Each stakeholder may have different priorities and preferences, which can impact the configuration choices.

A full refresh involves updating all configuration settings at once. This can be useful when making significant changes to the application's behavior. However, it can also be risky, as it increases the potential for errors or unintended consequences. A more targeted approach, involving updates to specific properties, can be more efficient and less disruptive.

While a full refresh can be a powerful tool, it's important to exercise caution and ensure that it aligns with the expectations and requirements of all stakeholders. Unilateral changes can lead to conflicts or unexpected consequences. It's often best to involve relevant parties in the decision-making process and communicate any changes clearly and proactively.

Keeping in mind the refresh endpoint in Spring Boot Actuator provides a valuable mechanism for updating application properties without requiring a full restart. For almost stable applications we can expect restarts and redeployment is not too frequent.

@ryanjbaxter
Copy link
Contributor

After discussing this with the team we have decided to mark this as "waiting for votes" to see if anyone else would like this feature.

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

No branches or pull requests

3 participants