[lxc-devel] [lxd/master] Better errors and docs about node-specific config keys of pools and networks

freeekanayaka on Github lxc-bot at linuxcontainers.org
Mon May 28 09:26:30 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 361 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180528/bf300e77/attachment.bin>
-------------- next part --------------
From 5f0c3674a62c94482d3b9ae78e805bb08c61b127 Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at canonical.com>
Date: Mon, 28 May 2018 09:25:12 +0000
Subject: [PATCH] Improve error messages and docs about node-specific config
 keys for pools and networks

Signed-off-by: Free Ekanayaka <free.ekanayaka at canonical.com>
---
 doc/clustering.md    | 42 +++++++++++++++++++++++++++++++++++++++++-
 lxd/networks.go      |  3 ++-
 lxd/storage_pools.go |  3 ++-
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/doc/clustering.md b/doc/clustering.md
index ef1e46703..bc353d133 100644
--- a/doc/clustering.md
+++ b/doc/clustering.md
@@ -221,7 +221,7 @@ lxc pull file xenial/etc/hosts .
 
 As mentioned above, all nodes must have identical storage pools. The
 only difference between pools on different nodes might be their
-`source` and `size` configuration keys.
+`source`, `size` or `zfs.pool_name` configuration keys.
 
 To create a new storage pool, you first have to define it across all
 nodes, for example:
@@ -231,6 +231,9 @@ lxc storage create --target node1 data zfs source=/dev/vdb1
 lxc storage create --target node2 data zfs source=/dev/vdc1
 ```
 
+Note that when defining a new storage pool on a node the only valid
+configuration keys you can pass are the node-specific ones mentioned above.
+
 At this point the pool hasn't been actually created yet, but just
 defined (it's state is marked as Pending if you run `lxc storage list`).
 
@@ -244,6 +247,9 @@ and the storage will be instantiated on all nodes. If you didn't
 define it on a particular node, or a node is down, an error will be
 returned.
 
+You can pass to this final ``storage create`` command any configuration key
+which is not node-specific (see above).
+
 ## Storage volumes
 
 Each volume lives on a specific node. The `lxc storage volume list`
@@ -269,3 +275,37 @@ lxc storage volume create default web --target node2
 lxc storage volume show default web --target node1
 lxc storage volume show default web --target node2
 ```
+
+## Networks
+
+As mentioned above, all nodes must have identical networks defined. The only
+difference between networks on different nodes might be their
+`bridge.external_interfaces` optional configuration key (see also documentation
+about [network configuration](networks.md)).
+
+To create a new network, you first have to define it across all
+nodes, for example:
+
+```bash
+lxc network create --target node1 my-network
+lxc network create --target node2 my-network
+```
+
+Note that when defining a new network on a node the only valid configuration
+key you can pass is `bridge.external_interfaces`, as mentioned above.
+
+At this point the network hasn't been actually created yet, but just
+defined (it's state is marked as Pending if you run `lxc network list`).
+
+Now run:
+
+```bash
+lxc network create my-network
+```
+
+and the network will be instantiated on all nodes. If you didn't
+define it on a particular node, or a node is down, an error will be
+returned.
+
+You can pass to this final ``network create`` command any configuration key
+which is not node-specific (see above).
diff --git a/lxd/networks.go b/lxd/networks.go
index 19c6d1b25..6021605c3 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -115,7 +115,8 @@ func networksPost(d *Daemon, r *http.Request) Response {
 		// value for the storage config is 'bridge.external_interfaces'.
 		for key := range req.Config {
 			if !shared.StringInSlice(key, db.NetworkNodeConfigKeys) {
-				return SmartError(fmt.Errorf("Invalid config key '%s'", key))
+				return SmartError(
+					fmt.Errorf("Config key '%s' may not be used as node-specific key", key))
 			}
 		}
 		err = d.cluster.Transaction(func(tx *db.ClusterTx) error {
diff --git a/lxd/storage_pools.go b/lxd/storage_pools.go
index 621bf06e7..227744d98 100644
--- a/lxd/storage_pools.go
+++ b/lxd/storage_pools.go
@@ -136,7 +136,8 @@ func storagePoolsPost(d *Daemon, r *http.Request) Response {
 	// storage config are the ones in StoragePoolNodeConfigKeys.
 	for key := range req.Config {
 		if !shared.StringInSlice(key, db.StoragePoolNodeConfigKeys) {
-			return SmartError(fmt.Errorf("Invalid config key '%s'", key))
+			return SmartError(
+				fmt.Errorf("Config key '%s' may not be used as node-specific key", key))
 		}
 	}
 


More information about the lxc-devel mailing list