Commit 10cab60
committed
fix(plugins): needs-restarting kernel-mismatch line on Debian
The Debian branch of the plugin parses `needrestart -b` output and
tries to print a "Running Kernel X != Installed Kernel Y" line when
the currently running kernel does not match the installed one.
The comparison variables `kcur` and `kexp` were being reset to empty
strings on every iteration of the parse loop, so by the time the
`if kcur != kexp:` check ran (outside the loop, at function scope)
both variables held the last iteration's reset value - two empty
strings, which are never "not equal". The kernel-mismatch line was
therefore never printed, even though a pending kernel upgrade was
correctly reported as WARN via `NEEDRESTART-KSTA: 3`.
Move the initialization out of the loop so the values set during
parsing survive, and extend the fixture-based unit test to assert
the "Running Kernel ... != Installed Kernel ..." line shows up for
the debian-kernel-pending case.1 parent a058e8d commit 10cab60
File tree
3 files changed
+8
-3
lines changed- check-plugins/needs-restarting
- unit-test
3 files changed
+8
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
146 | 147 | | |
147 | | - | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| |||
0 commit comments