[prev in list] [next in list] [prev in thread] [next in thread]
List: lxc-devel
Subject: [lxc-devel] [lxd/master] lxd/backup: Fixes hang in backupCreate when invalid compressio argument sup
From: tomponline on Github <lxc-bot () linuxcontainers ! org>
Date: 2020-05-28 8:23:18
Message-ID: 5ecf74f6.1c69fb81.4869.4bf9SMTPIN_ADDED_MISSING () mx ! google ! com
[Download RAW message or body]
[Attachment #2 (text/x-mailbox)]
The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7457
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) ===
Similar to 5ac84466558c0f48207f0f15807209c758fbf713
Fixes #7455
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
[Attachment #3 (text/plain)]
From e9c2af05669efd219e45d30676f2867dd2a65828 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott@canonical.com>
Date: Thu, 28 May 2020 09:21:55 +0100
Subject: [PATCH] lxd/backup: Fixes hang in backupCreate when invalid
compressio argument supplied
Similar to 5ac84466558c0f48207f0f15807209c758fbf713
Fixes #7455
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
---
lxd/backup.go | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/lxd/backup.go b/lxd/backup.go
index 2e0385964c..a938311e14 100644
--- a/lxd/backup.go
+++ b/lxd/backup.go
@@ -121,11 +121,18 @@ func backupCreate(s *state.State, args db.InstanceBackup, sourceInst instance.In
// Setup tar writer go routine, with optional compression.
tarWriterRes := make(chan error, 0)
+ var compressErr error
+
go func(resCh chan<- error) {
logger.Debug("Started backup tarball writer")
defer logger.Debug("Finished backup tarball writer")
if compress != "none" {
- err = compressFile(compress, tarPipeReader, tarFileWriter)
+ compressErr = compressFile(compress, tarPipeReader, tarFileWriter)
+
+ // If a compression error occurred, close the tarPipeWriter to end the export.
+ if compressErr != nil {
+ tarPipeWriter.Close()
+ }
} else {
_, err = io.Copy(tarFileWriter, tarPipeReader)
}
@@ -135,6 +142,13 @@ func backupCreate(s *state.State, args db.InstanceBackup, sourceInst instance.In
// Write index file.
logger.Debug("Adding backup index file")
err = backupWriteIndex(sourceInst, pool, b.OptimizedStorage(), !b.InstanceOnly(), tarWriter)
+
+ // Check compression errors.
+ if compressErr != nil {
+ return compressErr
+ }
+
+ // Check backupWriteIndex for errors.
if err != nil {
return errors.Wrapf(err, "Error writing backup index file")
}
[Attachment #4 (text/plain)]
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic