[research] Named pipe /dev/sshserial missing lines on first use
I discovered interesting behavior of script_output on spvm backend. When is script_output used for first, few lines at the beginning can be lost.
Here is the openQA reproduction:
script_output is used to get
systemctl status kdump, but first lines are missing.
# Result: Process: 4248 ExecStart=/lib/kdump/load.sh --update (code=exited, status=0/SUCCESS) Main PID: 4248 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 4915) CGroup: /system.slice/kdump.service
one character was echoed to /dev/sshserial, script_output is used to get
systemctl status kdump, all lines are captured
# Result: F0ZS5 ● kdump.service - Load kdump kernel and initrd Loaded: loaded (/usr/lib/systemd/system/kdump.service; enabled; vendor preset: disabled) Active: active (exited) since Mon 2019-05-06 16:37:24 EDT; 13h ago Process: 4248 ExecStart=/lib/kdump/load.sh --update (code=exited, status=0/SUCCESS) Main PID: 4248 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 4915) CGroup: /system.slice/kdump.service
I was able to manually reproduce similar behavior with named pipe on my system. Do it is root to have all output from systemctl,
open first terminal
mkfifo mypipe tail -f mypipe
open second terminal
systemctl status sshd | tee mypipe
Result of first status command, initial lines are missing:
May 08 22:51:43 headcleaner.lan sshd: Accepted publickey for petr from x.x.x.x port 59408 xxx May 08 22:51:43 headcleaner.lan sshd: pam_unix(sshd:session): session opened for user user by (uid=0)
Result of second use of status command:
● sshd.service - OpenSSH Daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2019-05-06 08:23:50 CEST; 4 days ago Main PID: 1467 (sshd) Tasks: 1 Memory: 2.0M CGroup: /system.slice/sshd.service └─1467 /usr/sbin/sshd -D
If is reading from named pipe done by cat like, all lines are displayed.
Maybe, we just need to flush buffer(like write something to it) in pipe before reading from it or maybe update os-autoinst part which reading from /dev/sshserial (in similar way like there is difference between cat and tail)?
#4 Updated by pcervinka about 3 years ago
Manually Tested: tail -fn +1 file and there is no lost output. Got inspiration on: https://unix.stackexchange.com/questions/139866/how-do-i-cat-and-follow-a-file.
Changed line in lib/susedistribution.pm:
serial => 'mkfifo /dev/sshserial; tail -f /dev/sshserial',
serial => 'mkfifo /dev/sshserial; tail -fn +1 /dev/sshserial',
And it works fine now, all script_output is captured: