data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

Support hot reloading of configuration

Open JelteF opened this issue 4 years ago • 13 comments
trafficstars

Allow specifiying something like a --watch to make the runtime watch the provided configs and reload when they change.

Relevant comment from @jarupatj in #50:

You should look at using IOptionsMonitor https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-5.0#options-interfaces

#892

### Tasks
- [ ] https://github.com/Azure/data-api-builder/pull/1981
- [ ] https://github.com/Azure/data-api-builder/issues/1969
- [ ] https://github.com/Azure/data-api-builder/issues/1869
- [ ] https://github.com/Azure/data-api-builder/issues/1968
- [ ] https://github.com/Azure/data-api-builder/issues/1967
- [ ] https://github.com/Azure/data-api-builder/issues/1966

JelteF avatar Nov 01 '21 09:11 JelteF

can this be closed with #50 merged? @JelteF

seantleonard avatar Nov 29 '21 18:11 seantleonard

I don't think this should be closed, because it is about the more user facing version of hot roloading configs. One that does not require dotnet watch but simply run the binary with a --watch flag.

However, I don't think this should be an M0 milestone. Work on dev tooling team can start just fine without this support. So I'm marking this as M1 instead now. @jarupatj please comment on this if you disagree with that for some reason.

JelteF avatar Nov 29 '21 20:11 JelteF

Solving this https://github.com/Azure/hawaii-gql/issues/189 will help here.

Aniruddh25 avatar Feb 10 '22 03:02 Aniruddh25

Should we support hot reloading at all? Once runtime is bootstrapped, should we allow modifications to it? In M1, we might expect customers to restart the docker image. For M2, we will throw away the container and use a different one from the warm pool whenever any config changes.

Moving to M2 for now so we can discuss more.

Aniruddh25 avatar Apr 16 '22 08:04 Aniruddh25

Modified this issue to cove hot reloading of the configuration file. This will clear duplicate issues, which will all be tracked here.

aaronburtle avatar Apr 03 '23 14:04 aaronburtle

Would be great to have a switch on the CLI, something like --watch that will automatically reload the configuration file (and thus re-generate the in-memory schema) whenever the file is changed. Something like https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-watch

That would greatly improve development velocity.

aaronburtle avatar Apr 03 '23 14:04 aaronburtle

In order to set the LogLevel based on the mode in the runtimeconfig we need to use a configuration provider that can reload the configuration after updating the Loglevel.

More information can be found here: https://learn.microsoft.com/en-us/dotnet/core/extensions/logging?tabs=command-line

aaronburtle avatar Apr 03 '23 14:04 aaronburtle

Moved to April, waiting on new configuration resolver.

aaronburtle avatar Apr 03 '23 14:04 aaronburtle

Form the GraphQL side you need to implement an ITypeModule ... this will manage the phase out of schemas...

Here you can see an example. https://github.com/ChilliCream/graphql-platform/blob/13349fa4af03514507ed5e3aaf9a771c696b56a6/src/HotChocolate/Fusion/src/Core/DependencyInjection/FileWatcherTypeModule.cs

The TypeModule is registered with the schema.

michaelstaib avatar Apr 03 '23 18:04 michaelstaib

hot-reload property in config?

seantleonard avatar Nov 16 '23 16:11 seantleonard

I have created a number of sub-tasks to help track the progress on Hot Reload.

Currently, we are refreshing the RuntimeConfig to match any updates that we see in the associated config file when we are in the local scenario and start the engine in developer mode.

To facilitate extending Hot Reload in the future, a refactor of the RuntimeConfigProvider is taking place

https://github.com/Azure/data-api-builder/issues/1966

as well as some changes to make hot reload work with the new multi config code

https://github.com/Azure/data-api-builder/issues/1967

Additionally, one of the key features we want support for hot reloading is reloading of the log-level, and so this property is being added to the config and we have a task to track being able to hot reload this property in both dev and production mode

https://github.com/Azure/data-api-builder/issues/1968

Additionally, there are some tasks for updating those settings which depend on the config only at startup, such as the OpenApiDoc and Auth settings

https://github.com/Azure/data-api-builder/issues/1869

https://github.com/Azure/data-api-builder/issues/1969

aaronburtle avatar Jan 12 '24 03:01 aaronburtle

Moving this + hot reload related tasks to post GA -> tracking via 1.2rc milestone.

seantleonard avatar Mar 07 '24 17:03 seantleonard

The top-level task tracking hot reload can remain in backlog as we address sub-tasks. Ideally a sprint's tracked work items should be resolvable. This task has so many pre-reqs , we need to resolve those first.

seantleonard avatar May 17 '24 00:05 seantleonard