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 CCE4A607B2 for ; Wed, 9 Sep 2020 21:12:31 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C77311407B for ; Wed, 9 Sep 2020 21:12:31 +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 776291404D for ; Wed, 9 Sep 2020 21:12:29 +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 3AA6F44ADE for ; Wed, 9 Sep 2020 21:12:29 +0200 (CEST) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Date: Wed, 9 Sep 2020 21:12:19 +0200 Message-Id: <20200909191223.4187564-1-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.184 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] Subject: [pve-devel] applied: [PATCH container 1/5] ct start: track lxc-start stderr and print in error case 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: Wed, 09 Sep 2020 19:12:31 -0000 Signed-off-by: Thomas Lamprecht --- src/PVE/LXC.pm | 15 +++++++++++++++ src/pve-container@.service | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index e13f7e6..f9aaaa9 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -2167,6 +2167,17 @@ sub userns_command { return []; } +my sub print_ct_stderr_log { + my ($vmid) = @_; + my $log = eval { file_get_contents("/run/pve/ct-$vmid.stderr") }; + return if !$log; + + while ($log =~ /^\h*(lxc-start:?\s+$vmid:?\s*\S+\s*)?(.*?)\h*$/gm) { + my $line = $2; + print STDERR "$line\n"; + } +} + my sub monitor_state_change($$) { my ($monitor_socket, $vmid) = @_; die "no monitor socket\n" if !defined($monitor_socket); @@ -2201,6 +2212,7 @@ my sub monitor_start($$) { if (my $err = $@) { warn "problem with monitor socket, but continuing anyway: $err\n"; } elsif (!$success) { + print_ct_stderr_log($vmid); die "startup for container '$vmid' failed\n"; } } @@ -2233,6 +2245,9 @@ sub vm_start { my $monitor_socket = eval { PVE::LXC::Monitor::get_monitor_socket() }; warn $@ if $@; + unlink "/run/pve/ct-$vmid.stderr"; # systemd does not truncate log files + + my $base_unit = $conf->{debug} ? 'pve-container-debug' : 'pve-container'; my $cmd = ['systemctl', 'start', "pve-container\@$vmid"]; diff --git a/src/pve-container@.service b/src/pve-container@.service index d9185bc..fdc373e 100644 --- a/src/pve-container@.service +++ b/src/pve-container@.service @@ -19,4 +19,4 @@ ExecStop=/usr/share/lxc/pve-container-stop-wrapper %i # Environment=CONSOLETYPE=serial # Prevent container init from putting all its output into the journal StandardOutput=null -StandardError=null +StandardError=file:/run/pve/ct-%i.stderr -- 2.20.1