[pve-devel] [PATCH v2 container 1/4] Fix #791: warn when resize2fs fails

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Feb 8 08:48:25 CET 2016


At this point the underlying file has already been
successfully resized which means it makes sense to refelct
that change in the config, but the guest will not see the
effect of it, however, a subsequent resize command will
further increase the size relative to the 'new' size, so
after such an error the best option is to manually deal with
the error and perform the necessary resize steps.
---
 Changes:
    fix warning condition and added it to each eval block separately
 src/PVE/API2/LXC.pm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 09b71c8..7db8488 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1317,10 +1317,16 @@ __PACKAGE__->register_method({
 			# interestingly we don't need to e2fsck on mounted systems...
 			my $quoted = PVE::Tools::shellquote($path);
 			my $cmd = "mount --make-rprivate / && mount $quoted /tmp && resize2fs $quoted";
-			PVE::Tools::run_command(['unshare', '-m', '--', 'sh', '-c', $cmd]);
+			eval {
+			    PVE::Tools::run_command(['unshare', '-m', '--', 'sh', '-c', $cmd]);
+			};
+			warn "Failed to update the container's filesystem: $@\n" if $@;
 		    } else {
-			PVE::Tools::run_command(['e2fsck', '-f', '-y', $path]);
-			PVE::Tools::run_command(['resize2fs', $path]);
+			eval {
+			    PVE::Tools::run_command(['e2fsck', '-f', '-y', $path]);
+			    PVE::Tools::run_command(['resize2fs', $path]);
+			};
+			warn "Failed to update the container's filesystem: $@\n" if $@;
 		    }
 		}
 	    };
-- 
2.1.4





More information about the pve-devel mailing list