Search code examples
gitsshbitbucketssh-keysspring-cloud-config

Spring Cloud Config Server - MultipleJGitEnvironmentRepository : Could not fetch remote for master remote


I'm trying to set up a spring cloud config server which fetches configs from a git repo using SSH key. It is running with springBootVersion 2.1.0.RELEASE and springCloudVersion Greenwich.M3.

The config service works fine without issues when using https bitbucket URI with username and password with below config:

  security.user:
    name: xxxxx
    password: xxxxx
  cloud.config.server:
    git:
      uri: https://bitbucket.org/abc/configs.git
      username: uname
      password: pass

But we had to migrate to use ssh key instead of username and password with the below configuration:

  security.user:
    name: xxxxx
    password: xxxxx
  cloud.config.server:
    git:
      uri: [email protected]:abc/configs.git

The id_rsa private key file is in .ssh folder with the config file:

Host bitbucket.org
    StrictHostKeyChecking no
    IdentityFile /home/user/.ssh/id_rsa

The initial git clone works fine and we are able to fetch the configs without any issues when I hit http://xxxx:xxxx@localhost:8899/app/dev.

But after that, there are lots of WARNs in the logs that its not able to fetch from remote. After the initial clone, further updates to the configs are also fetched properly. But not sure why there these many WARNs in the logs and it concerns me.

2020-07-31 11:38:51.636 WARN 1 --- [io-48899-exec-7] .c.s.e.MultipleJGitEnvironmentRepository : Could not fetch remote for master remote: [email protected]:abc/configs.git

As I mentioned earlier, this is only happening when we use SSH key to clone. The same project works fine with https clone. Is there anything that I'm missing?


Solution

  • In case anyone faces this issue in future, we were able to resolve this issue by setting refreshRate in config-server.

    You can control how often the config server will fetch updated configuration data from your Git backend by using spring.cloud.config.server.git.refreshRate. The value of this property is specified in seconds. By default the value is 0, meaning the config server will fetch updated configuration from the Git repo every time it is requested.

    By default it was set to 0. Since it was registered to consul, the consul healthcheck endpoints of the other services were overwhelming the config-server with too many requests per second which caused config server to pull the from bitbucket too many times. Once the refreshRate has been set to 5s, then the config-server started to pull the configs only per 5 seconds and it is stable now. Its been a week and the config service is working as expected without any issues with SSH key.