Skip to content

Commit

Permalink
Add debug logs to track bundle
Browse files Browse the repository at this point in the history
Otherwise, the command is completely silent and difficult to debug.

Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
  • Loading branch information
lcarva committed Nov 3, 2023
1 parent 561f6bd commit 59a71ff
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ func (t *Tracker) addBundleRecord(record bundleRecord) {
var collection map[string][]bundleRecord
switch record.Collection {
case pipelineCollection:
log.Debugf("Adding record to the pipelines collection: %#v", record)
collection = t.PipelineBundles
case taskCollection:
log.Debugf("Adding record to the tasks collection: %#v", record)
collection = t.TaskBundles
default:
log.Warnf("Ignoring record with unexpected collection: %#v", record)
Expand Down Expand Up @@ -123,6 +125,7 @@ func Track(ctx context.Context, urls []string, input []byte, prune bool, freshen
}

if freshen {
log.Debug("Freshen is enabled")
imageRefs, err := inputBundleTags(ctx, t)
if err != nil {
return nil, err
Expand All @@ -133,6 +136,7 @@ func Track(ctx context.Context, urls []string, input []byte, prune bool, freshen

effective_on := effectiveOn()
for _, ref := range refs {
log.Debugf("Processing bundle %q", ref.String())
info, err := newBundleInfo(ctx, ref)
if err != nil {
return nil, err
Expand Down Expand Up @@ -190,9 +194,11 @@ func effectiveOn() time.Time {
// filterBundles applies filterRecords to PipelienBundles and TaskBundles.
func (t *Tracker) filterBundles(prune bool) {
for ref, records := range t.PipelineBundles {
log.Debugf("Filtering pipeline records for %q", ref)
t.PipelineBundles[ref] = filterRecords(records, prune)
}
for ref, records := range t.TaskBundles {
log.Debugf("Filtering task records for %q", ref)
t.TaskBundles[ref] = filterRecords(records, prune)
}
}
Expand Down Expand Up @@ -230,5 +236,9 @@ func filterRecords(records []bundleRecord, prune bool) []bundleRecord {
}
}

filteredCount := len(records) - len(relevant)
if filteredCount != 0 {
log.Debugf("Filtered %d records (prune=%t)", filteredCount, prune)
}

Check warning on line 242 in internal/tracker/tracker.go

View check run for this annotation

Codecov / codecov/patch

internal/tracker/tracker.go#L241-L242

Added lines #L241 - L242 were not covered by tests
return relevant
}

0 comments on commit 59a71ff

Please sign in to comment.