sysinfo should log tracebacks to a log file instead of printing them to the terminal

Bug #261994 reported by Christopher Armstrong
4
Affects Status Importance Assigned to Milestone
Landscape Client
Fix Released
Medium
Christopher Armstrong
Landscape Server
Fix Released
Medium
Christopher Armstrong

Bug Description

If a plugin raises an exception, a big traceback will be printed to the terminal. This should be avoided, and instead a log file should be written.

Revision history for this message
Jamu Kakar (jkakar) wrote :

I wonder if it would be worth including a note when failures occur:

 => landscape-sysinfo plugins failed. See /var/log/landscape/sysinfo.log.

Revision history for this message
Christopher Armstrong (radix) wrote :

Thanks for the idea.

It's ready for review in the attached branch.

Changed in landscape:
assignee: nobody → radix
status: New → In Progress
Changed in landscape-client:
assignee: nobody → radix
status: New → In Progress
Changed in landscape:
milestone: none → thames-pre-7
Revision history for this message
Thomas Herve (therve) wrote :

[1] Flakes
landscape/sysinfo/sysinfo.py:4: 'maybeDeferred' imported but unused

Everything else looks good, it's fairly cool. The only problems I have is:
 * the log file can't be configured
 * the log file is created even if no errors are printed.

But nothing major, +1.

Jamu Kakar (jkakar)
Changed in landscape-client:
importance: Undecided → Medium
Changed in landscape:
importance: Undecided → Medium
Revision history for this message
Christopher Armstrong (radix) wrote :

Ok, I made some changes.

Thomas: I've fixed your [1]

- Rotation is now size-based. It rotates at 500k and keeps 1 backup file.
- The file is now put into ~/.landscape/sysinfo.log.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Hmm, one possible problem, which I'm not even sure was introduced in this branch, but that I just noticed. When there is an error of this kind, the exit status is not 1, but still one:

root@hardy-vm:~# chmod 0700 /proc
root@hardy-vm:~# su - andreas
andreas@hardy-vm:~$ landscape-sysinfo; echo $?
  Users logged-in: 1

  => Load plugin raised an exception. See ~/.landscape-sysinfo.log for information.
  => Disk plugin raised an exception. See ~/.landscape-sysinfo.log for information.
  => Memory plugin raised an exception. See ~/.landscape-sysinfo.log for information.
  => Processes plugin raised an exception. See ~/.landscape-sysinfo.log for information.
0
andreas@hardy-vm:~$

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Very very cool! Even WITH TESTS! +1!

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Oh, about the thing Andreas mentioned, it's an interesting point.

Maybe we should just log one line once for all plugins. The log file has details in any case.

Revision history for this message
Christopher Armstrong (radix) wrote :

Ok, I made it so there's only one note no matter how many plugins fail.

I also added word-wrapping to the note feature, since I noticed my note was >80 characters. Please check it out.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I think the main issue is that it still exits with code 0 instead of something different when there is an error. And I just realized I made a typo in my previous comment: "... the exit statis is not 1, but still s/one/zero/". :)

Revision history for this message
Thomas Herve (therve) wrote :

Small conflict in landscape/sysinfo/deployment.py, everything else is fine, +1.

Revision history for this message
Christopher Armstrong (radix) wrote :

Thanks, merged

Changed in landscape:
status: In Progress → Fix Committed
Changed in landscape-client:
status: In Progress → Fix Committed
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

This was released into production.

Changed in landscape-client:
status: Fix Committed → Fix Released
Changed in landscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.