From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 471F9691CC for ; Tue, 4 Aug 2020 14:09:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3C3F1CE48 for ; Tue, 4 Aug 2020 14:09:10 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 36384CE34 for ; Tue, 4 Aug 2020 14:09:09 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 04AC5433FB for ; Tue, 4 Aug 2020 14:09:09 +0200 (CEST) Date: Tue, 04 Aug 2020 14:09:01 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20200714175018.9592-1-s.ivanov@proxmox.com> In-Reply-To: <20200714175018.9592-1-s.ivanov@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1596542933.0g19smq090.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.040 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lxc.pm, proxmox.com] Subject: [pve-devel] applied: [PATCH container v2] Move volume activation to vm_start X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2020 12:09:40 -0000 On July 14, 2020 7:50 pm, Stoiko Ivanov wrote: > currently all volumes for a container are activated in the pre-start hook= , > which runs in a separate mount namespace (lxc.monitor.unshare is set to 1 > in our container config). This leads to problems with ZFS: > * if a pool is imported by this call the filesystems are mounted only ins= ide > the containers mount namespace >=20 > by running the volume activation inside vm_start, right before starting t= he > container via systemctl the volume activation happens before the unshare. >=20 > The other site where a container is started via systemctl is in > 'pve-container-stop-wrapper' when a container is rebooted from the inside= : > By activating the volumes in 'lxc-pve-poststop-hook' we avoid to try star= ting > a container with an inactive volume (LVM, kRBD), occuring when having a > mp-addtion pending during such a reboot >=20 > Starting a container manually using lxc-start is usually done for obtaini= ng > debug-logs (after starting failed with our tooling) - so the potential fo= r > regression in that case should also be small. >=20 > The $loopdevlist variable is not used anywhere in our codebase since 2015 > (da6298481ea4dfe7d894f42fa105cda015ebe5ce). >=20 > Signed-off-by: Stoiko Ivanov > --- > v1 -> v2: > * added the volume activation to lxc-pve-poststop-hook, after the great r= eview > from Fabian caught the case of container reboots (huge thanks!) > * decided to put it in lxc-pve-poststop-hook instead of > pve-container-stop-wrapper, since this avoids pulling in quite a few pa= rts > of our code-base into the latter, which currently has no imports. > AFAICU the only case where this could lead to a problem is if someone u= ses > `touch /var/lib/lxc/$vmid/reboot && systemctl restart pve-container@$vm= id` > for rebooting containers >=20 >=20 > src/PVE/LXC.pm | 5 +++++ > src/lxc-pve-poststop-hook | 6 ++++++ > src/lxc-pve-prestart-hook | 5 ----- > 3 files changed, 11 insertions(+), 5 deletions(-) >=20 > diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm > index f3aca7a..db5b8ca 100644 > --- a/src/PVE/LXC.pm > +++ b/src/PVE/LXC.pm > @@ -2186,6 +2186,11 @@ sub vm_start { > close($fh); > } > =20 > + my $storage_cfg =3D PVE::Storage::config(); > + my $vollist =3D PVE::LXC::Config->get_vm_volumes($conf); > + > + PVE::Storage::activate_volumes($storage_cfg, $vollist); > + > my $cmd =3D ['systemctl', 'start', "pve-container\@$vmid"]; > =20 > PVE::GuestHelpers::exec_hookscript($conf, $vmid, 'pre-start', 1); > diff --git a/src/lxc-pve-poststop-hook b/src/lxc-pve-poststop-hook > index 2683ae2..0fdd49e 100755 > --- a/src/lxc-pve-poststop-hook > +++ b/src/lxc-pve-poststop-hook > @@ -75,6 +75,12 @@ PVE::LXC::Tools::lxc_hook('post-stop', 'lxc', sub { > open(my $fh, '>', "/var/lib/lxc/$vmid/reboot") > or die "failed to create reboot trigger file: $!\n"; > close($fh); > + > + # activate all volumes of the container in case pending changes added > + # a not yet activated volume > + my $vollist =3D PVE::LXC::Config->get_vm_volumes($conf); > + PVE::Storage::activate_volumes($storage_cfg, $vollist); > + > # cause lxc to stop instead of rebooting > exit(1); > } > diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook > index ed25aa4..8823cad 100755 > --- a/src/lxc-pve-prestart-hook > +++ b/src/lxc-pve-prestart-hook > @@ -38,11 +38,6 @@ PVE::LXC::Tools::lxc_hook('pre-start', 'lxc', sub { > =20 > my $storage_cfg =3D PVE::Storage::config(); > =20 > - my $vollist =3D PVE::LXC::Config->get_vm_volumes($conf); > - my $loopdevlist =3D PVE::LXC::Config->get_vm_volumes($conf, 'rootfs'= ); > - > - PVE::Storage::activate_volumes($storage_cfg, $vollist); > - > my $rootdir =3D $vars->{ROOTFS_PATH}; > =20 > # Delete any leftover reboot-trigger file > --=20 > 2.20.1 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20 =