spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.61k stars 40.55k forks source link

Endpoint exposure patterns do not work with dashed IDs #20997

Closed NoMindToThink closed 4 years ago

NoMindToThink commented 4 years ago

springboot version : 2.2.6.RELEASE springcloud version: Hoxton.SR3

When I use the bus-fresh endpoint, I find it does not work my yml is :

management:
  endpoints:
    web:
      exposure:
        include: bus-refresh

But I tried to use * instead of bus-refresh, it started working,for example:

management:
  endpoints:
    web:
      exposure:
        include: "*"

This prevents me from just opening the bus-refresh endpoint。 when i checked source code , i found the reason,in org.springframework.boot.actuate.endpoint.EndpointId, line 145

    public static EndpointId fromPropertyValue(String value) {
        return new EndpointId(value.replace("-", ""));
    }

bus-refresh is replaced with busrefresh, which cannot be matched。 please help me, How to expose only bus-refresh endpoint? Please forgive me for my poor English, tks

snicoll commented 4 years ago

@gi122281742 I've tested with a small sample and couldn't reproduce the problem. Can you please share a small sample that reproduces the problem you've described? Either update my app or share your own (a zip or a link to a github repo). Thanks

NoMindToThink commented 4 years ago

sconfig-server.zip this is config-server, It needs to work with eurekaserver

NoMindToThink commented 4 years ago

it need from a property value, not annotation

NoMindToThink commented 4 years ago

@gi122281742 I've tested with a small sample and couldn't reproduce the problem. Can you please share a small sample that reproduces the problem you've described? Either update my app or share your own (a zip or a link to a github repo). Thanks

it call EndpointId.fromPropertyValue。it need from a property value, not annotation, thanks

snicoll commented 4 years ago

it need from a property value, not annotation

What does that mean? It is a property value

it call EndpointId.fromPropertyValue。it need from a property value, not annotation, thanks

Sorry but I don't know what that means. Can we take a step back and can you please share something I can run that reproduces the problem? If the config server has to be involved for the problem to happen, then please share a sample that I can run myself to actually see the problem.

I don't need your app by the way so all the extra config is not necessary.

NoMindToThink commented 4 years ago

My application is a simple config server and springcloud bus, and then I want to just open the bus-refresh endpoint, but I’can‘t.

NoMindToThink commented 4 years ago

I want to open the bus-refresh endpoint of the config server, but the configuration as "bus-refresh" is invalid and must be configured as "*"。

NoMindToThink commented 4 years ago

it need from a property value, not annotation

What does that mean? It is a property value

it call EndpointId.fromPropertyValue。it need from a property value, not annotation, thanks

Sorry but I don't know what that means. Can we take a step back and can you please share something I can run that reproduces the problem? If the config server has to be involved for the problem to happen, then please share a sample that I can run myself to actually see the problem.

I don't need your app by the way so all the extra config is not necessary.

By the way, regarding only bus-refresh, the same configuration file, the springcloud version Hoxton.SR1 can work normally, but Hoxton.SR3 can not.

snicoll commented 4 years ago

That's a lot to digest and I still don't know how to reproduce the problem. You shared no instructions so I ran your app but there is no configuration with the default profile. If I activate the cs1 profile, I can see that the bus-refresh endpoint is available. So things are working as expected for me.

I am going to close this now as there is no indication of a problem in Spring Boot. If you provide the exact steps to reproduce the problem, I am happy to reopen and have another look.

NoMindToThink commented 4 years ago

this is my project git: https://github.com/gi122281742/springcloud-bus-test.git.

  1. First introduce two modules, config-client and sconfig-server.
  2. Configure your own rabbitmq related information.
  3. Start sconfig-server and config-client in order.
  4. Then use the get method to access http://localhost:7070/config/dev and http://localhost:7081/hello. Can get a normal response. as follows
    
    GET:http://localhost:7070/config/dev:
    {"name":"config","profiles":["dev"],"label":null,"version":"b4f6edb221361d4f32184e379c2be760f0c62365","state":null,"propertySources":[{"name":"https://github.com/gi122281742/spring-config.git/config-dev.yml","source":{"name":"dev041901"}}]}

GET:http://localhost:7081/hello: dev041901

5. But according to the documentation, I request the bus-refresh of sconfig-server or config-client by POST to try to refresh the config file.
Got the following result
```json
post: http://localhost:7070/actuator/bus-refresh
{
    "timestamp": "2020-04-19T01:50:37.635+0000",
    "status": 405,
    "error": "Method Not Allowed",
    "message": "Request method 'POST' not supported",
    "path": "/actuator/bus-refresh"
}
POST: http://localhost:7081/actuator/bus-refresh
{
    "timestamp": "2020-04-19T01:50:34.243+0000",
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/actuator/bus-refresh"
}

This does not refresh the configuration, but if I modify the configuration of the relevant files in the project as follows

management:
  endpoints:
    web:
      exposure:
        include: "*"

In this case, after requesting / actuator / bus-refresh, you will get an empty body. Print log at the same time

2020-04-19 10:02:51.738  INFO 20672 --- [nio-7081-exec-5] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2020-04-19 10:02:53.505  INFO 20672 --- [nio-7081-exec-5] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2020-04-19 10:02:53.517  INFO 20672 --- [nio-7081-exec-5] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:7070
2020-04-19 10:02:56.254  INFO 20672 --- [nio-7081-exec-5] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=config, profiles=[dev], label=master, version=b4f6edb221361d4f32184e379c2be760f0c62365, state=null
2020-04-19 10:02:56.254  INFO 20672 --- [nio-7081-exec-5] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://github.com/gi122281742/spring-config.git/config-dev.yml'}]
2020-04-19 10:02:56.255  INFO 20672 --- [nio-7081-exec-5] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
2020-04-19 10:02:56.258  INFO 20672 --- [nio-7081-exec-5] o.s.boot.SpringApplication               : Started application in 6.25 seconds (JVM running for 111.708)
2020-04-19 10:02:56.321  INFO 20672 --- [nio-7081-exec-5] o.s.cloud.bus.event.RefreshListener      : Received remote refresh request. Keys refreshed []

And can get the value of the modified configuration file. My English is poor, but I hope you can understand. PS: If I change the springcloud version to Hoxton.SR1 in pom.xml, this problem will not occur.

<spring-cloud.version>Hoxton.SR1</spring-cloud.version>

Last but not least, thank you for your reply. But this is really a problem, I think he has not been closed.

philwebb commented 4 years ago

@gi122281742 Thanks for the additional instructions. This turned out to be a bug in our filtering logic. It should be fixed in the next release. As a workaround, I think using the following will work with the release that you're on:

management:
  endpoints:
    web:
      exposure:
        include: busrefresh
NoMindToThink commented 4 years ago

Thank you for your reply, I am very honored to be able to suggest something useful!

NoMindToThink commented 4 years ago

@gi122281742 Thanks for the additional instructions. This turned out to be a bug in our filtering logic. It should be fixed in the next release. As a workaround, I think using the following will work with the release that you're on:

management:
  endpoints:
    web:
      exposure:
        include: busrefresh

But this configuration still can not use bus-refreh endpoint, but it does not matter, I can also use "*" to replace it temporarily, or downgrade to use "Hoxton.SR1" version of spingcloud.

philwebb commented 4 years ago

Reopening because we have a similar issue in OnAvailableEndpointCondition

philwebb commented 4 years ago

Actually, OnAvailableEndpointCondition is a 2.2.x concern so I've opened #21044