spring-cloud-config icon indicating copy to clipboard operation
spring-cloud-config copied to clipboard

Benign java.io.IOException from JGit on startup

Open seanmmills opened this issue 4 years ago • 8 comments

Upgrading our Spring Cloud Config server from Spring Cloud 2020.0.3 to 2021.0.0 caused a seemingly benign error reported in the logs when deploying to kubernetes.

2022-01-03 20:04:02,892 [tributeWriter-2] ERROR org.eclipse.jgit.util.FS$FileStoreAttributes.saveToConfig - Cannot save config file 'FileBasedConfig[/.config/jgit/config]'
java.io.IOException: Creating directories for /.config/jgit failed
  at org.eclipse.jgit.util.FileUtils.mkdirs(FileUtils.java:412)
  at org.eclipse.jgit.internal.storage.file.LockFile.lock(LockFile.java:138)
  at org.eclipse.jgit.storage.file.FileBasedConfig.save(FileBasedConfig.java:219)
  at org.eclipse.jgit.util.FS$FileStoreAttributes.saveToConfig(FS.java:740)
  at org.eclipse.jgit.util.FS$FileStoreAttributes.lambda$4(FS.java:426)
  at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
  at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
  at java.base/java.lang.Thread.run(Thread.java:829)

I found this stackoverflow describing the problem and solution. I can add the XDG_CONFIG_HOME environment variable, however I think it would be great if a solution was provided in SCC.

seanmmills avatar Jan 05 '22 14:01 seanmmills

Interesting, IDK what we can do about it as it appears to be something JGit is doing.

Does everything still work despite the exception?

ryanjbaxter avatar Jan 05 '22 14:01 ryanjbaxter

Having found myself in a similar situation, it would appear that everything is working as expected.

mpkorstanje avatar Jan 10 '22 17:01 mpkorstanje

Thanks @mpkorstanje. I will try and take a look at it, but it will be low priority since everything is working.

ryanjbaxter avatar Jan 10 '22 20:01 ryanjbaxter

No problem!

I don't think this a problem for Spring to solve. It's up to the OS that runs the application to set XDG_CONFIG_HOME correctly.

In my case this variable was set correctly but the filesystem was mounted as read-only and so the user dir was not writable.

I'll file an issue with JGit to more gracefully handle read-only file systems.

mpkorstanje avatar Jan 10 '22 20:01 mpkorstanje

Could you post a comment to the JGit issue here?

ryanjbaxter avatar Jan 10 '22 20:01 ryanjbaxter

It already existed:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=560555

Thomas Wolf 2021-02-08 03:14:23 EST Two possible solutions:

  1. Do provide a user with a writeable home directory inside the Docker container.
  2. Set environment variable XDG_CONFIG_HOME inside the Docker container to point to a directory where the Java process has write permissions.

Sounds like a doc fix to me.

mpkorstanje avatar Jan 10 '22 22:01 mpkorstanje

Thanks!

ryanjbaxter avatar Jan 11 '22 00:01 ryanjbaxter

We probably need to document this

ryanjbaxter avatar Jan 11 '22 17:01 ryanjbaxter