spring-cloud-config icon indicating copy to clipboard operation
spring-cloud-config copied to clipboard

Multiple labels with JDBC not working

Open ats1999 opened this issue 1 year ago • 5 comments

My spring cloud config server is using JDBC as backend. My requirement is to use multiple labels to fetch config.

When fetching data using http://localhost:8888/test_app,test_app2/dev,prod/master URL i am getting the following response

{
  "name": "test_app,test_app2",
  "profiles": [
    "dev,prod"
  ],
  "label": "master",
  "version": null,
  "state": null,
  "propertySources": [
    {
      "name": "test_app2-prod",
      "source": {
        "name_dev": "rahul_dev9999"
      }
    },
    {
      "name": "test_app-prod",
      "source": {
        "name": "rahul"
      }
    },
    {
      "name": "test_app2-dev",
      "source": {
        "name_dev": "rahul_dev9999"
      }
    },
    {
      "name": "test_app-dev",
      "source": {
        "name_dev": "rahul_dev"
      }
    }
  ]
}

But getting empty response after adding another label, http://localhost:8888/test_app,test_app2/dev,prod/master,feature

{
  "name": "test_app,test_app2",
  "profiles": [
    "dev,prod"
  ],
  "label": "master,feature",
  "version": null,
  "state": null,
  "propertySources": []
}

Is this supported by spring cloud config?

It is required when working on feature branch, i want all configs to be pulled from master label while certain config from feature label.

ats1999 avatar Aug 10 '24 02:08 ats1999

I believe it should be supported. Have you tried it using the native file system as a back end to see if that supports multiple labels?

ryanjbaxter avatar Aug 12 '24 21:08 ryanjbaxter

Will check and let you know

ats1999 avatar Aug 13 '24 02:08 ats1999

Not working with file system backend as well

Spring cloud config server application.properties

spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=/Users/ats1999/Desktop/projects/w3worker/config-service/config-server/src/main/resources/config

/Users/ats1999/Desktop/projects/w3worker/config-service/config-server/src/main/resources/config/auth-dev-master.properties

auth=auth.dev.master

Upon querying http://localhost:8888/auth/dev/master, i am getting empty output.

But once i removed master from auth-dev-master.properties, i am getting the desired properties with or without label in http://localhost:8888/auth/dev/master

Is this desired behaviour?

ats1999 avatar Aug 13 '24 02:08 ats1999

No I don't think so. When I try this using a native backend I am getting a 500 back from the config server, is that not what you are seeing?

ryanjbaxter avatar Aug 23 '24 17:08 ryanjbaxter

Nope, i didn’t get 500. I got empty response as said

ats1999 avatar Aug 24 '24 14:08 ats1999

@ryanjbaxter I believe, currently, none of the environment repositories support multiple labels. Is there any doc/spec about such feature?

kvmw avatar Sep 05 '24 15:09 kvmw

There isn't much, but there is this mention of using multiple labels in the docs

For instance, you might want to align the config label with your branch but make it optional (in that case, use spring.cloud.config.label=myfeature,develop).

I haven't checked other environment repositories other than JDBC and native

ryanjbaxter avatar Sep 05 '24 15:09 ryanjbaxter

You can check the code here:

JdbcEnvironmentRepository.java

The label isn't converted into an array and iterated in a for loop, unlike application and profile.

So multiple labels isn't supported in the latest GA version 4.1.3.

blackr1234 avatar Sep 07 '24 17:09 blackr1234

Yes it is clearly not supported today.

ryanjbaxter avatar Sep 18 '24 16:09 ryanjbaxter