From ed8c931f68318a3142cc6d638abddeba7381cce1 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Thu, 20 Jun 2024 20:48:08 +0200 Subject: [PATCH] Hide tail errors from logs on log rotation When the log gets rotated in the api or metadata containers our logs will get polluted with the following messages from the `tail` command: ``` tail: '/var/log/nova/nova-api.log' has become inaccessible: No such file or directory tail: '/var/log/nova/nova-api.log' has appeared; following new file ``` To prevent his from happening we will redirect the `stderr` from the `tail` command into `/dev/null`. --- pkg/novaapi/deployment.go | 7 +++---- pkg/novametadata/deployment.go | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/novaapi/deployment.go b/pkg/novaapi/deployment.go index 6ad38b6d3..70068f424 100644 --- a/pkg/novaapi/deployment.go +++ b/pkg/novaapi/deployment.go @@ -154,10 +154,9 @@ func StatefulSet( Args: []string{ "--single-child", "--", - "/usr/bin/tail", - "-n+1", - "-F", - "/var/log/nova/nova-api.log", + "/bin/sh", + "-c", + "/usr/bin/tail -n+1 -F /var/log/nova/nova-api.log 2>/dev/null", }, Image: instance.Spec.ContainerImage, SecurityContext: &corev1.SecurityContext{ diff --git a/pkg/novametadata/deployment.go b/pkg/novametadata/deployment.go index cf218108a..de0ef21ca 100644 --- a/pkg/novametadata/deployment.go +++ b/pkg/novametadata/deployment.go @@ -142,10 +142,9 @@ func StatefulSet( Args: []string{ "--single-child", "--", - "/usr/bin/tail", - "-n+1", - "-F", - "/var/log/nova/nova-metadata.log", + "/bin/sh", + "-c", + "/usr/bin/tail -n+1 -F /var/log/nova/nova-metadata.log 2>/dev/null", }, Image: instance.Spec.ContainerImage, SecurityContext: &corev1.SecurityContext{