[pve-devel] [PATCH v2 pve-container 1/1] Correctly bail when online resize for CT is requested.
mir at datanom.net
mir at datanom.net
Sat Jun 17 23:38:54 CEST 2017
From: Michael Rasmussen <mir at datanom.net>
Signed-off-by: Michael Rasmussen <mir at datanom.net>
---
src/PVE/API2/LXC.pm | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 9cf22de..d333bea 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -1444,8 +1444,15 @@ __PACKAGE__->register_method({
PVE::Cluster::log_msg('info', $authuser, "update CT $vmid: resize --disk $disk --size $sizestr");
my $realcmd = sub {
# Note: PVE::Storage::volume_resize doesn't do anything if $running=1, so
+ my $scfg = PVE::Storage::storage_config($storage_cfg, $storeid);
# we pass 0 here (parameter only makes sense for qemu)
- PVE::Storage::volume_resize($storage_cfg, $volid, $newsize, 0);
+ if ($scfg->{type} eq 'freenas') {
+ # Since current FreeNAS API has a bug when doing online
+ # resize give us a way to bail until the bug is fixed
+ PVE::Storage::volume_resize($storage_cfg, $volid, $newsize, $running);
+ } else {
+ PVE::Storage::volume_resize($storage_cfg, $volid, $newsize, 0);
+ }
$mp->{size} = $newsize;
$conf->{$disk} = PVE::LXC::Config->print_ct_mountpoint($mp, $disk eq 'rootfs');
@@ -1478,18 +1485,17 @@ __PACKAGE__->register_method({
} else {
# Some storage backends only exposes disks when VM is running
# and e2fsck and resize2fs requires access to the disk to work
- my $scfg = PVE::Storage::storage_config($storage_cfg, $storeid);
- if ($scfg->{type} eq 'freenas') {
- PVE::Storage::activate_volumes($storage_cfg, [$volid]);
- }
+ if ($scfg->{type} eq 'freenas') {
+ PVE::Storage::activate_volumes($storage_cfg, [$volid]);
+ }
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 $@;
- if ($scfg->{type} eq 'freenas') {
- PVE::Storage::deactivate_volumes($storage_cfg, [$volid]);
- }
+ if ($scfg->{type} eq 'freenas') {
+ PVE::Storage::deactivate_volumes($storage_cfg, [$volid]);
+ }
}
}
};
--
2.11.0
----
This mail was virus scanned and spam checked before delivery.
This mail is also DKIM signed. See header dkim-signature.
More information about the pve-devel
mailing list