Skip to content

Improve error handling for gadget goroutine failures #53

@dorser

Description

@dorser

Summary

In internal/gadget/registry.go, gadgets run in goroutines and errors are only logged — there's no mechanism to surface failures back to the caller.

Current Code

go func(name string, config *GadgetConfig, gadgetCtx *gadgetcontext.GadgetContext) {
    if err := r.runtimeManager.RunGadget(gadgetCtx, config.Params); err != nil {
        slog.Error("Error running gadget", "name", name, "error", err)
    }
}(name, config, gadgetCtx)

Problems

  1. If a gadget fails to start, the main process doesn't know
  2. No way to trigger shutdown if a critical gadget fails
  3. No health status reporting for running gadgets

What's Needed

Options:

  • Return an error channel from RunAll that the caller can select on
  • Use an errgroup.Group to manage goroutine lifecycle
  • Add a callback/hook mechanism for gadget lifecycle events
  • At minimum, propagate first error and cancel context

Files

  • internal/gadget/registry.go
  • cmd/micromize/root.go (caller)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions