Skip to content

Commit be1c284

Browse files
committed
Set verbosity level for debug logs
In order to be able to filter debug logs from other info logs, we should use verbosity level. Zap used level 1 (-1 actually) for debug.
1 parent 2992026 commit be1c284

File tree

5 files changed

+33
-31
lines changed

5 files changed

+33
-31
lines changed

controllers/amphoracontroller_controller.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,32 +187,32 @@ func (r *OctaviaAmphoraControllerReconciler) Reconcile(ctx context.Context, req
187187
func (r *OctaviaAmphoraControllerReconciler) reconcileDelete(ctx context.Context, instance *octaviav1.OctaviaAmphoraController,
188188
helper *helper.Helper) (ctrl.Result, error) {
189189
Log := r.GetLogger(ctx)
190-
Log.Info("Reconciling Service delete")
190+
Log.V(1).Info("Reconciling Service delete")
191191

192192
controllerutil.RemoveFinalizer(instance, helper.GetFinalizer())
193193

194-
Log.Info("Reconciled Service delete successfully")
194+
Log.V(1).Info("Reconciled Service delete successfully")
195195
return ctrl.Result{}, nil
196196
}
197197

198198
func (r *OctaviaAmphoraControllerReconciler) reconcileUpdate(ctx context.Context) (ctrl.Result, error) {
199199
Log := r.GetLogger(ctx)
200-
Log.Info("Reconciling Service update")
201-
Log.Info("Reconciled Service update successfully")
200+
Log.V(1).Info("Reconciling Service update")
201+
Log.V(1).Info("Reconciled Service update successfully")
202202
return ctrl.Result{}, nil
203203
}
204204

205205
func (r *OctaviaAmphoraControllerReconciler) reconcileUpgrade(ctx context.Context) (ctrl.Result, error) {
206206
Log := r.GetLogger(ctx)
207-
Log.Info("Reconciling Service upgrade")
208-
Log.Info("Reconciled Service upgrade successfully")
207+
Log.V(1).Info("Reconciling Service upgrade")
208+
Log.V(1).Info("Reconciled Service upgrade successfully")
209209
return ctrl.Result{}, nil
210210
}
211211

212212
func (r *OctaviaAmphoraControllerReconciler) reconcileNormal(ctx context.Context, instance *octaviav1.OctaviaAmphoraController,
213213
helper *helper.Helper) (ctrl.Result, error) {
214214
Log := r.GetLogger(ctx)
215-
Log.Info("Reconciling Service")
215+
Log.V(1).Info("Reconciling Service")
216216

217217
// Prepare NetworkAttachments first, it must be done before generating the
218218
// configuration as the config uses IP addresses of the attachments.
@@ -459,6 +459,7 @@ func (r *OctaviaAmphoraControllerReconciler) reconcileNormal(ctx context.Context
459459
// We reached the end of the Reconcile, update the Ready condition based on
460460
// the sub conditions
461461
if instance.Status.Conditions.AllSubConditionIsTrue() {
462+
Log.V(1).Info("Setting Ready condition to true.")
462463
instance.Status.Conditions.MarkTrue(
463464
condition.ReadyCondition, condition.ReadyMessage)
464465
} else {
@@ -475,7 +476,7 @@ func (r *OctaviaAmphoraControllerReconciler) generateServiceConfigMaps(
475476
templateVars OctaviaTemplateVars,
476477
ospSecret *corev1.Secret,
477478
) error {
478-
r.Log.Info(fmt.Sprintf("generating service config map for %s (%s)", instance.Name, instance.Kind))
479+
r.Log.V(1).Info(fmt.Sprintf("generating service config map for %s (%s)", instance.Name, instance.Kind))
479480
cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(instance.ObjectMeta.Name), map[string]string{})
480481
db, err := mariadbv1.GetDatabaseByNameAndAccount(ctx, helper, octavia.DatabaseName, instance.Spec.DatabaseAccount, instance.Namespace)
481482
if err != nil {
@@ -666,8 +667,7 @@ func (r *OctaviaAmphoraControllerReconciler) generateServiceConfigMaps(
666667
return err
667668
}
668669

669-
r.Log.Info("Service config map generated")
670-
670+
r.Log.V(1).Info("Service config map generated")
671671
return nil
672672
}
673673

@@ -732,7 +732,7 @@ func listHealthManagerPods(name string, ns string, client kubernetes.Interface,
732732
LabelSelector: fmt.Sprintf("%s=%s", common.AppSelector, name),
733733
FieldSelector: "status.phase==Running",
734734
}
735-
log.Info(fmt.Sprintf("Listing pods using label selector %s and field selector %s", listOptions.LabelSelector, listOptions.FieldSelector))
735+
log.V(1).Info(fmt.Sprintf("Listing pods using label selector %s and field selector %s", listOptions.LabelSelector, listOptions.FieldSelector))
736736
pods, err := client.CoreV1().Pods(ns).List(context.Background(), listOptions)
737737
if err != nil {
738738
return nil, err

controllers/octavia_controller.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (r *OctaviaReconciler) reconcileInit(
299299
serviceAnnotations map[string]string,
300300
) (ctrl.Result, error) {
301301
Log := r.GetLogger(ctx)
302-
Log.Info("Reconciling Service init")
302+
Log.V(1).Info("Reconciling Service init")
303303

304304
// ConfigMap
305305
configMapVars := make(map[string]env.Setter)
@@ -428,35 +428,35 @@ func (r *OctaviaReconciler) reconcileInit(
428428

429429
// run octavia db sync - end
430430

431-
Log.Info("Reconciled Service init successfully")
431+
Log.V(1).Info("Reconciled Service init successfully")
432432
return ctrl.Result{}, nil
433433
}
434434

435435
func (r *OctaviaReconciler) reconcileUpdate(ctx context.Context) (ctrl.Result, error) {
436436
Log := r.GetLogger(ctx)
437-
Log.Info("Reconciling Service update")
437+
Log.V(1).Info("Reconciling Service update")
438438

439439
// TODO: should have minor update tasks if required
440440
// - delete dbsync hash from status to rerun it?
441441

442-
Log.Info("Reconciled Service update successfully")
442+
Log.V(1).Info("Reconciled Service update successfully")
443443
return ctrl.Result{}, nil
444444
}
445445

446446
func (r *OctaviaReconciler) reconcileUpgrade(ctx context.Context) (ctrl.Result, error) {
447447
Log := r.GetLogger(ctx)
448-
Log.Info("Reconciling Service upgrade")
448+
Log.V(1).Info("Reconciling Service upgrade")
449449

450450
// TODO: should have major version upgrade tasks
451451
// -delete dbsync hash from status to rerun it?
452452

453-
Log.Info("Reconciled Service upgrade successfully")
453+
Log.V(1).Info("Reconciled Service upgrade successfully")
454454
return ctrl.Result{}, nil
455455
}
456456

457457
func (r *OctaviaReconciler) reconcileNormal(ctx context.Context, instance *octaviav1.Octavia, helper *helper.Helper) (ctrl.Result, error) {
458458
Log := r.GetLogger(ctx)
459-
Log.Info("Reconciling Service")
459+
Log.V(1).Info("Reconciling Service")
460460

461461
// Service account, role, binding
462462
rbacRules := []rbacv1.PolicyRule{
@@ -831,7 +831,7 @@ func (r *OctaviaReconciler) reconcileNormal(ctx context.Context, instance *octav
831831
instance.Status.Conditions.MarkTrue(
832832
condition.ReadyCondition, condition.ReadyMessage)
833833
}
834-
Log.Info("Reconciled Service successfully")
834+
Log.V(1).Info("Reconciled Service successfully")
835835
return ctrl.Result{}, nil
836836
}
837837

controllers/octaviaapi_controller.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func (r *OctaviaAPIReconciler) reconcileInit(
361361
serviceLabels map[string]string,
362362
) (ctrl.Result, error) {
363363
Log := r.GetLogger(ctx)
364-
Log.Info("Reconciling Service init")
364+
Log.V(1).Info("Reconciling Service init")
365365
//
366366
// expose the service (create service and return the created endpoint URLs)
367367
//
@@ -526,36 +526,36 @@ func (r *OctaviaAPIReconciler) reconcileInit(
526526
instance.Status.Conditions.Set(c)
527527
}
528528

529-
Log.Info("Reconciled Service init successfully")
529+
Log.V(1).Info("Reconciled Service init successfully")
530530
return ctrlResult, nil
531531
}
532532

533533
func (r *OctaviaAPIReconciler) reconcileUpdate(ctx context.Context) (ctrl.Result, error) {
534534
Log := r.GetLogger(ctx)
535-
Log.Info("Reconciling Service update")
535+
Log.V(1).Info("Reconciling Service update")
536536

537537
// TODO: should have minor update tasks if required
538538
// - delete dbsync hash from status to rerun it?
539539

540-
Log.Info("Reconciled Service update successfully")
540+
Log.V(1).Info("Reconciled Service update successfully")
541541
return ctrl.Result{}, nil
542542
}
543543

544544
func (r *OctaviaAPIReconciler) reconcileUpgrade(ctx context.Context) (ctrl.Result, error) {
545545
Log := r.GetLogger(ctx)
546-
Log.Info("Reconciling Service upgrade")
546+
Log.V(1).Info("Reconciling Service upgrade")
547547

548548
// TODO: should have major version upgrade tasks
549549
// -delete dbsync hash from status to rerun it?
550550

551-
Log.Info("Reconciled Service upgrade successfully")
551+
Log.V(1).Info("Reconciled Service upgrade successfully")
552552
return ctrl.Result{}, nil
553553
}
554554

555555
// TODO(tweining): implement
556556
func (r *OctaviaAPIReconciler) reconcileNormal(ctx context.Context, instance *octaviav1.OctaviaAPI, helper *helper.Helper) (ctrl.Result, error) {
557557
Log := r.GetLogger(ctx)
558-
Log.Info("Reconciling Service")
558+
Log.V(1).Info("Reconciling Service")
559559

560560
// ConfigMap
561561
configMapVars := make(map[string]env.Setter)
@@ -836,7 +836,7 @@ func (r *OctaviaAPIReconciler) reconcileNormal(ctx context.Context, instance *oc
836836
instance.Status.Conditions.MarkTrue(
837837
condition.ReadyCondition, condition.ReadyMessage)
838838
}
839-
Log.Info("Reconciled Service successfully")
839+
Log.V(1).Info("Reconciled Service successfully")
840840
return ctrl.Result{}, nil
841841
}
842842

@@ -849,7 +849,7 @@ func (r *OctaviaAPIReconciler) generateServiceConfigMaps(
849849
envVars *map[string]env.Setter,
850850
) error {
851851
Log := r.GetLogger(ctx)
852-
Log.Info("Generating service config map")
852+
Log.V(1).Info("Generating service config map")
853853
//
854854
// create Configmap/Secret required for octavia input
855855
// - %-scripts configmap holding scripts to e.g. bootstrap the service
@@ -1004,7 +1004,7 @@ func (r *OctaviaAPIReconciler) generateServiceConfigMaps(
10041004
Log.Error(err, "unable to process config map")
10051005
return err
10061006
}
1007-
Log.Info("Service config map generated")
1007+
Log.V(1).Info("Service config map generated")
10081008

10091009
return nil
10101010
}

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ func main() {
8181
opts := zap.Options{
8282
Development: true,
8383
TimeEncoder: zapcore.ISO8601TimeEncoder,
84+
// Set level to 0 in order to hide all debug logs
85+
// Level: zapcore.Level(0),
8486
}
8587
opts.BindFlags(flag.CommandLine)
8688
flag.Parse()

pkg/octavia/lb_mgmt_network.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,12 +845,12 @@ func EnsureAmphoraManagementNetwork(
845845
return NetworkProvisioningSummary{}, err
846846
}
847847
if router != nil {
848-
log.Info("Router object found, reconciling")
848+
log.V(1).Info("Router object found, reconciling")
849849
router, err = reconcileRouter(client, router, providerNetwork, providerSubnet, networkParameters, log)
850850
if err != nil {
851851
return NetworkProvisioningSummary{}, err
852852
}
853-
log.Info(fmt.Sprintf("Reconciled router %s (%s)", router.Name, router.ID))
853+
log.V(1).Info(fmt.Sprintf("Reconciled router %s (%s)", router.Name, router.ID))
854854
} else {
855855
log.Info("Creating octavia provider router")
856856
enableSNAT := false

0 commit comments

Comments
 (0)