Skip to content

Commit 0c2b93a

Browse files
ratailoropenshift-merge-bot[bot]
authored andcommitted
Use GetLogger instead of log.FromContext
This change uses GetLogger function instead of direct use of log.FromContext.
1 parent 2ca2b27 commit 0c2b93a

8 files changed

+45
-45
lines changed

controllers/nova_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,7 +2046,7 @@ func (r *NovaReconciler) ensureTopLevelSecret(
20462046
func (r *NovaReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
20472047
requests := []reconcile.Request{}
20482048

2049-
l := log.FromContext(ctx).WithName("Controllers").WithName("Nova")
2049+
Log := r.GetLogger(ctx)
20502050

20512051
for _, field := range novaWatchFields {
20522052
crList := &novav1.NovaList{}
@@ -2056,12 +2056,12 @@ func (r *NovaReconciler) findObjectsForSrc(ctx context.Context, src client.Objec
20562056
}
20572057
err := r.Client.List(ctx, crList, listOps)
20582058
if err != nil {
2059-
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
2059+
Log.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
20602060
return requests
20612061
}
20622062

20632063
for _, item := range crList.Items {
2064-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
2064+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
20652065

20662066
requests = append(requests,
20672067
reconcile.Request{
@@ -2080,20 +2080,20 @@ func (r *NovaReconciler) findObjectsForSrc(ctx context.Context, src client.Objec
20802080
func (r *NovaReconciler) findObjectForSrc(ctx context.Context, src client.Object) []reconcile.Request {
20812081
requests := []reconcile.Request{}
20822082

2083-
l := log.FromContext(ctx).WithName("Controllers").WithName("Nova")
2083+
Log := r.GetLogger(ctx)
20842084

20852085
crList := &novav1.NovaList{}
20862086
listOps := &client.ListOptions{
20872087
Namespace: src.GetNamespace(),
20882088
}
20892089
err := r.Client.List(ctx, crList, listOps)
20902090
if err != nil {
2091-
l.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
2091+
Log.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
20922092
return requests
20932093
}
20942094

20952095
for _, item := range crList.Items {
2096-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
2096+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
20972097

20982098
requests = append(requests,
20992099
reconcile.Request{

controllers/novaapi_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ func getAPIServiceLabels() map[string]string {
911911
func (r *NovaAPIReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
912912
requests := []reconcile.Request{}
913913

914-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaAPI")
914+
Log := r.GetLogger(ctx)
915915

916916
for _, field := range apiWatchFields {
917917
crList := &novav1.NovaAPIList{}
@@ -921,12 +921,12 @@ func (r *NovaAPIReconciler) findObjectsForSrc(ctx context.Context, src client.Ob
921921
}
922922
err := r.Client.List(ctx, crList, listOps)
923923
if err != nil {
924-
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
924+
Log.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
925925
return requests
926926
}
927927

928928
for _, item := range crList.Items {
929-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
929+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
930930

931931
requests = append(requests,
932932
reconcile.Request{
@@ -945,7 +945,7 @@ func (r *NovaAPIReconciler) findObjectsForSrc(ctx context.Context, src client.Ob
945945
func (r *NovaAPIReconciler) findObjectsWithAppSelectorLabelInNamespace(ctx context.Context, src client.Object) []reconcile.Request {
946946
requests := []reconcile.Request{}
947947

948-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaAPI")
948+
Log := r.GetLogger(ctx)
949949

950950
// if the endpoint has the service label and its in our endpointList, reconcile the CR in the namespace
951951
if svc, ok := src.GetLabels()[common.AppSelector]; ok && util.StringInSlice(svc, endpointList) {
@@ -955,12 +955,12 @@ func (r *NovaAPIReconciler) findObjectsWithAppSelectorLabelInNamespace(ctx conte
955955
}
956956
err := r.Client.List(ctx, crList, listOps)
957957
if err != nil {
958-
l.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
958+
Log.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
959959
return requests
960960
}
961961

962962
for _, item := range crList.Items {
963-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
963+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
964964

965965
requests = append(requests,
966966
reconcile.Request{

controllers/novacell_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ func (r *NovaCellReconciler) getVNCProxyURL(
850850
func (r *NovaCellReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
851851
requests := []reconcile.Request{}
852852

853-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaCell")
853+
Log := r.GetLogger(ctx)
854854

855855
for _, field := range cellWatchFields {
856856
crList := &novav1.NovaCellList{}
@@ -860,12 +860,12 @@ func (r *NovaCellReconciler) findObjectsForSrc(ctx context.Context, src client.O
860860
}
861861
err := r.Client.List(ctx, crList, listOps)
862862
if err != nil {
863-
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
863+
Log.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
864864
return requests
865865
}
866866

867867
for _, item := range crList.Items {
868-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
868+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
869869

870870
requests = append(requests,
871871
reconcile.Request{

controllers/novacompute_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ func getComputeServiceLabels(cell string) map[string]string {
514514
func (r *NovaComputeReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
515515
requests := []reconcile.Request{}
516516

517-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaCompute")
517+
Log := r.GetLogger(ctx)
518518

519519
for _, field := range cmpWatchFields {
520520
crList := &novav1.NovaComputeList{}
@@ -524,12 +524,12 @@ func (r *NovaComputeReconciler) findObjectsForSrc(ctx context.Context, src clien
524524
}
525525
err := r.Client.List(ctx, crList, listOps)
526526
if err != nil {
527-
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
527+
Log.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
528528
return requests
529529
}
530530

531531
for _, item := range crList.Items {
532-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
532+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
533533

534534
requests = append(requests,
535535
reconcile.Request{
@@ -548,7 +548,7 @@ func (r *NovaComputeReconciler) findObjectsForSrc(ctx context.Context, src clien
548548
func (r *NovaComputeReconciler) findObjectsWithAppSelectorLabelInNamespace(ctx context.Context, src client.Object) []reconcile.Request {
549549
requests := []reconcile.Request{}
550550

551-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaCompute")
551+
Log := r.GetLogger(ctx)
552552

553553
// if the endpoint has the service label and its in our endpointList, reconcile the CR in the namespace
554554
if svc, ok := src.GetLabels()[common.AppSelector]; ok && util.StringInSlice(svc, endpointList) {
@@ -558,12 +558,12 @@ func (r *NovaComputeReconciler) findObjectsWithAppSelectorLabelInNamespace(ctx c
558558
}
559559
err := r.Client.List(ctx, crList, listOps)
560560
if err != nil {
561-
l.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
561+
Log.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
562562
return requests
563563
}
564564

565565
for _, item := range crList.Items {
566-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
566+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
567567

568568
requests = append(requests,
569569
reconcile.Request{

controllers/novaconductor_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ func (r *NovaConductorReconciler) cleanServiceFromNovaDb(
686686
func (r *NovaConductorReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
687687
requests := []reconcile.Request{}
688688

689-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaConductor")
689+
Log := r.GetLogger(ctx)
690690

691691
for _, field := range cdWatchFields {
692692
crList := &novav1.NovaConductorList{}
@@ -696,12 +696,12 @@ func (r *NovaConductorReconciler) findObjectsForSrc(ctx context.Context, src cli
696696
}
697697
err := r.Client.List(ctx, crList, listOps)
698698
if err != nil {
699-
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
699+
Log.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
700700
return requests
701701
}
702702

703703
for _, item := range crList.Items {
704-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
704+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
705705

706706
requests = append(requests,
707707
reconcile.Request{
@@ -720,7 +720,7 @@ func (r *NovaConductorReconciler) findObjectsForSrc(ctx context.Context, src cli
720720
func (r *NovaConductorReconciler) findObjectsWithAppSelectorLabelInNamespace(ctx context.Context, src client.Object) []reconcile.Request {
721721
requests := []reconcile.Request{}
722722

723-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaConductor")
723+
Log := r.GetLogger(ctx)
724724

725725
// if the endpoint has the service label and its in our endpointList, reconcile the CR in the namespace
726726
if svc, ok := src.GetLabels()[common.AppSelector]; ok && util.StringInSlice(svc, endpointList) {
@@ -730,12 +730,12 @@ func (r *NovaConductorReconciler) findObjectsWithAppSelectorLabelInNamespace(ctx
730730
}
731731
err := r.Client.List(ctx, crList, listOps)
732732
if err != nil {
733-
l.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
733+
Log.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
734734
return requests
735735
}
736736

737737
for _, item := range crList.Items {
738-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
738+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
739739

740740
requests = append(requests,
741741
reconcile.Request{

controllers/novametadata_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ func (r *NovaMetadataReconciler) generateNeutronConfigs(
900900
func (r *NovaMetadataReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
901901
requests := []reconcile.Request{}
902902

903-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaMetadata")
903+
Log := r.GetLogger(ctx)
904904

905905
for _, field := range metaWatchFields {
906906
crList := &novav1.NovaMetadataList{}
@@ -910,12 +910,12 @@ func (r *NovaMetadataReconciler) findObjectsForSrc(ctx context.Context, src clie
910910
}
911911
err := r.Client.List(ctx, crList, listOps)
912912
if err != nil {
913-
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
913+
Log.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
914914
return requests
915915
}
916916

917917
for _, item := range crList.Items {
918-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
918+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
919919

920920
requests = append(requests,
921921
reconcile.Request{
@@ -934,7 +934,7 @@ func (r *NovaMetadataReconciler) findObjectsForSrc(ctx context.Context, src clie
934934
func (r *NovaMetadataReconciler) findObjectsWithAppSelectorLabelInNamespace(ctx context.Context, src client.Object) []reconcile.Request {
935935
requests := []reconcile.Request{}
936936

937-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaMetadata")
937+
Log := r.GetLogger(ctx)
938938

939939
// if the endpoint has the service label and its in our endpointList, reconcile the CR in the namespace
940940
if svc, ok := src.GetLabels()[common.AppSelector]; ok && util.StringInSlice(svc, endpointList) {
@@ -944,12 +944,12 @@ func (r *NovaMetadataReconciler) findObjectsWithAppSelectorLabelInNamespace(ctx
944944
}
945945
err := r.Client.List(ctx, crList, listOps)
946946
if err != nil {
947-
l.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
947+
Log.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
948948
return requests
949949
}
950950

951951
for _, item := range crList.Items {
952-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
952+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
953953

954954
requests = append(requests,
955955
reconcile.Request{

controllers/novanovncproxy_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ func getNoVNCProxyServiceLabels(cell string) map[string]string {
765765
func (r *NovaNoVNCProxyReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
766766
requests := []reconcile.Request{}
767767

768-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaNoVNCProxy")
768+
Log := r.GetLogger(ctx)
769769

770770
for _, field := range noVNCProxyWatchFields {
771771
crList := &novav1.NovaNoVNCProxyList{}
@@ -775,12 +775,12 @@ func (r *NovaNoVNCProxyReconciler) findObjectsForSrc(ctx context.Context, src cl
775775
}
776776
err := r.Client.List(ctx, crList, listOps)
777777
if err != nil {
778-
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
778+
Log.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
779779
return requests
780780
}
781781

782782
for _, item := range crList.Items {
783-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
783+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
784784

785785
requests = append(requests,
786786
reconcile.Request{
@@ -799,7 +799,7 @@ func (r *NovaNoVNCProxyReconciler) findObjectsForSrc(ctx context.Context, src cl
799799
func (r *NovaNoVNCProxyReconciler) findObjectsWithAppSelectorLabelInNamespace(ctx context.Context, src client.Object) []reconcile.Request {
800800
requests := []reconcile.Request{}
801801

802-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaNoVNCProxy")
802+
Log := r.GetLogger(ctx)
803803

804804
// if the endpoint has the service label and its in our endpointList, reconcile the CR in the namespace
805805
if svc, ok := src.GetLabels()[common.AppSelector]; ok && util.StringInSlice(svc, endpointList) {
@@ -809,12 +809,12 @@ func (r *NovaNoVNCProxyReconciler) findObjectsWithAppSelectorLabelInNamespace(ct
809809
}
810810
err := r.Client.List(ctx, crList, listOps)
811811
if err != nil {
812-
l.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
812+
Log.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
813813
return requests
814814
}
815815

816816
for _, item := range crList.Items {
817-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
817+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
818818

819819
requests = append(requests,
820820
reconcile.Request{

controllers/novascheduler_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func (r *NovaSchedulerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
333333
func (r *NovaSchedulerReconciler) findObjectsForSrc(ctx context.Context, src client.Object) []reconcile.Request {
334334
requests := []reconcile.Request{}
335335

336-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaScheduler")
336+
Log := r.GetLogger(ctx)
337337

338338
for _, field := range schedulerWatchFields {
339339
crList := &novav1.NovaSchedulerList{}
@@ -343,12 +343,12 @@ func (r *NovaSchedulerReconciler) findObjectsForSrc(ctx context.Context, src cli
343343
}
344344
err := r.Client.List(ctx, crList, listOps)
345345
if err != nil {
346-
l.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
346+
Log.Error(err, fmt.Sprintf("listing %s for field: %s - %s", crList.GroupVersionKind().Kind, field, src.GetNamespace()))
347347
return requests
348348
}
349349

350350
for _, item := range crList.Items {
351-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
351+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
352352

353353
requests = append(requests,
354354
reconcile.Request{
@@ -367,7 +367,7 @@ func (r *NovaSchedulerReconciler) findObjectsForSrc(ctx context.Context, src cli
367367
func (r *NovaSchedulerReconciler) findObjectsWithAppSelectorLabelInNamespace(ctx context.Context, src client.Object) []reconcile.Request {
368368
requests := []reconcile.Request{}
369369

370-
l := log.FromContext(ctx).WithName("Controllers").WithName("NovaScheduler")
370+
Log := r.GetLogger(ctx)
371371

372372
// if the endpoint has the service label and its in our endpointList, reconcile the CR in the namespace
373373
if svc, ok := src.GetLabels()[common.AppSelector]; ok && util.StringInSlice(svc, endpointList) {
@@ -377,12 +377,12 @@ func (r *NovaSchedulerReconciler) findObjectsWithAppSelectorLabelInNamespace(ctx
377377
}
378378
err := r.Client.List(ctx, crList, listOps)
379379
if err != nil {
380-
l.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
380+
Log.Error(err, fmt.Sprintf("listing %s for namespace: %s", crList.GroupVersionKind().Kind, src.GetNamespace()))
381381
return requests
382382
}
383383

384384
for _, item := range crList.Items {
385-
l.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
385+
Log.Info(fmt.Sprintf("input source %s changed, reconcile: %s - %s", src.GetName(), item.GetName(), item.GetNamespace()))
386386

387387
requests = append(requests,
388388
reconcile.Request{

0 commit comments

Comments
 (0)