[pve-devel] [RFC container 1/2] fix #1147: allow marking non-volume mps as shared
Fabian Grünbichler
f.gruenbichler at proxmox.com
Mon Oct 10 13:04:35 CEST 2016
this introduces two new options for non-volume mount points,
modeled after the way we define 'shared' storages:
- boolean flag 'shared': marks a mount point as available on
other nodes (default: false)
- pve-node-list 'nodes': limits the 'shared' parameter to
specific nodes (default: no limit / all nodes)
when migrating containers with non-volume mount points,
these new properties are checked, and a migration is only
allowed if all mount points are 'shared' with the target
node.
setting these flags allows containers with non-volume mount
points to be migrated by the ha-manager as well, which was
previously not possible.
for backwards compatibility, the old "workaround" option
'-force' for 'pct migrate' still works, but displays a
warning pointing to the new options.
---
Note: the responsibility for actually setting up the sources
of such mounts correctly on all allowed nodes lies with the
user/admin - hence the warning in the description of the
'shared' property. I kept the terminology for consistency
and a lack of alternatives - if anybody has a better idea
on how to call this, don't hesitate ;)
Note: if used together with HA and a node limit, the HA
group should be setup accordingly, because currently there
are no checks in the ha-manager - it will happily migrate to
nodes where the mount is not available. If applied, I will
document this restriction until it is fixed in a future
ha-manager update.
src/PVE/API2/LXC.pm | 3 +--
src/PVE/LXC/Config.pm | 15 +++++++++++++++
src/PVE/LXC/Migrate.pm | 29 ++++++++++++++++++++++++-----
3 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 15ebb87..d0e558a 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -848,8 +848,7 @@ __PACKAGE__->register_method({
force => {
type => 'boolean',
description => "Force migration despite local bind / device" .
- " mounts. WARNING: identical bind / device mounts need to ".
- " be available on the target node.",
+ " mounts. NOTE: deprecated, use 'shared' property of mount point instead.",
optional => 1,
},
},
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 2ec643e..42cd7f6 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -245,6 +245,21 @@ my $rootfs_desc = {
description => 'Enable user quotas inside the container (not supported with zfs subvolumes)',
optional => 1,
},
+ shared => {
+ type => 'boolean',
+ description => 'Mark this non-volume mount point as available on multiple nodes (see \'nodes\')',
+ verbose_description => "Mark this non-volume mount point as available on multiple nodes (see 'nodes').\n\nWARNING: This option does not share the mount point automatically, it assumes it is shared already!",
+ optional => 1,
+ default => 0,
+ },
+ nodes => {
+ type => 'string',
+ format => 'pve-node-list',
+ format_description => 'node1[;node2;...]',
+ description => 'Limit \'shared\' parameter to these nodes (if enabled)',
+ default => 'all nodes',
+ optional => 1,
+ },
};
PVE::JSONSchema::register_standard_option('pve-ct-rootfs', {
diff --git a/src/PVE/LXC/Migrate.pm b/src/PVE/LXC/Migrate.pm
index 1c168bb..eec9c7e 100644
--- a/src/PVE/LXC/Migrate.pm
+++ b/src/PVE/LXC/Migrate.pm
@@ -46,11 +46,31 @@ sub prepare {
my ($ms, $mountpoint) = @_;
my $volid = $mountpoint->{volume};
+ my $type = $mountpoint->{type};
- # skip dev/bind mps when forced
- if ($mountpoint->{type} ne 'volume' && $force) {
- return;
+ # skip dev/bind mps when forced / shared
+ if ($type ne 'volume') {
+ if ($force) {
+ warn "-force is deprecated, please use the 'shared' property on individual non-volume mount points instead!\n";
+ return;
+ } elsif ($mountpoint->{shared}) {
+ if ($mountpoint->{nodes}) {
+ my $valid_target = 0;
+ foreach my $node (PVE::Tools::split_list($mountpoint->{nodes})) {
+ if ($node eq $self->{node}) {
+ $valid_target = 1;
+ last;
+ }
+ }
+
+ die "cannot migrate shared $type mount point '$ms', not shared with node '$self->{node}'\n" if !$valid_target;
+ }
+ return;
+ } else {
+ die "cannot migrate local $type mount point '$ms'\n";
+ }
}
+
my ($storage, $volname) = PVE::Storage::parse_volume_id($volid, 1) if $volid;
die "can't determine assigned storage for mountpoint '$ms'\n" if !$storage;
@@ -151,8 +171,7 @@ sub phase1 {
my $volid = $mountpoint->{volume};
# already checked in prepare
if ($mountpoint->{type} ne 'volume') {
- $self->log('info', "ignoring mountpoint '$ms' ('$volid') of type " .
- "'$mountpoint->{type}', migration is forced.")
+ $self->log('info', "ignoring shared '$mountpoint->{type}' mount point '$ms' ('$volid')")
if !$snapname;
return;
}
--
2.1.4
More information about the pve-devel
mailing list