]> git.proxmox.com Git - pve-cluster.git/commitdiff
API/Cluster: autoflush STDOUT for join and create
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 27 Mar 2018 06:08:37 +0000 (08:08 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 5 Apr 2018 08:25:36 +0000 (10:25 +0200)
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@proxmox.com>
data/PVE/API2/ClusterConfig.pm

index ea253b5d987dd52d44e4234520a9072eedd88119..ad7e8c6561cfa0a4488a55d494d34c808cfcf98f 100644 (file)
@@ -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 $@;
        };