Skip to content

Commit a523aa8

Browse files
committed
feat(catalog/olm): add tracking ids to logging
this will help correlate logs for each sync loop
1 parent d726c53 commit a523aa8

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

pkg/controller/operators/catalog/operator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ func (o *Operator) syncCatalogSources(obj interface{}) (syncError error) {
338338

339339
logger := o.Log.WithFields(logrus.Fields{
340340
"source": catsrc.GetName(),
341+
"id": queueinformer.NewLoopID(),
341342
})
342343
logger.Debug("syncing catsrc")
343344
out := catsrc.DeepCopy()
@@ -515,6 +516,7 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
515516

516517
logger := o.Log.WithFields(logrus.Fields{
517518
"namespace": namespace,
519+
"id": queueinformer.NewLoopID(),
518520
})
519521

520522
// get the set of sources that should be used for resolution and best-effort get their connections working
@@ -820,6 +822,7 @@ func (o *Operator) syncInstallPlans(obj interface{}) (syncError error) {
820822
}
821823

822824
logger := o.Log.WithFields(logrus.Fields{
825+
"id": queueinformer.NewLoopID(),
823826
"ip": plan.GetName(),
824827
"namespace": plan.GetNamespace(),
825828
"phase": plan.Status.Phase,

pkg/controller/operators/olm/operator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ func (a *Operator) deleteClusterServiceVersion(obj interface{}) {
321321
}
322322

323323
logger := a.Log.WithFields(logrus.Fields{
324+
"id": queueinformer.NewLoopID(),
324325
"csv": clusterServiceVersion.GetName(),
325326
"namespace": clusterServiceVersion.GetNamespace(),
326327
"phase": clusterServiceVersion.Status.Phase,
@@ -351,6 +352,7 @@ func (a *Operator) deleteClusterServiceVersion(obj interface{}) {
351352

352353
func (a *Operator) removeDanglingChildCSVs(csv *v1alpha1.ClusterServiceVersion) error {
353354
logger := a.Log.WithFields(logrus.Fields{
355+
"id": queueinformer.NewLoopID(),
354356
"csv": csv.GetName(),
355357
"namespace": csv.GetNamespace(),
356358
"phase": csv.Status.Phase,
@@ -381,6 +383,7 @@ func (a *Operator) syncClusterServiceVersion(obj interface{}) (syncError error)
381383
}
382384

383385
logger := a.Log.WithFields(logrus.Fields{
386+
"id": queueinformer.NewLoopID(),
384387
"csv": clusterServiceVersion.GetName(),
385388
"namespace": clusterServiceVersion.GetNamespace(),
386389
"phase": clusterServiceVersion.Status.Phase,
@@ -476,6 +479,7 @@ func (a *Operator) operatorGroupForActiveCSV(logger *logrus.Entry, csv *v1alpha1
476479
// transitionCSVState moves the CSV status state machine along based on the current value and the current cluster state.
477480
func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v1alpha1.ClusterServiceVersion, syncError error) {
478481
logger := a.Log.WithFields(logrus.Fields{
482+
"id": queueinformer.NewLoopID(),
479483
"csv": in.GetName(),
480484
"namespace": in.GetNamespace(),
481485
"phase": in.Status.Phase,

pkg/lib/queueinformer/loop_id.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package queueinformer
2+
3+
import (
4+
"encoding/base64"
5+
"math/rand"
6+
)
7+
8+
func NewLoopID() string {
9+
len := 5
10+
buff := make([]byte, len)
11+
rand.Read(buff)
12+
str := base64.StdEncoding.EncodeToString(buff)
13+
return str[:len]
14+
}

0 commit comments

Comments
 (0)