Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support Multiple Labels In Environment Repositories #2449

Closed
ats1999 opened this issue Aug 10, 2024 · 9 comments · Fixed by #2455, #2567, #2564, #2561 or #2454
Closed

Support Multiple Labels In Environment Repositories #2449

ats1999 opened this issue Aug 10, 2024 · 9 comments · Fixed by #2455, #2567, #2564, #2561 or #2454
Milestone

Comments

@ats1999
Copy link

ats1999 commented Aug 10, 2024

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.

@ryanjbaxter
Copy link
Contributor

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?

@ats1999
Copy link
Author

ats1999 commented Aug 13, 2024

Will check and let you know

@ats1999
Copy link
Author

ats1999 commented Aug 13, 2024

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?

@ryanjbaxter
Copy link
Contributor

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?

@ats1999
Copy link
Author

ats1999 commented Aug 24, 2024

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

@kvmw
Copy link
Contributor

kvmw commented Sep 5, 2024

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

@ryanjbaxter
Copy link
Contributor

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

@blackr1234
Copy link

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.

@ryanjbaxter
Copy link
Contributor

Yes it is clearly not supported today.

@ryanjbaxter ryanjbaxter removed this from 2023.0.4 Oct 1, 2024
@ryanjbaxter ryanjbaxter modified the milestones: 4.1.4, 4.2.0-M2 Oct 1, 2024
@ryanjbaxter ryanjbaxter linked a pull request Oct 2, 2024 that will close this issue
ryanjbaxter added a commit that referenced this issue Oct 2, 2024
* Support multiple labels in NativeEnvironmentRepository

Related to #2449

* Reverse labels

---------

Co-authored-by: Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com>
ryanjbaxter added a commit that referenced this issue Oct 2, 2024
* Support multiple labels in JdbcEnvironmentRepository

Fixes #2449

* Reversing labels

---------

Co-authored-by: Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com>
@ryanjbaxter ryanjbaxter changed the title Multiple labels with JDBC not working Support Multiple Labels In Environment Repositories Oct 2, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment