Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Config Server - No such label: master

I have a simple Spring Cloud Config Server which consume configuration from git server.

ConfigServer bootstrap.yml :

spring:
  application:
    name: config-service
  cloud:
    config:
      server:
        git:
          uri: ssh://git@mydomain:myport/myrepo.git
          searchPaths: "configurations/{application}/{profile}"
server:
  port: 8888

When I deploy ConfigServer on local, I can retrieve configuration from http://localhost:8888/myapp/test. But when I deploy ConfigServer on test server, it throws No such label: master when I hit http://testserverip:8888/myapp/test.

Any help would be most appreciated!

enter image description here

like image 872
mstzn Avatar asked Oct 13 '16 14:10

mstzn


7 Answers

I know that I'm posting this answer very very late. But, still posting it so that other folks can find this helpful. Now a days, default branch name of GitHub is "main", but Spring Cloud Config still looks for "master" as a label name. So, if you want to change the default behavior, you can always change the label name look up using below property in application.yml or application.properties:

spring.cloud.config.server.git.default-label=main

This worked very well for me. I'm using Spring Boot 2.3.6.RELEASE

like image 197
Anish Panthi Avatar answered Oct 05 '22 10:10

Anish Panthi


GitHub created default branch "main" , however Spring cloud Config was looking for "master branch". I have created a "master" branch and it worked!

like image 40
Rajiv Srivastava Avatar answered Oct 05 '22 10:10

Rajiv Srivastava


This happens when your service cannot access to Git repository. Since you can start your application, I assume test server can reach to Git. You should set up SSH authentication to your Git server. You can check this site for SSH configuration.

like image 45
bhdrkn Avatar answered Oct 05 '22 09:10

bhdrkn


I faced this same annoying scenario.

I'll first state how I solved this scenario and will later emphasize my mistakes which I did in my previous approaches. In my context, I'm using application.properties

My application overview looks like below: I have a config-server which is centralized & provides the respective configuration data to the respective micro-services.

For instance, a micro-service 'limits-service', requires some configuration data, it gets it from the central configuration server('spring-cloud-config-server'). Hence to achieve this, 'limits-service' queries the central config server which in-turn fetches the requested data from a remote git branch('spring-cloud-samples').

                            ┌---------------------- <--> [currency-exchange-service]
    [git] <--> [spring-cloud-config-server] ------- <--> [limits-service] 
                            └---------------------- <--> [currency-conversion-service]

Solution:

I simply created a new Git Repository (spring-cloud-samples) for all the configuration files which would be consumed by several micro-services through a central configuration server.

In the application.properties file of central configuration server('spring-cloud-config-server'), I have provided a property as:

spring.cloud.config.server.git.uri=https://github.com/{username}/{git-reponame.git}

which might look like

spring.cloud.config.server.git.uri=https://github.com/alice123/spring-cloud-samples.git That's it!

On starting my central-config-server & observe the log which is as follows:

2020-02-17 05:25:07.867  INFO 15000 --- [nio-8888-exec-9] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/D:/Users/{userName}/AppData/Local/Temp/config-repo-3453413414/limits-service.properties

Moreover, I also consumed the config-data through my 'limits-service' & it worked like a charm!

I tried the following things that resulted in failures and a lot of screaming & yelling. XD

I'm posting it, just so that someone who's trying this same concept might save a night's work or maybe less :p

1) Initially, I was using my Git Repositories SSH URL in my application.properties file of central-config-server like follows:

[email protected]:alice123/spring-cloud-samples.git
spring.cloud.config.server.git.username=alice123
spring.cloud.config.server.git.password=alice123Pwd

which resulted in the following error:

2020-02-17 05:22:45.091  WARN 15000 --- [nio-8888-exec-1] .c.s.e.MultipleJGitEnvironmentRepository : Error occured cloning to base directory.
org.eclipse.jgit.api.errors.TransportException: [email protected]:aniketrb-github/spring-cloud-samples.git: Auth fail

2) Later, I tried to read the config data from a native/local git directory, which was pointing to my Git remote branch(spring-cloud-samples) Then I provided the following in my application.properties file:

spring.cloud.config.server.git.uri=file://D:\aniket-workspace\github-ws\microservices\udemy-microservices\git-localconfig-repo

This crashed with:

java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.properties'

3) Later after enough googling, I changed the above property to below which worked!!:

spring.cloud.config.server.git.uri=D:\\\\alice-workspace\\\\github-ws\\\\microservices\\\\git-localconfig-repo

The 'limits-service' eventually failed while it tried to get the config-data from 'spring.cloud.config.server' with following error:

404: Not Found - "org.springframework.cloud.config.server.environment.NoSuchLabelException: No such label: master"

The solution I've stated worked for me due to all the failures I came across which I mentioned above. Please correct me if I'm wrong & improvise if necessary. I hope this helps and saves some crucial time.

References: spring-cloud-config, https-or-ssh, git-ssh-windows, git-ssh-windows-troubleshooting

like image 44
Aniket Avatar answered Oct 05 '22 10:10

Aniket


In my case nothing of given answers worked. only thing that worked is setting default-label to master

spring.cloud.config.server.git.default-label=master
like image 37
Saurabh Dhage Avatar answered Oct 05 '22 10:10

Saurabh Dhage


When you create a new repository, nowdays git makes "main" as the default branch instead of master. This issue is all about this.

Create "master" branch manually. It will solve all these issues.

like image 40
DHEERAJ KUMAR GUPTA Avatar answered Oct 05 '22 09:10

DHEERAJ KUMAR GUPTA


for me this caused due to my default branch 'main'. whenever you create a new branch the default branch is 'main' not 'master' anymore. but spring server config look for master branch. the quick solution is to checkout a new branch called 'master' from 'main' branch. and try from spring config server. thats it.

to create a new branch from main branch. first point to main branch and from there

git checkout -b master git push --set-upstream origin master

restart your config server and test

like image 36
somspeaks Avatar answered Oct 05 '22 11:10

somspeaks