[lxc-devel] [lxd/master] forknet: Cleans up forknet detach error logging and output

tomponline on Github lxc-bot at linuxcontainers.org
Wed Jul 3 14:12:57 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 435 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190703/9d715f76/attachment.bin>
-------------- next part --------------
From 8115d37a71b4f697bb8d233349981ea0398326ac Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Wed, 3 Jul 2019 15:06:56 +0100
Subject: [PATCH] forknet: Cleans up forknet detach error logging and output

Also removes -f from stop command in physical nic tests as not needed.

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/container_lxc.go                          |  2 +-
 lxd/main_forknet.go                           | 13 ++++++++++++-
 test/suites/container_devices_nic_physical.sh |  2 +-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index fce12c64f8..031e74d350 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -2743,7 +2743,7 @@ func (c *containerLXC) detachInterfaceRename(netns string, ifName string, hostNa
 
 	// Process forknet detach response
 	if err != nil {
-		logger.Error("Error calling 'lxd forknet detach", log.Ctx{"container": c.name, "output": out, "pid": c.InitPID()})
+		logger.Error("Error calling 'lxd forknet detach", log.Ctx{"container": c.name, "output": out, "netns": netns, "ifName": ifName, "hostName": hostName, "pid": lxdPID})
 	}
 
 	return nil
diff --git a/lxd/main_forknet.go b/lxd/main_forknet.go
index 2c511918ba..26fc37dbdf 100644
--- a/lxd/main_forknet.go
+++ b/lxd/main_forknet.go
@@ -134,6 +134,18 @@ func (c *cmdForknet) RunDetach(cmd *cobra.Command, args []string) error {
 	ifName := args[2]
 	hostName := args[3]
 
+	if lxdPID == "" {
+		return fmt.Errorf("LXD PID argument is required")
+	}
+
+	if ifName == "" {
+		return fmt.Errorf("ifname argument is required")
+	}
+
+	if hostName == "" {
+		return fmt.Errorf("hostname argument is required")
+	}
+
 	// Remove all IP addresses from interface before moving to parent netns.
 	// This is to avoid any container address config leaking into host.
 	_, err := shared.RunCommand("ip", "address", "flush", "dev", ifName)
@@ -147,6 +159,5 @@ func (c *cmdForknet) RunDetach(cmd *cobra.Command, args []string) error {
 		return err
 	}
 
-	fmt.Println("OK")
 	return nil
 }
diff --git a/test/suites/container_devices_nic_physical.sh b/test/suites/container_devices_nic_physical.sh
index 9f632c7202..ff932ea6ba 100644
--- a/test/suites/container_devices_nic_physical.sh
+++ b/test/suites/container_devices_nic_physical.sh
@@ -38,7 +38,7 @@ test_container_devices_nic_physical() {
   fi
 
   # Stop container and check MTU is restored.
-  lxc stop -f "${ctName}"
+  lxc stop "${ctName}"
 
   # Check original MTU is restored on physical device.
   if lxc info | grep 'network_phys_macvlan_mtu: "true"' ; then


More information about the lxc-devel mailing list