The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4151
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) ===
From 8d768562defe4800e2ab674547042f9a396adc3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Mon, 8 Jan 2018 21:31:58 -0500 Subject: [PATCH 1/2] network: Serialize network creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/networks.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lxd/networks.go b/lxd/networks.go index 7e78acea2..fb7659955 100644 --- a/lxd/networks.go +++ b/lxd/networks.go @@ -11,6 +11,7 @@ import ( "os/exec" "strconv" "strings" + "sync" "github.com/gorilla/mux" log "github.com/lxc/lxd/shared/log15" @@ -24,6 +25,9 @@ import ( "github.com/lxc/lxd/shared/version" ) +// Lock to prevent concurent networks creation +var networkCreateLock sync.Mutex + // API endpoints func networksGet(d *Daemon, r *http.Request) Response { recursionStr := r.FormValue("recursion") @@ -59,6 +63,9 @@ func networksGet(d *Daemon, r *http.Request) Response { } func networksPost(d *Daemon, r *http.Request) Response { + networkCreateLock.Lock() + defer networkCreateLock.Unlock() + req := api.NetworksPost{} // Parse the request From d97262ce28a8660fdcbdd192c78a0df5f192960d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Mon, 8 Jan 2018 21:32:20 -0500 Subject: [PATCH 2/2] storage: Serialize storage pool creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #4150 Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/storage_pools.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lxd/storage_pools.go b/lxd/storage_pools.go index 6d4d80bc8..a676cdcad 100644 --- a/lxd/storage_pools.go +++ b/lxd/storage_pools.go @@ -6,6 +6,7 @@ import ( "net/http" "strconv" "strings" + "sync" "github.com/gorilla/mux" "github.com/lxc/lxd/lxd/db" @@ -14,6 +15,9 @@ import ( "github.com/lxc/lxd/shared/version" ) +// Lock to prevent concurent storage pools creation +var storagePoolCreateLock sync.Mutex + // /1.0/storage-pools // List all storage pools. func storagePoolsGet(d *Daemon, r *http.Request) Response { @@ -60,6 +64,9 @@ func storagePoolsGet(d *Daemon, r *http.Request) Response { // /1.0/storage-pools // Create a storage pool. func storagePoolsPost(d *Daemon, r *http.Request) Response { + storagePoolCreateLock.Lock() + defer storagePoolCreateLock.Unlock() + req := api.StoragePoolsPost{} // Parse the request.
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel