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

Endpoint exposure patterns do not work with dashed IDs #20997

Closed
NoMindToThink opened this issue Apr 17, 2020 · 15 comments
Closed

Endpoint exposure patterns do not work with dashed IDs #20997

NoMindToThink opened this issue Apr 17, 2020 · 15 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@NoMindToThink
Copy link

NoMindToThink commented Apr 17, 2020

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 17, 2020
@snicoll snicoll changed the title bus-refresh endpoint does not work Could not expose an endpoint that has a dash in its id Apr 17, 2020
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 17, 2020
@snicoll snicoll added this to the 2.1.x milestone Apr 17, 2020
@snicoll
Copy link
Member

snicoll commented Apr 17, 2020

@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

@snicoll snicoll removed this from the 2.1.x milestone Apr 17, 2020
@snicoll snicoll added status: waiting-for-triage An issue we've not yet triaged and removed type: bug A general bug labels Apr 17, 2020
@NoMindToThink
Copy link
Author

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

@NoMindToThink
Copy link
Author

it need from a property value, not annotation

@NoMindToThink
Copy link
Author

@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
Copy link
Member

snicoll commented Apr 18, 2020

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.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Apr 18, 2020
@NoMindToThink
Copy link
Author

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.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Apr 18, 2020
@NoMindToThink
Copy link
Author

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
Copy link
Author

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
Copy link
Member

snicoll commented Apr 18, 2020

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.

@snicoll snicoll closed this as completed Apr 18, 2020
@snicoll snicoll added status: invalid An issue that we don't feel is valid and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Apr 18, 2020
@NoMindToThink
Copy link
Author

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
  1. 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
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 philwebb reopened this Apr 19, 2020
@philwebb philwebb self-assigned this Apr 19, 2020
@philwebb philwebb added status: waiting-for-triage An issue we've not yet triaged and removed status: invalid An issue that we don't feel is valid status: waiting-for-triage An issue we've not yet triaged labels Apr 19, 2020
@philwebb philwebb added the type: bug A general bug label Apr 19, 2020
@philwebb philwebb added this to the 2.1.14 milestone Apr 19, 2020
@philwebb philwebb changed the title Could not expose an endpoint that has a dash in its id Endpoint exposure patterns do not work with dashed IDs Apr 19, 2020
@philwebb
Copy link
Member

@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
Copy link
Author

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

@NoMindToThink
Copy link
Author

@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 philwebb reopened this Apr 20, 2020
@philwebb
Copy link
Member

Reopening because we have a similar issue in OnAvailableEndpointCondition

@philwebb
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants