Search code examples
giteclipsebitbucketjgitspring-cloud-config-server

Spring Cloud Config - Git Repository Errors


Spring Cloud Config Framework:

I'm trying to integrate spring cloud config in java project with backend repository git which is bitbucket. Basically, I encounter two errors more frequently on different occasions.

2020-04-11 17:08:59.265  WARN 2792 --- [           main] .c.s.e.MultipleJGitEnvironmentRepository : Could not fetch remote for master remote: https://user@bitbucket.org/workspace/config-repo.git

In the above case, it uses the cached version and tomcat/undertow server start without any problems.

2020-04-11 17:09:03.774  INFO 2792 --- [           main] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/var/folders/6m/1cgw7zvn3rsb8j5kskflhvrr0000gn/T/config-repo-2822438633438126334/api-gateway.yml
2020-04-11 17:09:03.774  INFO 2792 --- [           main] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/var/folders/6m/1cgw7zvn3rsb8j5kskflhvrr0000gn/T/config-repo-2822438633438126334/discovery-service.yml
2020-04-11 17:09:03.775  INFO 2792 --- [           main] o.s.c.c.s.e.NativeEnvironmentRepository  : Adding property source: file:/var/folders/6m/1cgw7zvn3rsb8j5kskflhvrr0000gn/T/config-repo-2822438633438126334/config-service.yml

Git Version:

git version 2.24.0

Error 1: git-upload-pack

2020-04-11 00:00:20 - WARN Error occurred cloning to base directory.

org.eclipse.jgit.api.errors.TransportException: https://<username>@bitbucket.org/<workspace>/config-repo.git: git-upload-pack not permitted on 'https://beatles89@bitbucket.org/workspace/config-repo.git/'

Starting the spring cloud config server, and I received this error randomly. After digging into this issue, I found that git-upload-pack is not supported on bitbucket. But it was reported 2 years ago here, and suggested to revert the GIT version.

Error 2: authentication not supported

org.eclipse.jgit.api.errors.TransportException: https://bitbucket.org/user/repo.git: authentication not supported

This above error I get when hit the /refresh on actuator to get the refreshed properties from remote config repository. Sometimes it work without any errors and sometimes it throws above error.

curl localhost:8060/refresh -d {} -H "Content-Type: application/json"

Actuator Refresh Command Error:

{"timestamp":"2020-04-10T16:35:41.144+0000","status":500,"error":"Internal Server Error","message":"Request processing failed; nested exception is org.springframework.cloud.config.server.environment.NoSuchRepositoryException: Cannot clone or checkout repository: https://beatles89@bitbucket.org/augmentedcloud/ac-config-repo.git","path":"/refresh"}

Note: As a side note, I have cloned the specified repository separately for testing and it worked without any authentication issues.


Solution

  • Spring Cloud Config Framework

    Spring Cloud Config framework basically provide git as the backend repository to fetch/load .properties from the remote/cache. You must provide the base directory definition with write permissions for git to clone/checkout the .properties from remote.

    spring:
      cloud:
        config:
          server:
            git:
              basedir: ${AC_CONFIG_SERVICE_GIT_BASE_DIR}
              uri: ${AC_CONFIG_SERVICE_GIT_REMOTE_URI}
              username: ${AC_CONFIG_SERVICE_GIT_REMOTE_USER}
              password: ${AC_CONFIG_SERVICE_GIT_REMOTE_PASSWORD}
              passphrase: ${AC_CONFIG_SERVICE_GIT_REMOTE_PASSPHRASE}
              skip-ssl-validation: true
              timeout: 10
    

    Note: Otherwise, on every server startup it will either complain for .properties with different errors or load the cached version of .properties from local repository. By default, basedir read from this location /var/tmp and spring cloud config framework is looking for the write permissions on parent directory which in this case /var - Hint: Safety Precautions Triggered.

    To be on safe side and don't want to ruin your OSX, defined one of your own custom location for basedir such as /Users/<....>/Documents/tmp. Because every time, git perform the lookup on remote repository for new change and if found then it will pull down the new .properties which require deletion of previous files.

    Since, I have defined the basedir not encountered any errors from the spring cloud config framework in logs.