[lxc-devel] [lxd/master] DB fixes
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Feb 3 14:41:56 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170203/a0acf411/attachment.bin>
-------------- next part --------------
From 2fff59997a83c3a3811113bb3afeb9764a295762 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 3 Feb 2017 15:26:46 +0100
Subject: [PATCH 1/2] tests: Empty and validate network tables
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
test/main.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/test/main.sh b/test/main.sh
index e5a88a1..3be6132 100755
--- a/test/main.sh
+++ b/test/main.sh
@@ -235,6 +235,12 @@ kill_lxd() {
lxc image delete "${image}" --force-local || true
done
+ # Delete all networks
+ echo "==> Deleting all networks"
+ for network in $(lxc network list --force-local | grep YES | grep "^| " | cut -d' ' -f2); do
+ lxc network delete "${network}" --force-local || true
+ done
+
# Delete all profiles
echo "==> Deleting all profiles"
for profile in $(lxc profile list --force-local | tail -n+3 | grep "^| " | cut -d' ' -f2); do
@@ -283,6 +289,8 @@ kill_lxd() {
check_empty_table "${daemon_dir}/lxd.db" "containers_devices"
check_empty_table "${daemon_dir}/lxd.db" "containers_devices_config"
check_empty_table "${daemon_dir}/lxd.db" "containers_profiles"
+ check_empty_table "${daemon_dir}/lxd.db" "networks"
+ check_empty_table "${daemon_dir}/lxd.db" "networks_config"
check_empty_table "${daemon_dir}/lxd.db" "images"
check_empty_table "${daemon_dir}/lxd.db" "images_aliases"
check_empty_table "${daemon_dir}/lxd.db" "images_properties"
From 4871754b24b61171844cae89a3ce8d4594bd1fe3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 3 Feb 2017 15:41:10 +0100
Subject: [PATCH 2/2] doc: Update database.md to match current DB schema
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
doc/database.md | 63 +++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 50 insertions(+), 13 deletions(-)
diff --git a/doc/database.md b/doc/database.md
index fd7de4f..e7b4748 100644
--- a/doc/database.md
+++ b/doc/database.md
@@ -55,21 +55,25 @@ The list of tables is:
* containers\_devices\_config
* containers\_profiles
* images
- * images\_properties
* images\_aliases
+ * images\_properties
* images\_source
+ * networks
+ * networks\_config
+ * patches
* profiles
* profiles\_config
* profiles\_devices
* profiles\_devices\_config
* schema
-You'll notice that compared to the REST API, there are three main differences:
+You'll notice that compared to the REST API, there are a few differences:
1. The extra "\*\_config" tables which are there for key/value config storage.
2. The extra "images\_properties" table which is there for key/value property storage.
3. The extra "schema" table whish is used for database schema version tracking.
- 4. There is no "snapshots" table. That's because snapshots are a copy
+ 4. The extra "patches" table used for data migration and other non-schema changes on upgrades.
+ 5. There is no "snapshots" table. That's because snapshots are a copy
of a container at a given point in time, including its configuration and
on-disk state. So having snapshots in a separate table would only be needless duplication.
@@ -104,15 +108,16 @@ Index: UNIQUE ON id AND key
## containers
-Column | Type | Default | Constraint | Description
-:----- | :--- | :------ | :--------- | :----------
-id | INTEGER | SERIAL | NOT NULL | SERIAL
-name | VARCHAR(255) | - | NOT NULL | Container name
-architecture | INTEGER | - | NOT NULL | Container architecture
-type | INTEGER | 0 | NOT NULL | Container type (0 = container, 1 = container snapshot)
-ephemeral | INTEGER | 0 | NOT NULL | Whether the container is ephemeral (0 = persistent, 1 = ephemeral)
-stateful | INTEGER | 0 | NOT NULL | Whether the snapshot contains state (snapshot only)
-creation\_date | DATETIME | - | | Image creation date (user supplied, 0 = unknown)
+Column | Type | Default | Constraint | Description
+:----- | :--- | :------ | :--------- | :----------
+id | INTEGER | SERIAL | NOT NULL | SERIAL
+name | VARCHAR(255) | - | NOT NULL | Container name
+architecture | INTEGER | - | NOT NULL | Container architecture
+type | INTEGER | 0 | NOT NULL | Container type (0 = container, 1 = container snapshot)
+ephemeral | INTEGER | 0 | NOT NULL | Whether the container is ephemeral (0 = persistent, 1 = ephemeral)
+stateful | INTEGER | 0 | NOT NULL | Whether the snapshot contains state (snapshot only)
+creation\_date | DATETIME | - | | Container creation date
+last\_use\_date | DATETIME | - | | Last container action
Index: UNIQUE ON id AND name
@@ -229,13 +234,45 @@ id | INTEGER | SERIAL | NOT NULL | SERIAL
image\_id | INTEGER | - | NOT NULL | images.id FK
server | TEXT | - | NOT NULL | Server URL
protocol | INTEGER | 0 | NOT NULL | Protocol to access the remote (0 = lxd, 1 = direct, 2 = simplestreams)
-alias | VARCHAR(255) | - | NOT NULL | What remote alias to use as the source
certificate | TEXT | - | | PEM encoded certificate of the server
+alias | VARCHAR(255) | - | NOT NULL | What remote alias to use as the source
Index: UNIQUE ON id
Foreign keys: image\_id REFERENCES images(id)
+## networks
+
+Column | Type | Default | Constraint | Description
+:----- | :--- | :------ | :--------- | :----------
+id | INTEGER | SERIAL | NOT NULL | SERIAL
+name | VARCHAR(255) | - | NOT NULL | Profile name
+
+Index: UNIQUE on id AND name
+
+## networks\_config
+
+Column | Type | Default | Constraint | Description
+:----- | :--- | :------ | :--------- | :----------
+id | INTEGER | SERIAL | NOT NULL | SERIAL
+network\_id | INTEGER | - | NOT NULL | networks.id FK
+key | VARCHAR(255) | - | NOT NULL | Configuration key
+value | TEXT | - | | Configuration value (NULL for unset)
+
+Index: UNIQUE ON id AND network\_id + key
+
+Foreign keys: network\_id REFERENCES networks(id)
+
+## patches
+
+Column | Type | Default | Constraint | Description
+:----- | :--- | :------ | :--------- | :----------
+id | INTEGER | SERIAL | NOT NULL | SERIAL
+name | VARCHAR(255) | - | NOT NULL | Patch name
+applied\_at | DATETIME | - | NOT NULL | When the patch was applied
+
+Index: UNIQUE ON id AND name
+
## profiles
Column | Type | Default | Constraint | Description
More information about the lxc-devel
mailing list