[lxc-devel] [lxd/master] More graceful shutdown fixes
stgraber on Github
lxc-bot at linuxcontainers.org
Thu Oct 8 17:07:15 UTC 2020
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/20201008/5d2e2e1b/attachment.bin>
-------------- next part --------------
From f5d8caf7988e3d6e6fd0a772540d696c92e2bc7d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 8 Oct 2020 11:18:34 -0400
Subject: [PATCH 1/2] lxd/operations: Fix timeout
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/operations.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/operations.go b/lxd/operations.go
index aa982b7034..e5d934c9ed 100644
--- a/lxd/operations.go
+++ b/lxd/operations.go
@@ -97,7 +97,7 @@ func waitForOperations(s *state.State, chCancel chan struct{}) {
if execConsoleOps > 0 {
logger.Info("Timeout reached, continuing with shutdown")
}
-
+ return
case <-logTick:
// Print log message every minute.
logger.Infof("Waiting for %d operation(s) to finish", runningOps)
From 3a6bf54b1ac3dc9156f267a7694aa4eb3f9b896c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 8 Oct 2020 13:06:49 -0400
Subject: [PATCH 2/2] lxd/daemon: Allow more operations during shutdown
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 | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/lxd/daemon.go b/lxd/daemon.go
index a422ef8b20..e04cafc397 100644
--- a/lxd/daemon.go
+++ b/lxd/daemon.go
@@ -461,7 +461,25 @@ func (d *Daemon) createCmd(restAPI *mux.Router, version string, c APIEndpoint) {
// - internal calls, e.g. lxd shutdown
// - events endpoint as this is accessed when running `lxd shutdown`
// - /1.0 endpoint
- if version != "internal" && c.Path != "events" && c.Path != "" && d.ctx.Err() == context.Canceled {
+ // - /1.0/operations endpoints
+ // - GET queries
+ allowedDuringShutdown := func() bool {
+ if version == "internal" {
+ return true
+ }
+
+ if c.Path == "" || c.Path == "events" || c.Path == "operations" || strings.HasPrefix(c.Path, "operations/") {
+ return true
+ }
+
+ if r.Method == "GET" {
+ return true
+ }
+
+ return false
+ }
+
+ if d.ctx.Err() == context.Canceled && !allowedDuringShutdown() {
response.Unavailable(fmt.Errorf("LXD is shutting down")).Render(w)
return
}
More information about the lxc-devel
mailing list