Skip to content

Commit 5c05a05

Browse files
authored
Merge pull request #426 from chmill-zz/reduce-log-verbosity
Move per-reconcile and per-resource log messages to V(2)
2 parents 8710291 + 070af8d commit 5c05a05

7 files changed

Lines changed: 12 additions & 12 deletions

File tree

pkg/patterns/addon/pkg/loaders/fs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (c *ManifestLoader) ResolveManifest(ctx context.Context, object runtime.Obj
105105

106106
log.WithValues("channel", channelName).WithValues("version", id).Info("resolved version from channel")
107107
} else {
108-
log.WithValues("version", version).Info("using specified version")
108+
log.WithValues("version", version).V(2).Info("using specified version")
109109
}
110110
s := make(map[string]string)
111111
s, err = c.repo.LoadManifest(ctx, componentName, id)

pkg/patterns/addon/pkg/loaders/git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (r *GitRepository) LoadManifest(ctx context.Context, packageName string, id
6666
}
6767

6868
log := log.FromContext(ctx)
69-
log.WithValues("package", packageName).Info("loading package")
69+
log.WithValues("package", packageName).V(2).Info("loading package")
7070

7171
var filePath string
7272
if r.subDir == "" {

pkg/patterns/addon/pkg/loaders/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (r *HTTPRepository) LoadManifest(ctx context.Context, packageName string, i
7474
}
7575

7676
log := log.FromContext(ctx)
77-
log.WithValues("package", packageName).Info("loading package")
77+
log.WithValues("package", packageName).V(2).Info("loading package")
7878

7979
p := r.makeURL("packages", packageName, id, "manifest.yaml")
8080
b, err := r.readURL(ctx, p)

pkg/patterns/addon/pkg/loaders/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (r *FSRepository) LoadManifest(ctx context.Context, packageName string, id
121121
}
122122

123123
log := log.FromContext(ctx)
124-
log.WithValues("package", packageName).Info("loading package")
124+
log.WithValues("package", packageName).V(2).Info("loading package")
125125

126126
dirPath := filepath.Join(r.basedir, "packages", packageName, id)
127127
filesPath, err := os.ReadDir(dirPath)

pkg/patterns/addon/pkg/status/kstatus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (k *kstatusAggregator) BuildStatus(ctx context.Context, info *declarative.S
131131
log.Error(err, "error getting status of resource")
132132
statusMap[status.UnknownStatus] = true
133133
} else if res != nil {
134-
log.WithValues("status", res.Status).WithValues("message", res.Message).Info("Got status of resource:")
134+
log.WithValues("status", res.Status).WithValues("message", res.Message).V(2).Info("Got status of resource:")
135135
statusMap[res.Status] = true
136136
} else {
137137
log.Info("resource status was nil")

pkg/patterns/declarative/pkg/watch/dynamic.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func (w *dynamicKindWatch) watchUntilClosed(ctx context.Context, eventTarget met
198198
return
199199
}
200200

201-
log.WithValues("kind", w.GVK.String()).WithValues("namespace", w.FilterNamespace).WithValues("labels", options.LabelSelector).Info("watch began")
201+
log.WithValues("kind", w.GVK.String()).WithValues("namespace", w.FilterNamespace).WithValues("labels", options.LabelSelector).V(2).Info("watch began")
202202

203203
// Always clean up watchers
204204
defer events.Stop()
@@ -231,9 +231,9 @@ func (w *dynamicKindWatch) watchUntilClosed(ctx context.Context, eventTarget met
231231
w.lastRV[key] = rv
232232
}
233233

234-
log.WithValues("type", clientEvent.Type).WithValues("kind", w.GVK.String()).WithValues("name", key.Name, "namespace", key.Namespace).Info("broadcasting event")
234+
log.WithValues("type", clientEvent.Type).WithValues("kind", w.GVK.String()).WithValues("name", key.Name, "namespace", key.Namespace).V(2).Info("broadcasting event")
235235
w.events <- event.GenericEvent{Object: clientObject{Object: clientEvent.Object, ObjectMeta: &eventTarget}}
236236
}
237237

238-
log.WithValues("kind", w.GVK.String()).WithValues("namespace", w.FilterNamespace).WithValues("labels", options.LabelSelector).Info("watch closed")
238+
log.WithValues("kind", w.GVK.String()).WithValues("namespace", w.FilterNamespace).WithValues("labels", options.LabelSelector).V(2).Info("watch closed")
239239
}

pkg/patterns/declarative/reconciler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (r *Reconciler) updateStatus(ctx context.Context, original DeclarativeObjec
289289

290290
func (r *Reconciler) reconcileExists(ctx context.Context, name types.NamespacedName, instance DeclarativeObject) (*StatusInfo, error) {
291291
log := log.FromContext(ctx)
292-
log.WithValues("object", name.String()).Info("reconciling")
292+
log.WithValues("object", name.String()).V(2).Info("reconciling")
293293

294294
statusInfo := &StatusInfo{
295295
Subject: instance,
@@ -311,7 +311,7 @@ func (r *Reconciler) reconcileExists(ctx context.Context, name types.NamespacedN
311311
log.Error(err, "flattening list objects")
312312
return statusInfo, fmt.Errorf("error flattening list objects: %w", err)
313313
}
314-
log.WithValues("objects", fmt.Sprintf("%d", len(objects.Items))).Info("built deployment objects")
314+
log.WithValues("objects", fmt.Sprintf("%d", len(objects.Items))).V(2).Info("built deployment objects")
315315
statusInfo.Manifest = objects
316316

317317
if r.options.status != nil {
@@ -680,7 +680,7 @@ func (r *Reconciler) setNamespaces(ctx context.Context, instance DeclarativeObje
680680
}
681681

682682
log := log.FromContext(ctx)
683-
log.WithValues("namespace", ns).Info("setting namespace")
683+
log.WithValues("namespace", ns).V(2).Info("setting namespace")
684684

685685
for _, o := range objects.Items {
686686
if o.GetNamespace() != "" {
@@ -706,7 +706,7 @@ func (r *Reconciler) injectOwnerRef(ctx context.Context, instance DeclarativeObj
706706
}
707707

708708
log := log.FromContext(ctx)
709-
log.WithValues("object", fmt.Sprintf("%s/%s", instance.GetName(), instance.GetNamespace())).Info("injecting owner references")
709+
log.WithValues("object", fmt.Sprintf("%s/%s", instance.GetName(), instance.GetNamespace())).V(2).Info("injecting owner references")
710710

711711
for _, o := range objects.Items {
712712
owner, err := r.options.ownerFn(ctx, instance, *o, *objects)

0 commit comments

Comments
 (0)