public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] applied: [PATCH container 1/5] ct start: track lxc-start stderr and print in error case
@ 2020-09-09 19:12 Thomas Lamprecht
  2020-09-09 19:12 ` [pve-devel] applied: [PATCH container 2/5] implement debug start Thomas Lamprecht
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2020-09-09 19:12 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
 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





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

end of thread, other threads:[~2020-09-09 19:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 19:12 [pve-devel] applied: [PATCH container 1/5] ct start: track lxc-start stderr and print in error case Thomas Lamprecht
2020-09-09 19:12 ` [pve-devel] applied: [PATCH container 2/5] implement debug start Thomas Lamprecht
2020-09-09 19:12 ` [pve-devel] applied: [PATCH container 3/5] protected_call: remove left-over rootdir/dev mkdir Thomas Lamprecht
2020-09-09 19:12 ` [pve-devel] applied: [PATCH container 4/5] alpine: setup net: pass whole config to parent method Thomas Lamprecht
2020-09-09 19:12 ` [pve-devel] applied: [PATCH container 5/5] setup: heuristically warn if the FS hosting /etc is not mounted 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