Skip to content

Commit 7590213

Browse files
committed
switch to structured logging
fix gitlog func update logging update tests logging update logging update logging switch to structured logging fix gitlog func update logging update tests logging update logging update logging switch to structured logging fix gitlog func update logging update tests logging update logging update logging Structured logging
1 parent 245302d commit 7590213

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

controllers/glance_controller.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type GlanceReconciler struct {
6464
Scheme *runtime.Scheme
6565
}
6666

67-
// getlogger returns a logger object with a prefix of "conroller.name" and aditional controller context fields
67+
// GetLogger returns a logger object with a prefix of "controller.name" and additional controller context fields
6868
func (r *GlanceReconciler) GetLogger(ctx context.Context) logr.Logger {
6969
return log.FromContext(ctx).WithName("Controllers").WithName("Glance")
7070
}
@@ -615,7 +615,10 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
615615
}
616616
if op != controllerutil.OperationResultNone {
617617
Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
618+
<<<<<<< HEAD
618619
Log.Info(fmt.Sprintf("StatefulSet %s successfully reconciled - operation: %s", instance.Name, string(op)))
620+
=======
621+
>>>>>>> e82dc49 (switch to structured logging)
619622
}
620623

621624
// It is possible that an earlier call to update the status has also set
@@ -646,7 +649,11 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
646649
return ctrl.Result{}, err
647650
}
648651
if op != controllerutil.OperationResultNone {
652+
<<<<<<< HEAD
649653
Log.Info(fmt.Sprintf("StatefulSet %s successfully reconciled - operation: %s", instance.Name, string(op)))
654+
=======
655+
Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
656+
>>>>>>> e82dc49 (switch to structured logging)
650657
}
651658

652659
// Mirror external GlanceAPI status' APIEndpoints to this parent CR
@@ -761,6 +768,7 @@ func (r *GlanceReconciler) generateServiceConfig(
761768
instance *glancev1.Glance,
762769
envVars *map[string]env.Setter,
763770
) error {
771+
Log := r.GetLogger(ctx)
764772
labels := labels.GetLabels(instance, labels.GetGroupLabel(glance.ServiceName), map[string]string{})
765773

766774
ospSecret, _, err := secret.GetSecret(ctx, h, instance.Spec.Secret, instance.Namespace)
@@ -781,11 +789,22 @@ func (r *GlanceReconciler) generateServiceConfig(
781789
// We set in the main 00-config-default.conf the image-cache bits that will
782790
// be used by CronJobs cleaner and pruner
783791
if len(instance.Spec.ImageCacheSize) > 0 {
792+
<<<<<<< HEAD
784793
// if ImageCacheSize is not a valid k8s Quantity, return an error
785794
cacheSize, err := resource.ParseQuantity(instance.Spec.ImageCacheSize)
786795
if err != nil {
787796
return err
788797
}
798+
=======
799+
// catch any panic generated by the MustParse function and report an
800+
// error
801+
defer func() {
802+
if err := recover(); err != nil {
803+
Log.Error(err.(error), "ImageCacheSize not valid: %s")
804+
}
805+
}()
806+
cacheSize := resource.MustParse(instance.Spec.ImageCacheSize)
807+
>>>>>>> e82dc49 (switch to structured logging)
789808
templateParameters["CacheEnabled"] = true
790809
templateParameters["CacheMaxSize"] = cacheSize.Value()
791810
templateParameters["ImageCacheDir"] = glance.ImageCacheDir

controllers/glanceapi_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ type GlanceAPIReconciler struct {
6767
Scheme *runtime.Scheme
6868
}
6969

70+
<<<<<<< HEAD
7071
// getlogger returns a logger object with a prefix of "conroller.name" and aditional controller context fields
72+
=======
73+
// GetLogger returns a logger object with a prefix of "controller.name" and additional controller context fields
74+
>>>>>>> e82dc49 (switch to structured logging)
7175
func (r *GlanceAPIReconciler) GetLogger(ctx context.Context) logr.Logger {
7276
return log.FromContext(ctx).WithName("Controllers").WithName("GlanceAPI")
7377
}

0 commit comments

Comments
 (0)