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

Random port config makes management.context-path invalid #3099

Closed
Flamingo93 opened this issue Jul 23, 2018 · 5 comments
Closed

Random port config makes management.context-path invalid #3099

Flamingo93 opened this issue Jul 23, 2018 · 5 comments

Comments

@Flamingo93
Copy link

Flamingo93 commented Jul 23, 2018

Config random server port by

server:
  port: 0

Also, I want to customize the prefix for the management endpoints, so I config eureka management.context-path by

management:
  context-path: /manage
eureka:
  instance:
    metadata-map:
      management:
        context-path: ${management.context-path}

Then, I found that default statusPageUrl and healthCheckUrl from eureka won't work, retrun 404.
Default statusPageUrl is "host:port/info" and it don't work, but "host:port/manage/info" still work.

Checking the source code, I found that in spring-cloud-netflix-eureka-client DefaultManagementMetadataProvider class, it process random port by

    public ManagementMetadata get(EurekaInstanceConfigBean instance, int serverPort,
                                  String serverContextPath, String managementContextPath,
                                  Integer managementPort) {
        if (isRandom(managementPort)) {
            return null;
        }
        if (managementPort == null && isRandom(serverPort)) {
            return null;
        }
        String healthCheckUrl = getHealthCheckUrl(instance, serverPort, serverContextPath,
                managementContextPath, managementPort, false);
        String statusPageUrl = getStatusPageUrl(instance, serverPort, serverContextPath,
                managementContextPath, managementPort);

        ManagementMetadata metadata = new ManagementMetadata(healthCheckUrl, statusPageUrl, managementPort == null ? serverPort : managementPort);
        if(instance.isSecurePortEnabled()) {
            metadata.setSecureHealthCheckUrl(getHealthCheckUrl(instance, serverPort, serverContextPath,
                    managementContextPath, managementPort, true));
        }
        return metadata;
    }

It will return null metadata when config port random, so that make default statusPageUrl and healthCheckUrl invalid.
Is it intentional or a bug? If intentional, why? Thx.

@spencergibb
Copy link
Member

Please reopen if you can describe the problem or create a sample that reproduces it

@Flamingo93 Flamingo93 changed the title Config random port Config random port make management.context-path invalid Jul 23, 2018
@Flamingo93
Copy link
Author

Flamingo93 commented Jul 23, 2018

I don't have right to reopen issue closed by repo collaborator.
@spencergibb

@ryanjbaxter
Copy link
Contributor

Provide the information requested and we will repopen.

@Flamingo93
Copy link
Author

I have update the information. Am I clear?
@spencergibb @ryanjbaxter

@ryanjbaxter
Copy link
Contributor

This is a duplicate of #3098

@Flamingo93 Flamingo93 changed the title Config random port make management.context-path invalid Random port config makes management.context-path invalid Sep 18, 2018
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