-
Notifications
You must be signed in to change notification settings - Fork 20
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
Dynamic Index Settings (Cameron's Proposal) #778
Comments
Migration PlanTo ensure a smooth transition to the new configuration system without introducing breaking changes, the following migration plan is proposed: Phase 1: Introduction of New Configuration Structure
Phase 2: Gradual Migration of Settings
Phase 3: Enable Dynamic Configuration Through Database
Phase 4: Deprecation and Removal of
|
Hi @da2ce7, I have some questions. 1. Difference between
|
Instance | Runtime | |
---|---|---|
Static | DB Connection String | API Socket |
Dynamic | Logging Level | Index Policy |
- What are Instance-Dynamic and Runtime-Static configurations?
From your examples, I would say:
- Instance: Configuration that involves or affects external services (out-of-process).
- Runtime: Configuration that only involves or affects internal services (in-process).
I don't know the difference between "Dynamic" and "Runtime".
2. override.toml
- Why do you need the
override.toml
? - Why doesn't the System Administrator provide the correct values in
private.toml
andpublic.toml
initially?
NOTE: We override values in index.toml
with env vars. An extra layer of overriding could be very confusing if all toml files allow overriding their values with env vars.
3. default.toml
I assume this allows to override hardcoded defaults, right?
Keep private.toml
and public.toml
in the current one, index.toml
?
I'm not sure if splitting the data using the permission is better than handling the permission in a different layer.
I assume the Service Administrator can only override the public.toml
configuration.
Pros:
- It's really clear what the System Administrator can see/edit.
- Security should be easier to implement.
Cons:
- Configuration permissions are hardcoded. For example, we can't allow the System Administrator to see or edit the "logging threshold", if we initially put it in the
private.toml
file.
4. Mandatory values
Where do we put the metadata information, such as the list of mandatory fields?
5. Versioning
Having four files instead of 1 makes it harder to keep consistency. I suppose we have to release new versions for all of them simultaneously.
6. Alternative 1: metadata.toml
Merge new files into a single one?
- We could keep the current
index.toml
- Add a new file:
metadata.toml
- Allow to override some (non private) values by Service Administrator in the database.
The metadata.toml
would contain:
[metadata]
schema_version = "2.0.0"
# List of mandatory fields
mandatory = [
"database.connect_url"
]
# List of fields that only the System Administrator can see/edit
private = [
"database.connect_url"
]
# Default values
[defaults.logging]
threshold = "info"
We can also move this info to the metadata section of the index.toml
file.
I guess the main advantage of this solution is flexibility. If we allow the system administrator to inject defautl values, these would be an extra level of indirection.
7. Alternative 2: New section in index.toml
We can also implement this proposal using the index.toml
file with new sections:
# ...
[private]
# ...
[public]
# ...
[override]
# ...
[defaults]
# ...
Putting all the info in a single file would make it easier in the future to refactor becuase we only need to change code and not the way the configration is injected. That requires changes in containers, deployments etc.
[override]
and [defaults]
sections could be inside [metadata]
.
8. More questions
- Should default values be stored in the database? I don't think so because there will be no way to be changed by the system administrator anymore.
- I assume the System Administrator is not the
root
Service administrator.
@josecelano Regarding Question One: 1. Difference between I need to update the original posts to make the table more clear. But here is a better summary of the idea I have in mind: Configuration Types
In this matrix, we can see that:
By combining these two dimensions, we get four quadrants that help us understand the different types of configurations:
|
@josecelano Regarding Question Two: 2. The
In this matrix, we can see that:
By providing a separate override mechanism, the System Administrator can ensure that dynamic values are set to a specific value, even if they are changed at runtime. This is particularly useful for security or compliance reasons, where specific values need to be enforced. The |
@josecelano Regarding Question Three: 3. default.toml The The purpose of the default.toml file is to allow the System Administrator to set their own default values, which may differ from the default values set by the application developers. This provides a way for the System Administrator to customize the application's default behavior without modifying the underlying code. By defining default values in a separate file, the System Administrator can easily manage and update the default configuration without affecting other configuration files or the application code. |
@josecelano Regarding Question Four: 4. Mandatory values The list of mandatory values is defined by the application code and is not something that can be changed through configuration files. It is the responsibility of the application to ensure that its configuration is coherent and valid. If the instance configuration is bad, the application will panic. If a proposed change to the dynamic configuration is invalid, the application will return an error. We should ensure that the application is always in a consistent and valid state, and prevent users from accidentally or intentionally configuring the application in a way that could undefined behavior. |
@josecelano Regarding Question Five: 5. Versioning To handle versioning of the configuration files, I suggest we should prefix all configuration files and environmental variables with the major version number. This will allow us to make significant changes to the configuration structure or syntax only when the major version is updated. For example, if the current major version is Minor version updates will be used to add new features by adding more fields to the existing configuration files. This way, we can introduce new configuration options without breaking existing configurations. Patches will be silent, meaning that minor bug fixes or tweaks will not require updates to the configuration files or environmental variables. Edit: I still think that the config files should have a |
I find it confusing to use "runtime" and "dynamic".
On the other hand, regarding
I would add a new one to expose services or maybe in the root endpoint. By the way, I would rename those endpoints to |
Ok, I understand now it's a way to enforce settings by the Systema Admin that is allowed to be changed dynamically by the Service Admin. I think the name Wouldn't having a list of fields that cannot be changed be easier? Then we can inform the Service Admin. We need to have it anyway; otherwise, it would be a surprise for the Service Admin to override some values without any effect. |
@josecelano Yes I'm open for renaming. I'm just trying to create words for different aspects in play... A good example is the API endpoint. The sys-admin sets a default API endpoint of But, if the sys-admin sets the API endpoint of |
I agree. even just |
On more question @da2ce7,
Can the Service Admin override public settings? Or DB settings are totally different from settings included in these four new files? I have added a proposal for relocating values in the new files. Current
|
A list of properties for a single configuration value: 1. Mutability
2. Setter Role
3. Visibility
4. Mandatory
5. Runtime Immutability Reason
6. Post-Initialization Modification
Example JSON Representation for a Configuration Value{
"name": "bind_address",
"mutability": "Immutable",
"setter_role": "SystemAdmin",
"visibility": "ServiceAdmin",
"mandatory": "Optional",
"runtime_immutability_reason": "CodeConstraint",
"post_initialization_modification": "Derived"
} Explanation with ExamplesUsing this structure, we can represent specific configuration values:
|
Hi @da2ce7 I have created a table to represent the current status for all values and properties: I've just realized not all secrets are mandatory. I guess all of them should be. I'm going to build another table with what we would like to have at the end. |
NOTES:
|
Today, in our weekly meeting, I mentioned that I would move I will wait for @da2ce7 to give it a second thought, especially for the file names. I guess the final implementation will be:
There will be some JSON schemas:
I don't know if there is a way to represent that with JSON schemas without duplicating parts of the schemas (the subsets private and public): https://json-schema.org/understanding-json-schema/structuring Maybe we need to create the schema for the |
Hi @da2ce7, since in this proposal we are going to include ALL keys in the files (unlike mine), I think this refactor is not necessary before adding the new settings I was planning to include:
I mean, we can do it before or after adding the new settings. I suggest starting to implement the new settings with the current format. In the meantime, we can refine this proposal. These features would be available earlier. The only problem is they would require the System Administrator to restart the service to change them until we implement this proposal. I don't think that's a problem because those options are options you generally don't want to change at all after starting the service. The only one that could require to change it dynamically is the one to pause registrations. NOTE: I would still make them dynamic because one of the reasons is to move the responsibility for platform customization from the System Administrator to the Service Administrator. I have created a proposal for the key names and the organization. These would be the new keys: [website.gui]
[website.gui.torrenting]
enable_torrent_download = true # It hides torrent download buttons in GUI when false
enable_magnet_links = true # It hides magnet links in GUI when false
[website.gui.torrent_view]
enable_external_links = false # It does not escape external links in the torrent description when true
show_comment = false # It hides torrent `comment` in GUI when false
show_creation_date = false # It torrent `creation date` in GUI when false
show_created_by = false # It hides torrent `created by ` in GUI when false
show_encoding = false # It hides torrent `encoding` in GUI when false
[registration]
paused = false # It only disables registration temporarily I'm using the
If you agree, I can remove the issue: From the EPI: Or move it to the end. I won't be a dependency any more. It would be done at the end. |
Related to torrust/torrust-index-gui#664
Current Situation
Torrust Index loads a read-only configuration upon startup; this configuration is static over the lifetime of the program.
Details
The Torrust Index reads its settings in TOML format from two places:
/etc/torrust/index/index.toml
, or a path overridden by theTORRUST_INDEX_CONFIG_TOML_PATH
environment variable.TORRUST_INDEX_CONFIG_TOML
.If both configurations are present, the configuration supplied by the environment variable takes precedence.
The TOML format is overridden by configuration options supplied by the
TORRUST_INDEX_CONFIG_OVERRIDE__
environment variable prefix.This merged configuration is read-only for the lifetime of a
torrust-index
instance.Configuration Types
There is a matrix of different types of configuration that the Torrust Index uses, for example:
There is also a matrix of different administration levels for the configuration:
Proposal
Split the Configuration into Four Separate Files Controlled by the System Administrator
The same settings can be supplied via environment variables, similar to the current implementation. If both a configuration file and the corresponding environment variable are present, the environment variable takes precedence.
1. Immutable-Private Configuration
/etc/torrust/index/private.toml
orTORRUST_INDEX_CONFIG_PRIVATE
This file will contain settings that are set by the system administrator and should only be known by the system administrator.
2. Immutable-Public Configuration
/etc/torrust/index/public.toml
orTORRUST_INDEX_CONFIG_PUBLIC
This file will contain settings that are set by the system administrator and may be shared with the service administrator (or more).
3. General Forced
/etc/torrust/index/forced.toml
orTORRUST_INDEX_CONFIG_FORCED
This file will contain settings that are overridden by the system administrator.
4. General Default
/etc/torrust/index/default.toml
orTORRUST_INDEX_CONFIG_DEFAULT
This file will contain default settings that are set by the system administrator.
Create an In-Database Settings File
As a record inside the database:
This record will contain a
json_utf8
formatted entry with the settings supplied by the service administrator.The following endpoints and actions will be created:
/admin/current
/admin/current
/admin/merged
/admin/default
/admin/override
The text was updated successfully, but these errors were encountered: