The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7445

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 813785f1204f85fcedfb6123fd8a444bd26f6b5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 26 May 2020 16:19:16 -0400
Subject: [PATCH 1/4] shared/subprocess: Ensure monitor routine exits
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 shared/subprocess/proc.go | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/shared/subprocess/proc.go b/shared/subprocess/proc.go
index 06157e6db0..bd490d428d 100644
--- a/shared/subprocess/proc.go
+++ b/shared/subprocess/proc.go
@@ -1,6 +1,7 @@
 package subprocess
 
 import (
+       "fmt"
        "io/ioutil"
        "os"
        "os/exec"
@@ -13,9 +14,11 @@ import (
 
 // Process struct. Has ability to set runtime arguments
 type Process struct {
-       exitCode int64         `yaml:"-"`
-       exitErr  error         `yaml:"-"`
-       chExit   chan struct{} `yaml:"-"`
+       exitCode int64 `yaml:"-"`
+       exitErr  error `yaml:"-"`
+
+       chExit     chan struct{} `yaml:"-"`
+       hasMonitor bool          `yaml:"-"`
 
        Name   string   `yaml:"name"`
        Args   []string `yaml:"args,flow"`
@@ -48,6 +51,10 @@ func (p *Process) Stop() error {
                }
        }
 
+       if p.hasMonitor {
+               <-p.chExit
+       }
+
        // Check if either the existence check or the kill resulted in an 
already finished error.
        if strings.Contains(err.Error(), "process already finished") {
                return ErrNotRunning
@@ -92,6 +99,7 @@ func (p *Process) Start() error {
 
        p.Pid = int64(cmd.Process.Pid)
        p.chExit = make(chan struct{})
+       p.hasMonitor = true
 
        // Spawn a goroutine waiting for it to exit.
        go func() {
@@ -177,6 +185,10 @@ func (p *Process) Signal(signal int64) error {
 
 // Wait will wait for the given process object exit code
 func (p *Process) Wait() (int64, error) {
+       if !p.hasMonitor {
+               return -1, fmt.Errorf("Unable to wait on process we didn't 
spawn")
+       }
+
        <-p.chExit
        return p.exitCode, p.exitErr
 }

From f369612e66efe1dd002edec3fc4ee17503125b8f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 26 May 2020 16:34:58 -0400
Subject: [PATCH 2/4] shared/subprocess: Properly reset state
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 shared/subprocess/proc.go | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/shared/subprocess/proc.go b/shared/subprocess/proc.go
index bd490d428d..b5caf41068 100644
--- a/shared/subprocess/proc.go
+++ b/shared/subprocess/proc.go
@@ -98,10 +98,14 @@ func (p *Process) Start() error {
        }
 
        p.Pid = int64(cmd.Process.Pid)
-       p.chExit = make(chan struct{})
-       p.hasMonitor = true
+
+       // Reset exitCode/exitErr
+       p.exitCode = 0
+       p.exitErr = nil
 
        // Spawn a goroutine waiting for it to exit.
+       p.chExit = make(chan struct{})
+       p.hasMonitor = true
        go func() {
                procstate, err := cmd.Process.Wait()
                if err != nil {

From f861c17d172ba615ac3933d70a1f59c41841c50b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 26 May 2020 16:43:36 -0400
Subject: [PATCH 3/4] tests: Fix btrfs test on non-shiftfs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 test/suites/storage_driver_btrfs.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/test/suites/storage_driver_btrfs.sh 
b/test/suites/storage_driver_btrfs.sh
index b5c483eb5a..85c3ac44bc 100644
--- a/test/suites/storage_driver_btrfs.sh
+++ b/test/suites/storage_driver_btrfs.sh
@@ -33,9 +33,13 @@ test_storage_driver_btrfs() {
     lxc snapshot c1pool1 snap0
 
     # Create some subvolumes and populate with test files. Mark the intermedia 
subvolume as read only.
+    OWNER="$(stat -c %u:%g "${LXD_DIR}/storage-pools/lxdtest-$(basename 
"${LXD_DIR}")-pool1/containers/c1pool1/rootfs")"
     btrfs subvolume create "${LXD_DIR}/storage-pools/lxdtest-$(basename 
"${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a"
+    chown "${OWNER}" "${LXD_DIR}/storage-pools/lxdtest-$(basename 
"${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a"
     btrfs subvolume create "${LXD_DIR}/storage-pools/lxdtest-$(basename 
"${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b"
+    chown "${OWNER}" "${LXD_DIR}/storage-pools/lxdtest-$(basename 
"${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b"
     btrfs subvolume create "${LXD_DIR}/storage-pools/lxdtest-$(basename 
"${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b/c"
+    chown "${OWNER}" "${LXD_DIR}/storage-pools/lxdtest-$(basename 
"${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b/c"
     lxc exec c1pool1 -- touch /a/a1.txt
     lxc exec c1pool1 -- touch /a/b/b1.txt
     lxc exec c1pool1 -- touch /a/b/c/c1.txt

From b99470f18932fc77df1b09053c9c96bc4c5e793a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 26 May 2020 17:00:50 -0400
Subject: [PATCH 4/4] tests: Old kernels don't let you rmdir btrfs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 test/suites/storage_driver_btrfs.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/suites/storage_driver_btrfs.sh 
b/test/suites/storage_driver_btrfs.sh
index 85c3ac44bc..31fa6e63e9 100644
--- a/test/suites/storage_driver_btrfs.sh
+++ b/test/suites/storage_driver_btrfs.sh
@@ -101,7 +101,9 @@ test_storage_driver_btrfs() {
 
     # Delete /a in c1pool1 and restore snap 1.
     btrfs property set "${LXD_DIR}/storage-pools/lxdtest-$(basename 
"${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b" ro false
-    lxc exec c1pool1 -- rm -rf /a
+    btrfs subvol delete "${LXD_DIR}/storage-pools/lxdtest-$(basename 
"${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b/c"
+    btrfs subvol delete "${LXD_DIR}/storage-pools/lxdtest-$(basename 
"${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a/b"
+    btrfs subvol delete "${LXD_DIR}/storage-pools/lxdtest-$(basename 
"${LXD_DIR}")-pool1/containers/c1pool1/rootfs/a"
     lxc restore c1pool1 snap1
     lxc exec c1pool1 -- stat /a/a1.txt
     lxc exec c1pool1 -- stat /a/b/b1.txt
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to