[lxc-devel] [lxd/master] Allow local direct /internal access during startup
stgraber on Github
lxc-bot at linuxcontainers.org
Tue Oct 8 05:18:42 UTC 2019
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/20191007/92c75bb5/attachment.bin>
-------------- next part --------------
From 5221d43df530131f2c6e06369cdda8122f10eee1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 8 Oct 2019 00:49:37 -0400
Subject: [PATCH 1/3] lxd/main_migratedumpsuccess: Use fast connection
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>
---
lxd/main_migratedumpsuccess.go | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lxd/main_migratedumpsuccess.go b/lxd/main_migratedumpsuccess.go
index e3f60c2ce3..de87f4b3be 100644
--- a/lxd/main_migratedumpsuccess.go
+++ b/lxd/main_migratedumpsuccess.go
@@ -48,7 +48,10 @@ func (c *cmdMigratedumpsuccess) Run(cmd *cobra.Command, args []string) error {
return fmt.Errorf("This must be run as root")
}
- d, err := lxd.ConnectLXDUnix("", nil)
+ lxdArgs := lxd.ConnectionArgs{
+ SkipGetServer: true,
+ }
+ d, err := lxd.ConnectLXDUnix("", &lxdArgs)
if err != nil {
return err
}
From d64888338f82547220f3b9524d0968600cf1fbe7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 8 Oct 2019 00:49:47 -0400
Subject: [PATCH 2/3] lxd/main_sql: Use fast connection
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>
---
lxd/main_sql.go | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lxd/main_sql.go b/lxd/main_sql.go
index 9e6a759ff4..a6ee638a5a 100644
--- a/lxd/main_sql.go
+++ b/lxd/main_sql.go
@@ -87,7 +87,10 @@ func (c *cmdSql) Run(cmd *cobra.Command, args []string) error {
}
// Connect to LXD
- d, err := lxd.ConnectLXDUnix("", nil)
+ lxdArgs := lxd.ConnectionArgs{
+ SkipGetServer: true,
+ }
+ d, err := lxd.ConnectLXDUnix("", &lxdArgs)
if err != nil {
return err
}
From 68da729c3ae989616db1751d2adeacceb27a9de1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 8 Oct 2019 00:54:56 -0400
Subject: [PATCH 3/3] lxd/daemon: Allow internal queries during startup
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>
---
lxd/daemon.go | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/lxd/daemon.go b/lxd/daemon.go
index ba9852273c..dcc70122b3 100644
--- a/lxd/daemon.go
+++ b/lxd/daemon.go
@@ -367,14 +367,16 @@ func (d *Daemon) createCmd(restAPI *mux.Router, version string, c APIEndpoint) {
route := restAPI.HandleFunc(uri, func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
- // Block public API requests until we're done with basic
- // initialization tasks, such setting up the cluster database.
- select {
- case <-d.setupChan:
- default:
- response := response.Unavailable(fmt.Errorf("LXD daemon setup in progress"))
- response.Render(w)
- return
+ if !(r.RemoteAddr == "@" && version == "internal") {
+ // Block public API requests until we're done with basic
+ // initialization tasks, such setting up the cluster database.
+ select {
+ case <-d.setupChan:
+ default:
+ response := response.Unavailable(fmt.Errorf("LXD daemon setup in progress"))
+ response.Render(w)
+ return
+ }
}
// Authentication
More information about the lxc-devel
mailing list