spring-cloud / spring-cloud/spring-cloud-config

Cannot start config server on temporary git repository availability problems

Open
#1,760 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
2k
Forks
1.3k
Avg merge
2d 59m
Merged PRs (30d)
16

Description

Is your feature request related to a problem? Please describe.
There is an option to specify git basedir spring.cloud.config.server.git.basedir to have a static place to checkout git repository to. That said, if such repository exists in a specified location the config server should start even if it cannot pull from it at the moment of start. That happens, when the git repo is gone and config server was already running. But it turns out when it is down during config server startup - the startup fails on spring context initialization.

Describe the solution you'd like
Config server should acknowledge the fact that the repository in the specified basedir exists, and startup and serve values from that repository until the remote repository is back online

Additional context
I have tested it by disabling git repository host in my firewall rules. The config server runs fine until I restart it. The errors I get:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultEnvironmentRepository' defined in class path res
ource [org/springframework/cloud/config/server/config/DefaultRepositoryConfiguration.class]: Invocation of init method failed; nested exception is org.ecl
ipse.jgit.api.errors.TransportException: ssh://git@bitbucket.myorg.com:7999/apps/config.git: timeout: socket is not established
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1464)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1428)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1319)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1206)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1168)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:668)
        ... 149 common frames omitted
Caused by: org.eclipse.jgit.api.errors.TransportException: ssh://git@bitbucket.myorg.com:7999/apps/config.git: timeout: socket is not established
        at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:254)
        at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:306)
        at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:200)
        at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.cloneToBasedir(JGitEnvironmentRepository.java:574)
        at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.initClonedRepository(JGitEnvironmentRepository.java:332)
        at org.springframework.cloud.config.server.environment.JGitEnvironmentRepository.afterPropertiesSet(JGitEnvironmentRepository.java:251)
        at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.afterPropertiesSet(MultipleJGitEnvironmentRepository.java:68)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
        ... 162 common frames omitted
Caused by: org.eclipse.jgit.errors.TransportException: ssh://git@bitbucket.myorg.com:7999/apps/config.git: timeout: socket is not established
        at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:192)
        at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:140)
        at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:280)
        at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:170)
        at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:137)
        at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:123)
        at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1271)
        at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:243)
        ... 170 common frames omitted
Caused by: com.jcraft.jsch.JSchException: timeout: socket is not established
        at com.jcraft.jsch.Util.createSocket(Util.java:394)
        at com.jcraft.jsch.Session.connect(Session.java:215)
        at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:146)
        ... 177 common frames omitted

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing initialization through DefaultRepositoryConfiguration and MultipleJGitEnvironmentRepository.afterPropertiesSet(), then inspect JGitEnvironmentRepository.initClonedRepository() and cloneToBasedir(). The change is complete when a configured existing basedir lets the config server start and serve its cached values while the remote Git repository is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, java, spring
Domain
backend, cloud
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.