xenserver / xe-guest-utilities

XenServer guest utilities for unix-like operating systems
BSD 2-Clause "Simplified" License
56 stars 58 forks source link

Bug - panic: runtime error: slice bounds out of range [:-1] #161

Open iuriss opened 2 months ago

iuriss commented 2 months ago

Service had a panic

May 03 14:42:48 host systemd[1]: Started Linux Guest Agent. May 03 14:42:48 host xe-daemon[5682]: panic: runtime error: slice bounds out of range [:-1] May 03 14:42:48 host xe-daemon[5682]: goroutine 1 [running]: May 03 14:42:48 host xe-daemon[5682]: xe-guest-utilities/guestmetric.(*Collector).CollectDisk(0xc000122018) May 03 14:42:48 host xe-daemon[5682]: /builddir/build/BUILD/xe-guest-utilities-7.30.0/vendor/xe-guest-utilities/guestmetric/guestmetric_linux.go:290 +0xdb0 May 03 14:42:48 hostxe-daemon[5682]: main.main() May 03 14:42:48 host xe-daemon[5682]: /builddir/build/BUILD/xe-guest-utilities-7.30.0/build/gobuild/xe-daemon/xe-daemon.go:114 +0xdab May 03 14:42:48 host systemd[1]: xe-linux-distribution.service: Main process exited, code=exited, status=2/INVALIDARGUMENT May 03 14:42:48 host systemd[1]: xe-linux-distribution.service: Failed with result 'exit-code'.

I found this bug

I had /dev/xvdc1 which I created a PV with. However I had not created a VG with it. The process kept having the panic.

Once I created VG data with /dev/xvdc1. Then the service started accordingly.

LunfanZhang commented 2 months ago

@iuriss I take a look at the call trace, the error happened when the agent tries to collect the disk metrics, specific on the pvs query. The output format of the pvs query command has changed, resulting in the parsed results of the regular expression not matching the expectation Some improvements are necessary in the future I.M.O

  1. check if output format of the pvs query meet for our requirement before we obtain the value with index
  2. I presume a whole exception handling structure is needed as it is unacceptable that the whole process crash for only one metrics fails