Skip to content

Commit

Permalink
Fix api log file increases indefinitely
Browse files Browse the repository at this point in the history
The cinder-api pod uses a file between the cinder-api service and a
sidecar to pass the cinder logs from the service to the stdout.

With the current code it will grow forever, which makes no sense, since
the stdout from the pod itself is already being stored, under
/var/log/pods and/or in a centralized logging service.

This patch makes the oslo.log service rotate the log file once it
reaches 20MB in size.

Other projects like nova and glance set the limit to 50MB and they keep
5 rotated files, but I think that keeping rotated files is useless here,
and 50MB seems a bit much.

Unfortunately we need to at least keep 1 copy, or oslo.log will not do
the right thing if set to 0.

We also need to redirect errors in the sidecar container that tails the
log to /dev/null to prevent tail error messages whenever the file gets
rotated.
  • Loading branch information
Akrog committed Jun 26, 2024
1 parent e6f7008 commit 07b9e7d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
7 changes: 3 additions & 4 deletions pkg/cinderapi/statefuleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ func StatefulSet(
Args: []string{
"--single-child",
"--",
"/usr/bin/tail",
"-n+1",
"-F",
LogFile,
"/bin/sh",
"-c",
"/usr/bin/tail -n+1 -F " + LogFile + " 2>/dev/null",
},
Image: instance.Spec.ContainerImage,
SecurityContext: &corev1.SecurityContext{
Expand Down
3 changes: 3 additions & 0 deletions templates/cinderapi/config/01-service-defaults.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[DEFAULT]
log_file = {{ .LogFile }}
log_rotation_type = size
max_logfile_count = 1
max_logfile_size_mb = 20

[oslo_policy]
enforce_scope = true
Expand Down
7 changes: 3 additions & 4 deletions test/kuttl/common/assert_sample_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ spec:
- args:
- --single-child
- --
- /usr/bin/tail
- -n+1
- -F
- /var/log/cinder/cinder-api.log
- /bin/sh
- -c
- /usr/bin/tail -n+1 -F /var/log/cinder/cinder-api.log 2>/dev/null
command:
- /usr/bin/dumb-init
imagePullPolicy: IfNotPresent
Expand Down
7 changes: 3 additions & 4 deletions test/kuttl/common/assert_tls_sample_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ spec:
- args:
- --single-child
- --
- /usr/bin/tail
- -n+1
- -F
- /var/log/cinder/cinder-api.log
- /bin/sh
- -c
- /usr/bin/tail -n+1 -F /var/log/cinder/cinder-api.log 2>/dev/null
volumeMounts:
- mountPath: /var/log/cinder
name: logs
Expand Down

0 comments on commit 07b9e7d

Please sign in to comment.