The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8039
This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.
=== Description (from pull-request) ===
Recreated all changes but re-forked to fix some git issues we caused by forgetting to include sign-offs in all of our commits.
Signed-off-by: Kyle Colburn
From a6c990e86186454ebbce28dcf7c792893ed12cb2 Mon Sep 17 00:00:00 2001
From: Kyle Colburn
Date: Thu, 15 Oct 2020 21:22:58 -0500
Subject: [PATCH] Remade all typo fix changes and reapplied patch.
Signed-off-by: Kyle Colburn
---
lxd/db/storage_pools.go | 2 +-
lxd/patches.go | 56 +
2 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/lxd/db/storage_pools.go b/lxd/db/storage_pools.go
index e27a3d1e12..76d12693d1 100644
--- a/lxd/db/storage_pools.go
+++ b/lxd/db/storage_pools.go
@@ -885,7 +885,7 @@ var StoragePoolNodeConfigKeys = []string{
"source",
"volatile.initial_source",
"zfs.pool_name",
- "lvm.thinpool",
+ "lvm.thinpool_name",
"lvm.vg_name",
}
diff --git a/lxd/patches.go b/lxd/patches.go
index d60ad8e1b6..6a37e49214 100644
--- a/lxd/patches.go
+++ b/lxd/patches.go
@@ -102,6 +102,7 @@ var patches = []patch{
{name: "network_clear_bridge_volatile_hwaddr", stage:
patchPostDaemonStorage, run: patchNetworkCearBridgeVolatileHwaddr},
{name: "move_backups_instances", stage: patchPostDaemonStorage, run:
patchMoveBackupsInstances},
{name: "network_ovn_enable_nat", stage: patchPostDaemonStorage, run:
patchNetworkOVNEnableNAT},
+ {name: "thinpool_typo_fix", stage: patchPostDaemonStorage, run:
patchThinpoolTypoFix},
}
type patch struct {
@@ -166,6 +167,61 @@ func patchesApply(d *Daemon, stage patchStage) error {
// Patches begin here
+// renames any config incorrectly set config file entries due to the
lvm.thinpool_name typo
+func patchThinpoolTypoFix(name string, d *Daemon) error {
+ tx, err = d.cluster.Transaction(func(tx *db.ClusterTx) error {
+ // Fetch the IDs of all existing nodes.
+ nodeIDs, err := query.SelectIntegers(tx, "SELECT id FROM nodes")
+ if err != nil {
+ return errors.Wrap(err, "Failed to get IDs of current
nodes")
+ }
+
+ // Fetch the IDs of all existing lvm pools.
+ poolIDs, err := query.SelectIntegers(tx, "SELECT id FROM
storage_pools WHERE driver='lvm'")
+ if err != nil {
+ return errors.Wrap(err, "Failed to get IDs of current
lvm pools")
+ }
+
+ for _, poolID := range poolIDs {
+ // Fetch the config for this lvm pool and check if it
has the
+ // lvn.thinpool_name key.
+ config, err := query.SelectConfig(
+ tx, "storage_pools_config",
"storage_pool_id=?", poolID)
+ if err != nil {
+ return errors.Wrap(err, "Failed a fetch of lvm
pool config")
+ }
+
+ value, ok := config["lvm.thinpool"]
+ if !ok {
+ continue
+ }
+
+ // Delete the current key
+ _, err = tx.Exec(`
+ DELETE FROM storage_pools_config WHERE
key='lvm.thinpool' AND storage_pool_id=?`, poolID)
+ if err != nil {
+ return errors.Wrapf(err, "Failed to delete %s
config", key)
+ }
+
+ // Add the config entry for each node
+ for _, nodeID := range nodeIDs {
+ _, err := tx.Exec(`
+ INSERT INTO
storage_pools_config(storage_pool_id, node_id, key, value)
+ VALUES(?, ?, 'lvm.thinpool_name', ?)
+ `, poolID, curNodeID, value)
+ if err != nil {
+ return errors.Wrapf(err, "Failed to
create %s node config", key)
+ }
+ }
+ }
+ })
+ if err != nil {
+ return errors.Wrap(err, "Failed to commit transaction")
+ }
+
+ return err
+}
+
// patchNetworkOVNEnableNAT adds "ipv4.nat" and "ipv6.nat" keys set to "true"
to OVN networks if not present.
// This is to ensure existing networks retain the old behaviour of always
having NAT enabled as we introduce
// the new NAT settings which default to disabled if not specified.
___
lxc-d