-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set runtime configuration via pgagroal-cli
#329
Labels
feature
New feature
Comments
fluca1978
added a commit
to fluca1978/pgagroal
that referenced
this issue
Mar 30, 2023
This commit introduces the `config-set` in `pgagroal-cli` to allow the user to ask the pooler to change a configuration setting. As a simple usage example: pgagroal-cli config-set log_level debug The idea is to write over the communication socket the parameter name and the parameter value, so that the system can understand what has to do. In order to achieve the capability to dynamically set a single parameter, a new utility function named 'pgagroal_appy_main_configuration' has been created. Such function is now the backbone of the configuration reading process. Other internal functions have been added to easily manage the dynamic changes of pieces of structures, e.g., `struct hba` and alike. The code that loads the initial configuration out of the configuration files has been refactored in order to use these new utility functions so to keep the whole system coherent. When a request to dynamically change a single parameter arrives, the system creates a clone of the currently running configuration, than try to apply on such a clone the new setting, and in the case of success, swaps the cloned configuration with the currently running one, so that the currently running one becomes the (changed) cloned. In the case of failure, e.g., if the configuration change cannot be applied because it requires a restart, the cloned configuration is destroyed and the system keeps running with the previous one. The answer of a `config-set` command is a `config-get` for the same setting, that is the system sends over the communication socket the value of the setting requested to be changed. If the final value has changed, the `pgagroal-cli` will receive the new value, otherwise if the old value is kept, the old value will be sent. This allows for automation of `pgagroal-cli config-set` usage, so that it becomes easy to test back when a parameter have been applied. The `pgagroal-cli` is responsible to understand if the change did take effect, so it does compare the sent value with the received answer, and if they are the same it assumes there was an error. In case of failure, a return error code is returned, otherwise zero on success. If the `pgagroal-cli` is used with the verbose flag, the ending result will print out the status of the command and the value of the setting as done by `config-get`. This commit also changed some management debug levels to `debug` consistently between `config-get` and `config-set` implementations. Documentation updated. Shell completions updated. Close agroal#329
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related to #328 :
pgagroal-cli
should provide a capability to set some run-time configuration parameters while the system is running.I imagine a command line like the following one:
The workflow should be pretty much the following one:
In the case the parameter cannot be changed on the fly, at step 2, then step 3 will report back the current setting, otherwise the new setting.
I see the need for refactoring of the function
pgagroal_read_configuration
https://github.com/agroal/pgagroal/blob/master/src/libpgagroal/configuration.c#L169 because this time the configuration does not arrive from a file, rather from a single setting, so the bits that parse a single argument (e.g., https://github.com/agroal/pgagroal/blob/master/src/libpgagroal/configuration.c#L363) should be indepdentt and shared among a file based configuration and a dynamic one.Moreover, not all parameters can be changed at runtime without a restart. My proposal is to use a similar approach at that of a
reload
action:pgagroal_transfer_configuration
(after validation steps).This means that also
pgagrla_reload
function https://github.com/agroal/pgagroal/blob/master/src/libpgagroal/configuration.c#L1814 requires refactoring to handle not only a reload driven by a file, but also driven by a single change in the parameters.The text was updated successfully, but these errors were encountered: