[pve-devel] [PATCH cluster] API/Cluster: autoflush STDOUT for join and create

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Mar 27 08:08:37 CEST 2018


We're in a forked worker here, so STDOUT isn't connected to a
(pseudo)TTY directly, so perl flushes only when it's intewrnal buffer
is full.

Ensure each line gets flushed out to the API client in use to give
immediate feedback about the operation.

For example, our WebUIs Task Viewer won't show anything without this
quite a bit of time, you may even get logged out before the flush
from the perl side happens, which is simply bad UX.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 data/PVE/API2/ClusterConfig.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/data/PVE/API2/ClusterConfig.pm b/data/PVE/API2/ClusterConfig.pm
index ea253b5..ad7e8c6 100644
--- a/data/PVE/API2/ClusterConfig.pm
+++ b/data/PVE/API2/ClusterConfig.pm
@@ -121,6 +121,7 @@ __PACKAGE__->register_method ({
 	my $authuser = $rpcenv->get_user();
 
 	my $code = sub {
+	    STDOUT->autoflush();
 	    PVE::Cluster::setup_sshd_config(1);
 	    PVE::Cluster::setup_rootsshconfig();
 	    PVE::Cluster::setup_ssh_keys();
@@ -512,6 +513,7 @@ __PACKAGE__->register_method ({
 	my $authuser = $rpcenv->get_user();
 
 	my $worker = sub {
+	    STDOUT->autoflush();
 	    PVE::Tools::lock_file($local_cluster_lock, 10, \&PVE::Cluster::join, $param);
 	    die $@ if $@;
 	};
-- 
2.14.2




More information about the pve-devel mailing list