Skip to content

Commit

Permalink
fix(linux): ⚡ don't run problems worker if ABRT problems are not avai…
Browse files Browse the repository at this point in the history
…lable in D-Bus
  • Loading branch information
joshuar committed Sep 9, 2024
1 parent 590891f commit fecb599
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/linux/problems/problems.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func parseProblem(details map[string]string) map[string]any {
type worker struct {
getProblems func() ([]string, error)
getProblemDetails func(problem string) (map[string]string, error)
logger *slog.Logger
bus *dbusx.Bus
}

Expand Down Expand Up @@ -129,6 +128,12 @@ func NewProblemsWorker(ctx context.Context) (*linux.SensorWorker, error) {
return nil, linux.ErrNoSystemBus
}

// Check if we can fetch problem data, bail if we can't.
_, err := dbusx.GetData[[]string](bus, dBusProblemsDest, dBusProblemIntr, dBusProblemIntr+".GetProblems")
if err != nil {
return nil, fmt.Errorf("unable to fetch ABRT problems from D-Bus: %w", err)
}

return &linux.SensorWorker{
Value: &worker{
getProblems: func() ([]string, error) {
Expand All @@ -153,8 +158,7 @@ func NewProblemsWorker(ctx context.Context) (*linux.SensorWorker, error) {
return details, nil
}
},
logger: logging.FromContext(ctx).With(slog.String("worker", problemsWorkerID)),
bus: bus,
bus: bus,
},
WorkerID: problemsWorkerID,
},
Expand Down

0 comments on commit fecb599

Please sign in to comment.