spring-cloud / spring-cloud-config

External configuration (server and client) for Spring Cloud
Apache License 2.0
1.96k stars 1.29k forks source link

Problem with Health Indicator. #571

Closed eacdy closed 7 years ago

eacdy commented 7 years ago

I've build a simple config server to test the Health Indicator .

Here goes my configuration:

server:
  port: 8080
spring:
  application:
    name: microservice-config-server
  cloud:
    config:
      server:
        git:
          uri: https://github.com/eacdy/spring-cloud-test-for-issue/
          username: null
          password: null
          search-paths:
            - config-repo
        health:
          repositories:
            a-foo:
              label: master
              name: microservice-foo
              profiles: dev

When I come to the /health endpoint, I can get this:

{
    "status": "UP",
    "configServer": {
        "status": "UP",
        "repositories": [
            {
                "sources": [
                    "https://github.com/eacdy/spring-cloud-test-for-issue/config-repo/microservice-foo-dev.properties",
                    "https://github.com/eacdy/spring-cloud-test-for-issue/config-repo/microservice-foo.properties"
                ],
                "name": "microservice-foo",
                "profiles": [
                    "dev"
                ],
                "label": "master"
            }
        ]
    },
    "diskSpace": {
        "status": "UP",
        "total": 107376275456,
        "free": 26694565888,
        "threshold": 10485760
    },
    "refreshScope": {
        "status": "UP"
    }
}

I found that https://github.com/eacdy/spring-cloud-test-for-issue/config-repo/microservice-foo-dev.properties returns 404. The right url is https://github.com/eacdy/spring-cloud-test-for-issue/blob/master/config-repo/microservice-foo-dev.properties

Code in org.springframework.cloud.config.server.environment.EnvironmentCleaner :

    public Environment clean(Environment value, String workingDir, String uri) {
        Environment result = new Environment(value);
        for (PropertySource source : value.getPropertySources()) {
            String name = source.getName().replace(workingDir, "");
            name = name.replace("applicationConfig: [", "");
            name = uri + "/" + name.replace("]", "");
            result.add(new PropertySource(name, source.getSource()));
        }
        return result;
    }

I think it should be

    public Environment clean(Environment value, String workingDir, String uri) {
        Environment result = new Environment(value);
        for (PropertySource source : value.getPropertySources()) {
            String name = source.getName().replace(workingDir, "");
            name = name.replace("applicationConfig: [", "");
            name = uri + "/blob/master/" + name.replace("]", "");
            result.add(new PropertySource(name, source.getSource()));
        }
        return result;
    }

Is it just a bug? Thanks a lot.

eacdy commented 7 years ago

@dsyer Could you help me?

dsyer commented 7 years ago

It's not really a bug. Those URLs are not really supposed to represent real resources. They are just unique (but helpful) identifiers.

eacdy commented 7 years ago

@dsyer Thank you very much.

shixiwanzi commented 6 years ago

I think it's not a bug

Sunyelw commented 5 years ago

I am reading your book Chapter 9,Take a bubble~