docker-systemctl-replacement icon indicating copy to clipboard operation
docker-systemctl-replacement copied to clipboard

systemctl.py does no journal logrotate

Open gdraheim opened this issue 7 years ago • 2 comments

When doing "systemctl status cron" then systemd may report

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

The systemctl.py replacement does create a path_journal_log as well, but it is never rotated. When using a container that runs for a long time then it might get to be a large file.

gdraheim avatar Sep 06 '18 19:09 gdraheim

As the processes of the services are completely independent one can just exchange the out file-node where to write to. An option may be to use "falloate --punch-hole" to put sparse blocks into the journal.

If one does really want to have a rotatation one could do some "dd" first. However I would prefer to not do such file creation - or even do it like just once a day.

Instead I would like to implement an option where the journal is given a maximum non-sparse value, and everything below is getting punched in the init_loop. That should keep the interruptions rather short - just one hole at a time most of the times.

fallocate --punch-hole --offset 40K --length 4K service.log
# TEST
dd if=/dev/random of=random1.log count=200
dd if=/dev/random of=random2.log count=200
fallocate -p -o 0 -l 12K random1.log
du random*
     16	random2.log
     4	random.log
cat random1.log | od -a | wc -l
    223
cat random2.log | od -a | wc -l
    985
ls -l random*
 -rw-r--r-- 15805 10. Sep 16:02 random1.log
 -rw-r--r-- 15735 10. Sep 16:03 random2.log

gdraheim avatar Sep 10 '18 14:09 gdraheim

man fallocate(1)

   -p, --punch-hole
          Deallocates  space  (i.e.,  creates  a hole) in the byte range starting at offset and continuing for length bytes.  Within the specified
          range, partial filesystem blocks are zeroed, and whole filesystem blocks are removed from the file.  After a successful call, subsequent
          reads  from  this  range will return zeroes.  This option may not be specified at the same time as  the --zero-range option.  Also, when
          using this option, --keep-size is implied.

          Supported for XFS (since Linux 2.6.38), ext4 (since Linux 3.0), Btrfs (since Linux 3.7) and tmpfs (since Linux 3.5).

gdraheim avatar Sep 10 '18 14:09 gdraheim