... | ... | @@ -215,9 +215,13 @@ The current configuration for a daemon will still be stored in the `kea_daemon` |
|
|
|
|
|
The `reverse_commands` value is only set when a user applies a configuration change using commands exposed by the hook libraries (e.g., `subnet_cmds`). In this case, the CM can store one or more commands reverting to this revision. In this case, the revision will contain both the entire configuration and the commands reverting to it from the later revision. To revert to this configuration from the later one, the CM may first try using the reverse commands. If it fails or is not feasible, it should fall back to the stored configuration and the `config-set` command instead.
|
|
|
|
|
|
The following picture shows the new `kea_config_revision` table, the updated `kea_daemon` table, and the `system_user` table now referenced from the `kea_daemon` table.
|
|
|
We have a requirement that a user can schedule several configuration updates executed at the specified time. A new table, `scheduled_config_update`, will hold a list of such updates indexed by the scheduled execution time. The CM will use this information to run the configuration updates at the specified time. The table is common for all application types monitored by Stork, and individual entries may contain multiple updates for several daemons.
|
|
|
|
|
|
![kea_config_revision](uploads/cf6c6f2b0a90d4151f1ccb2aa58f1581/kea_config_revision.png)
|
|
|
The `recipe` column contains the information in the CM's proprietary format required to run the updates. It has a JSON format, but the actual contents are not presented in this design.
|
|
|
|
|
|
The following picture shows the new `kea_config_revision` table, the updated `kea_daemon` table, `scheduled_config_update` and the `system_user` table now referenced from the `kea_daemon` and `scheduled_config_update` tables.
|
|
|
|
|
|
![kea_config_revision](uploads/ae88470451bbde92f127a95b1709a196/kea_config_revision.png)
|
|
|
|
|
|
Here is the corresponding SQL migration (including functions, triggers, etc.):
|
|
|
|
... | ... | @@ -263,11 +267,25 @@ $function$; |
|
|
CREATE TRIGGER trigger_create_kea_config_revision
|
|
|
AFTER UPDATE ON kea_daemon
|
|
|
FOR EACH ROW EXECUTE FUNCTION create_kea_config_revision();
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS scheduled_config_update (
|
|
|
id BIGSERIAL NOT NULL PRIMARY KEY,
|
|
|
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT timezone('utc'::text, now()) NOT NULL,
|
|
|
deadline_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
|
|
|
user_id BIGINT NOT NULL,
|
|
|
recipe JSONB NOT NULL,
|
|
|
CONSTRAINT scheduled_config_update_user FOREIGN KEY (user_id)
|
|
|
REFERENCES system_user(id)
|
|
|
ON UPDATE CASCADE
|
|
|
ON DELETE CASCADE
|
|
|
);
|
|
|
CREATE INDEX scheduled_config_update_deadline_idx ON scheduled_config_update USING btree (deadline_at);
|
|
|
```
|
|
|
|
|
|
Reverse migration:
|
|
|
|
|
|
```sql
|
|
|
DROP TABLE IF EXISTS scheduled_config_update;
|
|
|
DROP TRIGGER IF EXISTS trigger_create_kea_config_revision ON kea_daemon;
|
|
|
DROP FUNCTION IF EXISTS create_kea_config_revision;
|
|
|
DROP TABLE IF EXISTS kea_config_revision;
|
... | ... | |