[lxc-devel] [lxd/master] LXD console fixes

stgraber on Github lxc-bot at linuxcontainers.org
Fri Jan 5 20:25:12 UTC 2018


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/20180105/9e15c396/attachment.bin>
-------------- next part --------------
From a53fe55976f10bcaee9c279542b91400b27cf93e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 5 Jan 2018 14:58:22 -0500
Subject: [PATCH 1/2] console: Don't prevent setting lxc.console.logfile
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The preferred option is certainly for users to use the console
ringbuffer and console API, but if they wish to use the old school
logfile, that's not going to break LXD.

This also unbreaks existing users that set this key and anyone who's not
running liblxc from git.

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/container_lxc.go | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index efe317fbc..e4557ca1c 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -210,12 +210,8 @@ func lxcValidConfig(rawLxc string) error {
 			return fmt.Errorf("Setting lxc.logfile is not allowed")
 		}
 
-		if key == "lxc.console.logfile" {
-			return fmt.Errorf("Setting lxc.console.logfile is not allowed")
-		}
-
 		if key == "lxc.syslog" || key == "lxc.log.syslog" {
-			return fmt.Errorf("Setting lxc.syslog is not allowed")
+			return fmt.Errorf("Setting lxc.log.syslog is not allowed")
 		}
 
 		if key == "lxc.ephemeral" {

From c160898722dd9293690f5cfb4da50d981218aaa4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 5 Jan 2018 15:00:02 -0500
Subject: [PATCH 2/2] console: Fix version check in log API
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/container_console.go | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lxd/container_console.go b/lxd/container_console.go
index 07ef18b4f..3f1216dfb 100644
--- a/lxd/container_console.go
+++ b/lxd/container_console.go
@@ -320,16 +320,16 @@ func containerConsolePost(d *Daemon, r *http.Request) Response {
 }
 
 func containerConsoleLogGet(d *Daemon, r *http.Request) Response {
+	if !util.RuntimeLiblxcVersionAtLeast(3, 0, 0) {
+		return BadRequest(fmt.Errorf("Querying the console buffer requires liblxc >= 3.0"))
+	}
+
 	name := mux.Vars(r)["name"]
 	c, err := containerLoadByName(d.State(), name)
 	if err != nil {
 		return SmartError(err)
 	}
 
-	if util.RuntimeLiblxcVersionAtLeast(3, 0, 0) {
-		return BadRequest(fmt.Errorf("Querying the console buffer requires liblxc >= 3.0"))
-	}
-
 	ent := fileResponseEntry{}
 	if !c.IsRunning() {
 		// Hand back the contents of the console ringbuffer logfile.
@@ -367,16 +367,16 @@ func containerConsoleLogGet(d *Daemon, r *http.Request) Response {
 }
 
 func containerConsoleLogDelete(d *Daemon, r *http.Request) Response {
+	if !util.RuntimeLiblxcVersionAtLeast(3, 0, 0) {
+		return BadRequest(fmt.Errorf("Clearing the console buffer requires liblxc >= 3.0"))
+	}
+
 	name := mux.Vars(r)["name"]
 	c, err := containerLoadByName(d.State(), name)
 	if err != nil {
 		return SmartError(err)
 	}
 
-	if util.RuntimeLiblxcVersionAtLeast(3, 0, 0) {
-		return BadRequest(fmt.Errorf("Clearing the console buffer requires liblxc >= 3.0"))
-	}
-
 	truncateConsoleLogFile := func(path string) error {
 		// Check that this is a regular file. We don't want to try and unlink
 		// /dev/stderr or /dev/null or something.


More information about the lxc-devel mailing list