Skip to content

Commit

Permalink
chore: only log when required
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Jun 28, 2024
1 parent 847f840 commit 7989080
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions db/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ func updateCI(ctx api.ScrapeContext, result v1.ScrapeResult, ci, existing *model
result.Changes = []v1.ChangeResult{*changeResult}
if newChanges, _, orphanedChanges, err := extractChanges(ctx, &result, ci); err != nil {
return false, nil, err
} else {
} else if orphanedChanges > 0 {
logger.Warnf("orphaned changes found for existing cofig")
ctx.JobHistory().AddErrorf("%d changes were orphaned for config item: [%s/%s]", orphanedChanges, existing.ID, *existing.Name)
changes = append(changes, newChanges...)
}
Expand Down Expand Up @@ -344,8 +345,9 @@ func saveResults(ctx api.ScrapeContext, isPartialResultSet bool, results []v1.Sc
newConfigs, configsToUpdate, newChanges, changesToUpdate, orphanedChanges, err := extractConfigsAndChangesFromResults(ctx, startTime, isPartialResultSet, results)
if err != nil {
return fmt.Errorf("failed to extract configs & changes from results: %w", err)
} else if orphanedChanges > 0 {
ctx.JobHistory().AddErrorf("%d changes were orphaned for scraper: [%s/%s]", orphanedChanges, ctx.ScrapeConfig().Namespace, ctx.ScrapeConfig().Name)
}
ctx.JobHistory().AddErrorf("%d changes were orphaned for scraper: [%s/%s]", orphanedChanges, ctx.ScrapeConfig().Namespace, ctx.ScrapeConfig().Name)

ctx.Logger.V(2).Infof("%d new configs, %d configs to update, %d new changes & %d changes to update",
len(newConfigs), len(configsToUpdate), len(newChanges), len(changesToUpdate))
Expand Down

0 comments on commit 7989080

Please sign in to comment.