Skip to content

Commit 2db7de2

Browse files
committed
spec: extensible config management by tedge-agent
1 parent fb62e85 commit 2db7de2

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

design/decisions/0008-extensible-config-management.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,94 @@ like the pre-update or post-update actions, leaving the rest of the behavior unc
5757
but the table names with the type prefix (e.g: `[docker.include]` and `[docker.exclude]`) must be used in those as well.
5858
- When new software is installed, their corresponding `include/exclude` entries can be appended to the main plugin config itself,
5959
or created in an independent extension file.
60+
61+
## Config management
62+
63+
### Phase 1
64+
65+
- Similar to log management, config plugins are defined under `/etc/tedge/config-plugins`.
66+
- Each plugin corresponds to their corresponding config types, unlike the log plugins where each plugin supports multiple types.
67+
- A config plugin needs to support the following sub-commands:
68+
- `info`: Used to detect if this is a valid plugin if it exits with exit code 0.
69+
The output must be the config type corresponding to this plugin.
70+
- `get <type>`: Get the existing configuration for the given type
71+
- `prepare <type>`: Perform any preparation steps like backing up existing config.
72+
Any relevant data to be passed to `rollback` or `commit` commands later (path of the backup file)
73+
must be printed to the console in json format:
74+
`{"meta": "<some-metadata>"}`
75+
- `set <type> [--url <new-config-url>] [--file <downloaded-file-path>]`: Update the existing config file
76+
- `validate <type>`: Validate if the applied configuration is successful
77+
- `rollback <type> --old-meta <json-output-from-prepare>`: Rollback the applied configuration if it failed in the `validate` phase.
78+
- `commit <type> --old-meta <json-output-from-prepare>`: Perform any post-update steps if the `validate` phase succeeded like deleting the backed up configs.
79+
- File-based config types can still be defined in the existing `tedge-config-plugin.toml` file.
80+
If a corresponding plugin script is not defined for the same type,
81+
the existing behavior of just updating the file on the fie system is maintained,
82+
without any `prepare`, `validate`, `commit` or `rollback` phases.
83+
- The `config-plugins` also has a `conf.d` sub-directory where extensions of the main config file can be created dynamically.
84+
Each extension config can have entries as follows:
85+
```
86+
[[files]]
87+
type = "collectd"
88+
path = "/etc/collectd/collectd.conf"
89+
90+
[[files]]
91+
type = "nginx"
92+
path = "/etc/nginx/nginx.conf"
93+
```
94+
- The supported config types are gathered from the main plugin config, its extension files
95+
and the names of all the plugins defined under `/etc/tedge/config-plugins`.
96+
97+
### Phase 2
98+
99+
Instead of the `exeucting` phase of `config_update` workflow doing everything in that single step,
100+
break it down into multiple smaller stages that corresponds to each plugin command/phase as well as follows:
101+
102+
```config_update.toml
103+
operation = "config_update"
104+
105+
[init]
106+
action = "proceed"
107+
on_success = "scheduled"
108+
109+
[scheduled]
110+
action = "proceed"
111+
on_success = "executing"
112+
113+
[executing]
114+
action = "builtin:config_update:executing"
115+
on_success = "download"
116+
117+
[download]
118+
action = "builtin:config_update:executing"
119+
on_success = "prepare"
120+
121+
[prepare]
122+
action = "builtin:config_update:prepare"
123+
on_success = "apply"
124+
125+
[apply]
126+
action = "builtin:config_update:apply"
127+
on_success = "validate"
128+
129+
[apply]
130+
action = "builtin:config_update:apply"
131+
on_success = "commit"
132+
on_error = "rollback"
133+
134+
[apply]
135+
action = "builtin:config_update:apply"
136+
on_success = "successful"
137+
138+
[rollback]
139+
action = "builtin:config_update:rollback"
140+
on_success = "failed"
141+
142+
[successful]
143+
action = "cleanup"
144+
145+
[failed]
146+
action = "cleanup"
147+
```
148+
149+
This helps customers override a single stage like `download` to do it their way,
150+
while still reusing the rest of the functionality as-is.

0 commit comments

Comments
 (0)