aspnet / Configuration

[Archived] Interfaces and providers for accessing configuration files. Project moved to https://github.com/aspnet/Extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] How does reloadOnChange work in AddJsonFile

Marusyk opened this issue · comments

I have this code in Program.cs

return WebHost.CreateDefaultBuilder(args)
	.ConfigureAppConfiguration((hostingContext, config) =>
	{
		config
			.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
			.AddJsonFile(Path.Combine("configurations", "ocelot.json"), false, reloadOnChange: true)
			.AddEnvironmentVariables();
	})
	.UseStartup<Startup>();

Then I run my app in Docker container that managed by k8s.
I've created ConfigMap and in Deployment add volume to that file (ocelot.json). So, I expected when ConfigMap changes then my file ocelot.json also should change. And it does. I exec container and check that file has changed but my app doesn't see that.

Also I check sha1sum of file before and after change ConfigMap and it is different. What is the problem? Why my app doesn't see that changes?

Filesystem monitoring does not work in docker mounted volumes (yet). The JsonConfigurationProvider relies basically on FileSystemWatcher monitoring the source file. The problem is that file system watch does not work in mounted volumes as stated here.