SteeltoeOSS / Steeltoe

.NET Components for Externalized Configuration, Database Connectors, Service Discovery, Logging and Distributed Tracing, Application Management, Security, and more.
https://steeltoe.io
Apache License 2.0
1.01k stars 163 forks source link

Usage of RefreshActuator with HTTP POST #611

Closed iliya24 closed 1 month ago

iliya24 commented 3 years ago

Question

I am trying to use RefreshActuator in order to reload configuration in run time I have followed this documentation

Environment (please complete the following information):

also tried

 public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        {
            var builder = WebHost.CreateDefaultBuilder(args)                

                .AddAllActuators()
                .AddConfigServer()

                .UseStartup<Startup>();
            return builder;
        }

and my appsettings.json is "Management": { "Endpoints": { "Exposure": { "Include": [ "*" ] } } } and appsettings.Development.json "Management": { "Endpoints": { "Exposure": { "Include": [ "*" ] } } } but when I call from postman http://localhost:8080/actuator/refresh it the result is image

and in my webapi the new value is not reflected in the configuration but if I check the spring server values it is updated
http://localhost:8888/my-values/default i see new values I have tried to use IOptionsMonitor<Logging> and also DI the IConfiguration both are not updated with new values

TimHess commented 3 years ago

Try using a GET request instead of POST.

I'm not sure why the verb isn't defined in the docs, but since there is no request body it makes the most sense to be GET

iliya24 commented 3 years ago

HI I tried to use post as per this tutorial https://www.youtube.com/watch?v=yNnLICy2zk4&ab_channel=JavaBrains the name is "Dynamic config with spring Boot - Microservice configuration with Spring Boot [13]" I tried to get as u suggested it returns some configurations and did update the values ;) pls can u check the tutorial and see why in steeltoe it is different or why the post is not working , the body suppose to be empty again as in the tutorial above. The purpose of http://localhost:8080/actuator/refresh is not to get the values!!! it suppose to be some sort of the webhook for the service config to get notify that values are updated in the server and pull them so even after using "get" verb in sted of "post" it did somehow triggered the service to updated the values but I just wanted to explain that the return of the verb are not the values it is only a trigger .

TimHess commented 3 years ago

As far back as I can recall, this endpoint has been setup for GET out of the box, but there is an AllowedVerbs config property that should allow the actuator to listen for POST requests. Unfortunately that setting does not appear to be working with current version. This could be related to changes during the transition to endpoint routing, but that's a guess at this point. The core team is deep in other issues at the moment, this issue could be a good one for community contribution

patrickcbrown commented 2 years ago

Hi, this appears to still be an issue, is there a plan to fix this so it aligns with Javas actuator/refresh behavior? Regarding the AllowVerbs I can see in the code where they are explicitly set to null with a comment that they should not be set via configuration…other actuators have them hard coded to GET, POST

thompson-tomo commented 8 months ago

@TimHess with the changes in https://github.com/SteeltoeOSS/Steeltoe/commit/9dd18a23d6db5c735e4b868fd4ea240a63034b5e it appears to have been switched to the POST. Is there a need to back port the changes to v3. Note the changes in the above i would consider a breaking change as the current solution has removed the GET

TimHess commented 8 months ago

Right again @thompson-tomo, thanks for looking into this. It would be nice to ensure that developers have a choice of http verb as the configuration is documented to permit. Given the scope of that changeset I don't know offhand that it will be straightforward to backport anything, but if you have time and interest in making sure that POST can be configured for this actuator in v3 that would be appreciated