public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH cluster] pvecm add: require user to navigate out of /etc/pve
@ 2023-03-09 12:30 Friedrich Weber
  2023-03-11 17:01 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Friedrich Weber @ 2023-03-09 12:30 UTC (permalink / raw)
  To: pve-devel

If `pvecm add` is issued from /etc/pve (or any subdirectory), it
prints some errors:

    [...]
    shell-init: error retrieving current directory: getcwd: cannot
    access parent directories: Transport endpoint is not connected
    [...]
    successfully added node 'pve-c2' to cluster.
    cannot fetch initial working directory: Transport endpoint is not
    connected at /usr/share/perl5/PVE/CLI/pvecm.pm line 446.

The reason is that `pvecm add` restarts pmxcfs, which re-mounts the
fuse mount at /etc/pve, invalidating pvecm's working directory.

The error messages give the impression that something went wrong.
Indeed, the second error indicates the temporary directory is not
cleaned up. The cluster join itself actually works, though.

The issue could be fixed by chdir'ing to / in `pvecm add`. However,
the user's shell would still remain in the now-invalid /etc/pve,
potentially leading to confusing "transport endpoint not connected"
messages in future interactions.

To avoid this, require the user to chdir out of /etc/pve before
running `pvecm add`.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---
 data/PVE/CLI/pvecm.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/data/PVE/CLI/pvecm.pm b/data/PVE/CLI/pvecm.pm
index 5ac9ed3..b0b5931 100755
--- a/data/PVE/CLI/pvecm.pm
+++ b/data/PVE/CLI/pvecm.pm
@@ -3,6 +3,7 @@ package PVE::CLI::pvecm;
 use strict;
 use warnings;
 
+use Cwd qw(getcwd);
 use File::Path;
 use File::Basename;
 use PVE::Tools qw(run_command);
@@ -348,6 +349,11 @@ __PACKAGE__->register_method ({
     code => sub {
 	my ($param) = @_;
 
+	# avoid "transport endpoint not connected" errors that occur if
+	# restarting pmxcfs while in fuse-mounted /etc/pve
+	die "Navigate out of $basedir before running 'pvecm add', for example by running 'cd'.\n"
+	    if getcwd() =~ m!^$basedir(/.*)?$!;
+
 	my $nodename = PVE::INotify::nodename();
 	my $host = $param->{hostname};
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH cluster] pvecm add: require user to navigate out of /etc/pve
  2023-03-09 12:30 [pve-devel] [PATCH cluster] pvecm add: require user to navigate out of /etc/pve Friedrich Weber
@ 2023-03-11 17:01 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-03-11 17:01 UTC (permalink / raw)
  To: Proxmox VE development discussion, Friedrich Weber

Am 09/03/2023 um 13:30 schrieb Friedrich Weber:
> If `pvecm add` is issued from /etc/pve (or any subdirectory), it
> prints some errors:
> 
>     [...]
>     shell-init: error retrieving current directory: getcwd: cannot
>     access parent directories: Transport endpoint is not connected
>     [...]
>     successfully added node 'pve-c2' to cluster.
>     cannot fetch initial working directory: Transport endpoint is not
>     connected at /usr/share/perl5/PVE/CLI/pvecm.pm line 446.
> 
> The reason is that `pvecm add` restarts pmxcfs, which re-mounts the
> fuse mount at /etc/pve, invalidating pvecm's working directory.
> 
> The error messages give the impression that something went wrong.
> Indeed, the second error indicates the temporary directory is not
> cleaned up. The cluster join itself actually works, though.
> 
> The issue could be fixed by chdir'ing to / in `pvecm add`. However,
> the user's shell would still remain in the now-invalid /etc/pve,
> potentially leading to confusing "transport endpoint not connected"
> messages in future interactions.
> 
> To avoid this, require the user to chdir out of /etc/pve before
> running `pvecm add`.
> 
> Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
> ---
>  data/PVE/CLI/pvecm.pm | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-11 17:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 12:30 [pve-devel] [PATCH cluster] pvecm add: require user to navigate out of /etc/pve Friedrich Weber
2023-03-11 17:01 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal