Description of problem: Currently logshifter fails to start if the newline at the end of the file is missing. Version-Release number of selected component (if applicable): openshift-origin-logshifter-1.8.2.1-1.el6op.x86_64 How reproducible: always Steps to Reproduce: 1. open /etc/openshift/logshifter.conf on a node and remove the last empty line 2. try to start logshifter: /usr/bin/logshifter -verbose -tag ruby Actual results: Logshifter cannot start, error returned: config: &{queueSize:1000 inputBufferSize:4096 outputType:multi syslogBufferSize:4096 fileBufferSize:4096 fileWriterDir: outputTypeFromEnviron:false} using max file size 10485760 and max files 10 panic: runtime error: slice bounds out of range goroutine 1 [running]: runtime.panic(0x560780, 0x72cdaa) /usr/lib64/golang/src/pkg/runtime/panic.c:266 +0xb6 main.(*FileWriter).Init(0xc2100213c0, 0x0, 0x0) /builddir/build/BUILD/openshift-origin-logshifter-1.8.2.1/_build/src/github.com/openshift/logshifter/file_writer.go:62 +0x300 main.(*MultiWriter).Init(0xc21004f440, 0xc210000170, 0x568380) /builddir/build/BUILD/openshift-origin-logshifter-1.8.2.1/_build/src/github.com/openshift/logshifter/multi_writer.go:14 +0x5d main.(*Output).Write(0xc21004f480, 0xc21004f480, 0x0, 0x0) /builddir/build/BUILD/openshift-origin-logshifter-1.8.2.1/_build/src/github.com/openshift/logshifter/output.go:27 +0x5f main.(*Shifter).Start(0xc210021410, 0xc210021410, 0x4) /builddir/build/BUILD/openshift-origin-logshifter-1.8.2.1/_build/src/github.com/openshift/logshifter/shifter.go:66 +0xf8 main.main() /builddir/build/BUILD/openshift-origin-logshifter-1.8.2.1/_build/src/github.com/openshift/logshifter/main.go:124 +0xaf1 goroutine 3 [syscall]: os/signal.loop() /usr/lib64/golang/src/pkg/os/signal/signal_unix.go:21 +0x1e created by os/signal.init·1 /usr/lib64/golang/src/pkg/os/signal/signal_unix.go:27 +0x31 goroutine 4 [chan receive]: main.func·002() /builddir/build/BUILD/openshift-origin-logshifter-1.8.2.1/_build/src/github.com/openshift/logshifter/main.go:28 +0xbe created by main.main /builddir/build/BUILD/openshift-origin-logshifter-1.8.2.1/_build/src/github.com/openshift/logshifter/main.go:31 +0x8a goroutine 5 [syscall]: runtime.goexit() /usr/lib64/golang/src/pkg/runtime/proc.c:1394 This causes gears on the node to fail silently without producing any logs when created/restarted. Expected results: Logshifter is able to parse the config properly Additional info: Sample "broken" config looks like this hexdump -C /etc/openshift/logshifter.conf 00000000 71 75 65 75 65 73 69 7a 65 20 3d 20 31 30 30 30 |queuesize = 1000| 00000010 0a 69 6e 70 75 74 62 75 66 66 65 72 73 69 7a 65 |.inputbuffersize| 00000020 20 3d 20 34 30 39 36 0a 6f 75 74 70 75 74 74 79 | = 4096.outputty| 00000030 70 65 20 3d 20 6d 75 6c 74 69 0a 73 79 73 6c 6f |pe = multi.syslo| 00000040 67 62 75 66 66 65 72 73 69 7a 65 20 3d 20 34 30 |gbuffersize = 40| 00000050 39 36 0a 66 69 6c 65 62 75 66 66 65 72 73 69 7a |96.filebuffersiz| 00000060 65 20 3d 20 34 30 39 36 0a 6f 75 74 70 75 74 74 |e = 4096.outputt| 00000070 79 70 65 66 72 6f 6d 65 6e 76 69 72 6f 6e 20 3d |ypefromenviron =| 00000080 20 66 61 6c 73 65 0a 66 69 6c 65 77 72 69 74 65 | false.filewrite| 00000090 72 64 69 72 20 3d 20 7e 2f 61 70 70 2d 72 6f 6f |rdir = ~/app-roo| 000000a0 74 2f 6c 6f 67 73 |t/logs| 000000a6 this one will work (note the 0A line feed symbol) hexdump -C /etc/openshift/logshifter.conf 00000000 71 75 65 75 65 73 69 7a 65 20 3d 20 31 30 30 30 |queuesize = 1000| 00000010 0a 69 6e 70 75 74 62 75 66 66 65 72 73 69 7a 65 |.inputbuffersize| 00000020 20 3d 20 34 30 39 36 0a 6f 75 74 70 75 74 74 79 | = 4096.outputty| 00000030 70 65 20 3d 20 6d 75 6c 74 69 0a 73 79 73 6c 6f |pe = multi.syslo| 00000040 67 62 75 66 66 65 72 73 69 7a 65 20 3d 20 34 30 |gbuffersize = 40| 00000050 39 36 0a 66 69 6c 65 62 75 66 66 65 72 73 69 7a |96.filebuffersiz| 00000060 65 20 3d 20 34 30 39 36 0a 6f 75 74 70 75 74 74 |e = 4096.outputt| 00000070 79 70 65 66 72 6f 6d 65 6e 76 69 72 6f 6e 20 3d |ypefromenviron =| 00000080 20 66 61 6c 73 65 0a 66 69 6c 65 77 72 69 74 65 | false.filewrite| 00000090 72 64 69 72 20 3d 20 7e 2f 61 70 70 2d 72 6f 6f |rdir = ~/app-roo| 000000a0 74 2f 6c 6f 67 73 0a |t/logs.| 000000a6
The fix was shipped in openshift-origin-logshifter-1.9.1.1-1.el6op with openshift enterprise 2.2.6: https://rhn.redhat.com/errata/RHBA-2015-1463.html
Even with the aforementioned fix, it is possible for the last line of the configuration file not to be included if the file does not end with a EOL or '\n'.
https://github.com/openshift/origin-server/pull/6243
For QA: (In reply to Timothy Williams from comment #3) > Even with the aforementioned fix, it is possible for the last line of the > configuration file not to be included if the file does not end with a EOL or > '\n'. Just to clarify the reproducing steps accordingly: (in reply to Evgheni Dereveanchin from comment #0) > Steps to Reproduce: > 1. open /etc/openshift/logshifter.conf on a node and remove the last empty > line The problem actually happens when the last line in the file is not empty but doesn't end with a newline. The default /etc/openshift/logshifter.conf is set for outputtype=file and its last line specifies the log file dir (filewriterdir), so you should be able to reproduce this on a fresh install with: # perl -i.bak -p0e 's/\s*$//' /etc/openshift/logshifter.conf
Commit pushed to master at https://github.com/openshift/origin-server https://github.com/openshift/origin-server/commit/d51d2e03c2c6fd0e93d9c2e6ffe65bb4af720be9 Bug 1264039: Read all lines even if file does not end in '\n' or EOL https://bugzilla.redhat.com/show_bug.cgi?id=1264039 Ensure that all lines of a configuration file are read even if the file does not end in a newline character or EOL.
Verify this bug with openshift-origin-logshifter-1.10.1.2-1.el6op.x86_64. Remove the whitespace character of logshifter.conf by # perl -i.bak -p0e 's/\s*$//' /etc/openshift/logshifter.conf Start logshifter: [root@node2 yum.repos.d]# /usr/bin/logshifter -verbose -tag ruby config: &{queueSize:1000 inputBufferSize:4096 outputType:file syslogBufferSize:4096 fileBufferSize:4096 fileWriterDir:~/app-root/logs outputTypeFromEnviron:false} using max file size 10485760 and max files 10
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHSA-2015-1844.html