The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7793
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) === Fixes #7788 Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
From f25e9db704187aca1019255a74e121b21b29aa73 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Thu, 20 Aug 2020 10:13:49 +0100 Subject: [PATCH] lxd/storage/drivers/utils: Fixes shrinkFileSystem to detect e2fsck filesystem modifications Fixes #7788 Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/drivers/utils.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lxd/storage/drivers/utils.go b/lxd/storage/drivers/utils.go index 055fd73e2d..0408e2fc64 100644 --- a/lxd/storage/drivers/utils.go +++ b/lxd/storage/drivers/utils.go @@ -5,6 +5,7 @@ import ( "io" "io/ioutil" "os" + "os/exec" "path/filepath" "sort" "strings" @@ -476,8 +477,23 @@ func shrinkFileSystem(fsType string, devPath string, vol Volume, byteSize int64) return vol.UnmountTask(func(op *operations.Operation) error { output, err := shared.RunCommand("e2fsck", "-f", "-y", devPath) if err != nil { - // e2fsck provides some context to errors on stdout. - return errors.Wrapf(err, "%s", strings.TrimSpace(output)) + exitCodeFSModified := false + runErr, ok := err.(shared.RunError) + if ok { + exitError, ok := runErr.Err.(*exec.ExitError) + if ok { + if exitError.ExitCode() == 1 { + exitCodeFSModified = true + } + } + } + + // e2fsck can return non-zero exit code if it has modified the filesystem, but + // this isn't an error and we can proceed. + if !exitCodeFSModified { + // e2fsck provides some context to errors on stdout. + return errors.Wrapf(err, "%s", strings.TrimSpace(output)) + } } _, err = shared.RunCommand("resize2fs", devPath, strSize)
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel