public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Aaron Lauterer <a.lauterer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] ceph install: improve ceph install checks during installation
Date: Fri,  1 Oct 2021 15:59:34 +0200	[thread overview]
Message-ID: <20211001135934.3429632-1-a.lauterer@proxmox.com> (raw)

Adding a lock file during the Ceph installation helps to cover the time
span in which the binary is already present but the installation not yet
done.

The most noticeable effect is that the 'Next' button in the GUI will
only become active once the installation is actually finished and not
earlier.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
---

I don't know if the file creation could be done nicer than using open
and close.

If the lock file /var/run/lock/ceph_install.lck is created before ceph
is installed, there is no effect. If it is created after Ceph has been
installed, the user is prompted by the install dialog once more, but apt
will be done right away.

 PVE/CLI/pveceph.pm | 9 +++++++++
 PVE/Ceph/Tools.pm  | 4 +++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/PVE/CLI/pveceph.pm b/PVE/CLI/pveceph.pm
index 356af282..3bee3413 100755
--- a/PVE/CLI/pveceph.pm
+++ b/PVE/CLI/pveceph.pm
@@ -177,7 +177,14 @@ __PACKAGE__->register_method ({
 	);
 
 	print "start installation\n";
+
+	my $install_lock_file = '/var/lock/ceph_install.lck';
+	open(INSTALL_LOCK, ">${install_lock_file}") ||
+	     die "could not lock Ceph installation\n";
+	close INSTALL_LOCK;
+
 	if (system(@apt_install, @ceph_packages) != 0) {
+	    unlink $install_lock_file;
 	    die "apt failed during ceph installation ($?)\n";
 	}
 
@@ -188,6 +195,8 @@ __PACKAGE__->register_method ({
 	    'systemctl', 'try-reload-or-restart', 'pvedaemon.service', 'pveproxy.service'
 	]);
 
+	unlink $install_lock_file;
+
 	return undef;
     }});
 
diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index f54d837a..18133d65 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -155,7 +155,9 @@ sub check_ceph_installed {
 
     $service = 'ceph_bin' if !defined($service);
 
-    if (! -x $ceph_service->{$service}) {
+    # ceph_install.lck is checked to cover the time where the binary is already
+    # present, but the installation not yet done
+    if (! -x $ceph_service->{$service} || -e '/var/lock/ceph_install.lck') {
 	die "binary not installed: $ceph_service->{$service}\n" if !$noerr;
 	return undef;
     }
-- 
2.30.2





             reply	other threads:[~2021-10-01 13:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 13:59 Aaron Lauterer [this message]
2021-10-01 14:06 ` [pve-devel] [PATCH v2 " Aaron Lauterer
2021-10-04  6:15   ` Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211001135934.3429632-1-a.lauterer@proxmox.com \
    --to=a.lauterer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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