Our config server is using Git as backend source, and we want to have an HA feature in case if the Git is not reachable, we can still use something like cache in config server so it can still serve, maybe not latest config but our client services won't crash when recreated.

Is there any suggestion in this scenario?

Comment From: ryanjbaxter

Really what you are asking is how to make your Git server highly available which is really outside the scope of Spring Cloud Config.

That said Spring Cloud Config Server will clone the repo locally and will have a local copy of the git repo after the initial fetch that is can use.

Comment From: neorclynn

I'm not quite sure how Spring Cloud Config Server cache works. I made a simple test, after the initial fetch and then I close Git server, the Config Server just couldn't serve even for the same file. Apparently its cache is not for high availability, maybe only for performance. Is there any way I can make Config Server can still serve even when its backend is unreachable? I mean only for the ones that it served before.

Comment From: ryanjbaxter

Here is what I did... * Started a local gitea server using docker * Pointed my config server at a config repo on my local gitea server * Made a request to my config server so it would clone the repo while the gitea server was up * Stopped the docker container running the gitea server * Made the same request to my config server, which returned successfully with the data

So after the initial clone the config server was using the locally clones git repo to serve configuration successfully even though the git server was not running.

If this is not what you are observing please provide a sample to reproduce what you are observing.

Comment From: neorclynn

Thank you so much.

If my understanding is correct, config server does this in 2 steps: 1. git fetch into local file 2. use local file to serve.

If the first step is failed, and the local file is already there, it proceed to step 2. So after initial clone, it will takes some time and try to git fetch, even failed, it can still return using last time clone.

If this is correct, here's my current thought. I want to store the local file into a persistent disk outside config server, and mount that disk into config server. So even the config server restarts and git is down, the last time clone is still available.

I checked my current one, the local file stores in a random name location, in my case is /tmp/config-repo-8499027853404462243. Is there any way that it can specify that to use a fixed name? And we have multiple git backend for one config server, so I wish this setting, if it exists, to be backend-level.

Comment From: neorclynn

I think I figured out, it's just param basedir which can specify the local file location. I think I can start following steps from here. Thank you so much for your help.

Comment From: ryanjbaxter

Yes you can set spring.cloud.config.server.git.basedir to accomplish that.