Using Spring Cloud Config in a docker container. springBootVersion = 2.6.6 springCloudConfigVersion = 3.1.1 springCloudVersion = 2021.0.1
My application.yaml looks like this:
spring:
application:
name: configserver
cloud:
config:
server:
git:
uri: ssh://git@bitbucket:7999/config/demo-config.git
refreshRate: 600
delete-untracked-branches: true
defaultLabel: master
repos:
app:
pattern: '*'
uri: ssh://git@bitbucket:7999/config/{application}-config.git
environment:
pattern: '*'
uri: ssh://git@bitbucket:7999/config/environments-aspect.git
when I test this, I get this in the logs: INFO 1 --- [https-jsse-nio-8443-exec-1] o.s.c.c.s.e.JGitEnvironmentRepository : Could not refresh default label main org.springframework.cloud.config.server.environment.NoSuchLabelException: No such label: main (+ 78 more lines) INFO 1 --- [https-jsse-nio-8443-exec-1] o.s.c.c.s.e.JGitEnvironmentRepository : Will try to checkout master label instead.
It looks as if spring.cloud.config.server.git.defaultLabel: master is not honored. I tried using spring.cloud.config.server.git.default-label with similar results.
Comment From: ns-rkusumoto
still an issue updating to: springBootVersion = 2.7.0 springCloudConfigVersion = 3.1.3 springCloudVersion = 2021.0.3
Comment From: ryanjbaxter
What is the request you are making?
Comment From: ns-rkusumoto
The issue I have with the current method of using git branch main first then master is that the logs for this when main does not exist is excessive.
I would like spring.cloud.config.server.git.defaultLabel: master to work as my default. It does not.
Comment From: ryanjbaxter
Yes but your configuration is not strait forward there are multiple repos involved. Its hard to reason why you are seeing this behavior based on the information provided. If you can provide a sample that reproduces problem that would allow us to best assist you.
Comment From: ns-rkusumoto
All my repos in bitbucket use master as default. This worked in prior versions of spring cloud config.
When the change to use main, then master, while it functioned, logs were excessive:
org.springframework.cloud.config.server.environment.NoSuchLabelException: No such label: main
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.refresh(JGitEnvironmentRepository.java:314) ~[spring-cloud-config-server-3.1.3.jar!/:3.1.3]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.getLocations(JGitEnvironmentRepository.java:262) ~[spring-cloud-config-server-3.1.3.jar!/:3.1.3]
at org.springframework.cloud.config.server.environment.AbstractScmEnvironmentRepository.findOne(AbstractScmEnvironmentRepository.java:55) ~[spring-cloud-config-server-3.1.3.jar!/:3.1.3]
at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.findOne(MultipleJGitEnvironmentRepository.java:153) ~[spring-cloud-config-server-3.1.3.jar!/:3.1.3]
at org.springframework.cloud.config.server.environment.CompositeEnvironmentRepository.findOne(CompositeEnvironmentRepository.java:64) ~[spring-cloud-config-server-3.1.3.jar!/:3.1.3]
at org.springframework.cloud.config.server.environment.EnvironmentEncryptorEnvironmentRepository.findOne(EnvironmentEncryptorEnvironmentRepository.java:61) ~[spring-cloud-config-server-3.1.3.jar!/:3.1.3]
at org.springframework.cloud.config.server.environment.EnvironmentController.getEnvironment(EnvironmentController.java:134) ~[spring-cloud-config-server-3.1.3.jar!/:3.1.3]
at org.springframework.cloud.config.server.environment.EnvironmentController.defaultLabel(EnvironmentController.java:110) ~[spring-cloud-config-server-3.1.3.jar!/:3.1.3]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282) ~[spring-core-5.3.20.jar!/:5.3.20]
at org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.invoke(GenericScope.java:485) ~[spring-cloud-context-3.1.3.jar!/:3.1.3]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.20.jar!/:5.3.20]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.20.jar!/:5.3.20]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.20.jar!/:5.3.20]
at org.springframework.cloud.config.server.environment.EnvironmentController$$EnhancerBySpringCGLIB$$ddccba29.defaultLabel(<generated>) ~[spring-cloud-config-server-3.1.3.jar!/:3.1.3]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.20.jar!/:5.3.20]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.20.jar!/:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.20.jar!/:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.20.jar!/:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.20.jar!/:5.3.20]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.20.jar!/:5.3.20]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.20.jar!/:5.3.20]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.20.jar!/:5.3.20]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.20.jar!/:5.3.20]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.20.jar!/:5.3.20]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.20.jar!/:5.3.20]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.63.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.20.jar!/:5.3.20]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.20.jar!/:5.3.20]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.20.jar!/:5.3.20]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.20.jar!/:5.3.20]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96) ~[spring-boot-actuator-2.7.0.jar!/:2.7.0]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.20.jar!/:5.3.20]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.20.jar!/:5.3.20]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.20.jar!/:5.3.20]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.63.jar!/:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.63.jar!/:na]
at java.base/java.lang.Thread.run(Unknown Source) ~[na:na]
Caused by: org.eclipse.jgit.api.errors.RefNotFoundException: Ref main cannot be resolved
at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:223) ~[org.eclipse.jgit-5.12.0.202106070339-r.jar!/:5.12.0.202106070339-r]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.checkout(JGitEnvironmentRepository.java:468) ~[spring-cloud-config-server-3.1.3.jar!/:3.1.3]
at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.refresh(JGitEnvironmentRepository.java:307) ~[spring-cloud-config-server-3.1.3.jar!/:3.1.3]
... 71 common frames omitted
2022-06-08 12:10:06.126 INFO 1 --- [https-jsse-nio-8443-exec-8] o.s.c.c.s.e.JGitEnvironmentRepository : Will try to checkout master label instead.
2022-06-08 12:10:06.196 INFO 1 --- [https-jsse-nio-8443-exec-8] o.s.c.c.s.e.NativeEnvironmentRepository : Adding property source: Config resource 'file [/tmp/config-repo-16011596117921709059/config-repo-15977568293077331989/application-prod.properties]' via location 'file:/tmp/config-repo-16011596117921709059/config-repo-15977568293077331989/'
So my preferences are: 1) default to master. This does not work. 2) reduce logging
Comment From: ryanjbaxter
Again I am trying to understand why setting defaultLabel
is not working please provide a sample
Comment From: ns-rkusumoto
The initial post had my application.yaml snippet:
spring:
application:
name: configserver
cloud:
config:
server:
git:
uri: ssh://git@bitbucket:7999/config/demo-config.git
refreshRate: 600
delete-untracked-branches: true
defaultLabel: master
repos:
app:
pattern: '*'
uri: ssh://git@bitbucket:7999/config/{application}-config.git
environment:
pattern: '*'
uri: ssh://git@bitbucket:7999/config/environments-aspect.git
so you see I am setting:
spring.cloud.config.server.git.defaultLabel: master
but the logs show that it is still defaulting to main before checking for master.
Comment From: ryanjbaxter
That is not a working sample
Comment From: ns-rkusumoto
I don't know how to show a working sample of my airgapped environment. Please help.
Comment From: ns-rkusumoto
```spring: application: name: configserver cloud: config: server: git: uri: ssh://git@github.com:ns-rkusumoto/spring-cloud-config-label.git refreshRate: 600 delete-untracked-branches: true defaultLabel: master
Created git repo that only has master branch. Using the above config, there's a lot of log data generated due to no main branch and the defaultLabel: master not being honored.
**Comment From: ryanjbaxter**
I created a sample using Spring Boot 2.7.2, Spring Cloud 2021.0.3
With this config
spring: cloud: config: server: git: uri: https://github.com/ryanjbaxter/s1-2021-config default-label: master
Here are the logs I get
2022-07-28 10:52:53.455 INFO 36377 --- [ main] com.example.master.MasterApplication : No active profile set, falling back to 1 default profile: "default" 2022-07-28 10:52:54.146 INFO 36377 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=ba075623-c82d-3643-9ad7-a10ed8c957f1 2022-07-28 10:52:54.368 INFO 36377 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2022-07-28 10:52:54.375 INFO 36377 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-07-28 10:52:54.375 INFO 36377 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65] 2022-07-28 10:52:54.465 INFO 36377 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2022-07-28 10:52:54.465 INFO 36377 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 978 ms 2022-07-28 10:52:55.094 INFO 36377 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2022-07-28 10:52:55.113 INFO 36377 --- [ main] com.example.master.MasterApplication : Started MasterApplication in 2.032 seconds (JVM running for 2.674) 2022-07-28 10:53:00.933 INFO 36377 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet' 2022-07-28 10:53:00.934 INFO 36377 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet' 2022-07-28 10:53:00.935 INFO 36377 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms 2022-07-28 10:53:02.847 INFO 36377 --- [nio-8080-exec-1] o.s.c.c.s.e.NativeEnvironmentRepository : Adding property source: Config resource 'file [/var/folders/k3/zv8hzdm17vv69j485fv3cf9r0000gp/T/config-repo-5772776430190818249/application.yaml]' via location 'file:/var/folders/k3/zv8hzdm17vv69j485fv3cf9r0000gp/T/config-repo-5772776430190818249/' (document #0)
**Comment From: spring-cloud-issues**
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
**Comment From: ns-rkusumoto**
Since I'm the only one getting the excessive logging and can't replicate this issue, please close.
**Comment From: gabriel-lafreniere**
Hello, we are getting the same exception with Spring Cloud 3.1.0 and Spring Boot 2.6.4
spring: cloud: config: server: git: uri: ${SPRING_CLOUD_CONFIG_SERVER_GIT_URI} passphrase: ${SPRING_CLOUD_CONFIG_SERVER_GIT_PASSPHRASE} private-key: ${SPRING_CLOUD_CONFIG_SERVER_GIT_PRIVATE_KEY} ignore-local-ssh-settings: true default-label: master force-pull: true #temporary for testing
.c.s.e.MultipleJGitEnvironmentRepository : Could not checkout default label main
org.eclipse.jgit.api.errors.RefNotFoundException: Ref main cannot be resolved
Any idea what the issue might be?
**Comment From: ryanjbaxter**
Can you try the latest Boot and Cloud releases?
**Comment From: raffig**
Just for clarity for those who hit this issue:
I've just completed the upgrade to Spring Boot 2.7.4 (Spring Cloud Config 3.1.4) and I can confirm that this property works fine.
Also please note that accordingly to the docs:
https://docs.spring.io/spring-cloud-config/docs/3.1.4/reference/html/#_default_label
Default label is set to `main`, but if there is no `main` branch in given GIT repository fallback to branch `master` will occur, and I can confirm this with following log entries:
INFO - Could not checkout default label main org.eclipse.jgit.api.errors.RefNotFoundException: Ref main cannot be resolved INFO - Will try to checkout master label instead ```
It means that if you use master
branch there is no need to set this property at all.
Summarizing this feature seems to work fine with versions mentioned above.
Comment From: ns-rkusumoto
looks like because I defined spring.cloud.config.server.git.repos.app and spring.cloud.config.server.git.repos.environment there were separate spring.cloud.config.server.git.repos.app.defaultLabel and spring.cloud.config.server.git.repos.environment.defaultLabel set to main. Using spring.cloud.config.server.git.defaultLabel = master did not override these settings so I had to explicitly set defaultLabel to master in those 2 places.
My massive logging issue because of the main not found, using master is now resolved.
version tested: Spring Cloud Config 4.0.4, Spring Boot 3.1.4, Spring Cloud 2022.0.4