Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop Beyla if either NetO11y or AppO11y component fails [1.9-backport] #1520

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/components/beyla.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ func RunBeyla(ctx context.Context, cfg *beyla.Config) error {
wg.Add(1)
}

// of one of both nodes fail, the other should stop
ctx, cancel := context.WithCancel(ctx)
errs := make(chan error, 2)
if app {
go func() {
defer wg.Done()
if err := setupAppO11y(ctx, ctxInfo, cfg); err != nil {
cancel()
errs <- err
}
}()
Expand All @@ -45,11 +48,13 @@ func RunBeyla(ctx context.Context, cfg *beyla.Config) error {
go func() {
defer wg.Done()
if err := setupNetO11y(ctx, ctxInfo, cfg); err != nil {
cancel()
errs <- err
}
}()
}
wg.Wait()
cancel()
select {
case err := <-errs:
return err
Expand All @@ -66,9 +71,11 @@ func setupAppO11y(ctx context.Context, ctxInfo *global.ContextInfo, config *beyl

instr := appolly.New(ctx, ctxInfo, config)
if err := instr.FindAndInstrument(&wg); err != nil {
slog.Debug("can't find target process", "error", err)
return fmt.Errorf("can't find target process: %w", err)
}
if err := instr.ReadAndForward(); err != nil {
slog.Debug("can't start read and forwarding", "error", err)
return fmt.Errorf("can't start read and forwarding: %w", err)
}
return nil
Expand All @@ -82,9 +89,11 @@ func setupNetO11y(ctx context.Context, ctxInfo *global.ContextInfo, cfg *beyla.C
slog.Info("starting Beyla in Network metrics mode")
flowsAgent, err := agent.FlowsAgent(ctxInfo, cfg)
if err != nil {
slog.Debug("can't start network metrics capture", "error", err)
return fmt.Errorf("can't start network metrics capture: %w", err)
}
if err := flowsAgent.Run(ctx); err != nil {
slog.Debug("can't start network metrics capture", "error", err)
return fmt.Errorf("can't start network metrics capture: %w", err)
}
return nil
Expand Down
3 changes: 3 additions & 0 deletions pkg/internal/discover/watcher_proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,14 @@ func (pa *pollAccounter) Run(out chan<- []Event[processAttrs]) {
bpfWatchEvents := make(chan watcher.Event, 100)
if err := pa.loadBPFWatcher(pa.cfg, bpfWatchEvents); err != nil {
log.Error("Unable to load eBPF watcher for process events", "error", err)
// will stop pipeline in cascade
return
}

if pa.cfg.EBPF.BpfDebug {
if err := pa.loadBPFLogger(pa.cfg); err != nil {
log.Error("Unable to load eBPF logger for process events", "error", err)
// keep running without logs
}
}

Expand Down
Loading