Make the libvirt trace compact: libvirt API names, one error field, terse test output

The first live run showed the trace working but noisy: testr printed
ts/level/msg and the per-run constants on every line, the error text
appeared twice, host appeared twice on image-cache lines, and the Go
method name was less useful than the libvirt function it maps to.

The tracer now logs rpc=virDomainLookupByName (go-libvirt's names are the
public API names without the vir prefix), error plus libvirtError (code
name) and libvirtCode, and image.go stops re-adding host. The integration
test replaces testr with a compact logr sink: time, logger name, the rpc
as headline, then fields, with provider/host/name omitted since the first
line of the run states them. Docs and execution log updated.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
2026-09-10 19:13:51 +00:00
co-authored by Claude Fable 5.1
parent f50d30e58e
commit 5a6c889531
11 changed files with 165 additions and 46 deletions
+4 -7
View File
@@ -68,16 +68,13 @@ func logAPIError(log logr.Logger, op string, err error) {
}
// libvirtErrorFields renders a daemon-reported error as log key/values:
// the numeric code, its constant name (ErrNoDomain, ...) and the daemon's
// message. Nil for transport and other non-libvirt errors.
// its constant name (ErrNoDomain, ...) and numeric code. The daemon's
// message is already the error text. Nil for transport and other
// non-libvirt errors.
func libvirtErrorFields(err error) []any {
var lerr libvirt.Error
if !errors.As(err, &lerr) {
return nil
}
return []any{
"libvirtCode", lerr.Code,
"libvirtCodeName", libvirt.ErrorNumber(lerr.Code).String(),
"libvirtMessage", lerr.Message,
}
return []any{"libvirtError", libvirt.ErrorNumber(lerr.Code).String(), "libvirtCode", lerr.Code}
}