diff --git a/pkg/datastore/interface.go b/pkg/datastore/interface.go index 9e63626..cebb603 100644 --- a/pkg/datastore/interface.go +++ b/pkg/datastore/interface.go @@ -137,17 +137,21 @@ func SearchRepo(ctx context.Context, ds Datastore, repo string) (*Target, error) repoTarget, err := ds.GetTargetByScope(ctx, repo) if err == nil && repoTarget.CanReceiveJob() { return repoTarget, nil - } else if err != nil && err != ErrNotFound { + } else if err != nil && !errors.Is(err, ErrNotFound) { return nil, fmt.Errorf("failed to get target from repo: %w", err) } // repo is not found, so search org target org := sep[0] orgTarget, err := ds.GetTargetByScope(ctx, org) - if err != nil || !orgTarget.CanReceiveJob() { + if err != nil { return nil, fmt.Errorf("failed to get target from organization: %w", err) } + if !orgTarget.CanReceiveJob() { + return nil, fmt.Errorf("target is not active") + } + return orgTarget, nil } diff --git a/pkg/metric/scrape_github.go b/pkg/metric/scrape_github.go index c34d437..1d79a08 100644 --- a/pkg/metric/scrape_github.go +++ b/pkg/metric/scrape_github.go @@ -65,7 +65,7 @@ func scrapePendingRuns(ctx context.Context, ds datastore.Datastore, ch chan<- pr installationID := value.(int64) target, err := datastore.SearchRepo(ctx, ds, repoName) if err != nil { - logger.Logf(false, "failed to get target by scope (%s): %+v", repoName, err) + logger.Logf(false, "failed to scrape pending run: failed to get target by scope (%s): %+v", repoName, err) return true } owner, repo := target.OwnerRepo() @@ -74,7 +74,7 @@ func scrapePendingRuns(ctx context.Context, ds datastore.Datastore, ch chan<- pr } runs, err := gh.ListRuns(owner, repo) if err != nil { - logger.Logf(false, "failed to list pending runs: %+v", err) + logger.Logf(false, "failed to scrape pending run: failed to list pending runs: %+v", err) return true }