@@ -4,10 +4,10 @@ import (
4
4
"fmt"
5
5
"strings"
6
6
7
- "github.com/golang/glog"
8
7
"github.com/nginxinc/kubernetes-ingress/internal/configs"
9
8
"github.com/nginxinc/kubernetes-ingress/internal/k8s/appprotect"
10
9
"github.com/nginxinc/kubernetes-ingress/internal/k8s/appprotectcommon"
10
+ nl "github.com/nginxinc/kubernetes-ingress/internal/logger"
11
11
conf_v1 "github.com/nginxinc/kubernetes-ingress/pkg/apis/configuration/v1"
12
12
api_v1 "k8s.io/api/core/v1"
13
13
networking "k8s.io/api/networking/v1"
@@ -19,19 +19,19 @@ func createAppProtectPolicyHandlers(lbc *LoadBalancerController) cache.ResourceE
19
19
handlers := cache.ResourceEventHandlerFuncs {
20
20
AddFunc : func (obj interface {}) {
21
21
pol := obj .(* unstructured.Unstructured )
22
- glog . V ( 3 ). Infof ( "Adding AppProtectPolicy: %v" , pol .GetName ())
22
+ nl . Debugf ( lbc . logger , "Adding AppProtectPolicy: %v" , pol .GetName ())
23
23
lbc .AddSyncQueue (pol )
24
24
},
25
25
UpdateFunc : func (oldObj , obj interface {}) {
26
26
oldPol := oldObj .(* unstructured.Unstructured )
27
27
newPol := obj .(* unstructured.Unstructured )
28
- different , err := areResourcesDifferent (oldPol , newPol )
28
+ different , err := areResourcesDifferent (lbc . logger , oldPol , newPol )
29
29
if err != nil {
30
- glog . V ( 3 ). Infof ( "Error when comparing policy %v" , err )
30
+ nl . Debugf ( lbc . logger , "Error when comparing policy %v" , err )
31
31
lbc .AddSyncQueue (newPol )
32
32
}
33
33
if different {
34
- glog . V ( 3 ). Infof ( "ApPolicy %v changed, syncing" , oldPol .GetName ())
34
+ nl . Debugf ( lbc . logger , "ApPolicy %v changed, syncing" , oldPol .GetName ())
35
35
lbc .AddSyncQueue (newPol )
36
36
}
37
37
},
@@ -46,19 +46,19 @@ func createAppProtectLogConfHandlers(lbc *LoadBalancerController) cache.Resource
46
46
handlers := cache.ResourceEventHandlerFuncs {
47
47
AddFunc : func (obj interface {}) {
48
48
conf := obj .(* unstructured.Unstructured )
49
- glog . V ( 3 ). Infof ( "Adding AppProtectLogConf: %v" , conf .GetName ())
49
+ nl . Debugf ( lbc . logger , "Adding AppProtectLogConf: %v" , conf .GetName ())
50
50
lbc .AddSyncQueue (conf )
51
51
},
52
52
UpdateFunc : func (oldObj , obj interface {}) {
53
53
oldConf := oldObj .(* unstructured.Unstructured )
54
54
newConf := obj .(* unstructured.Unstructured )
55
- different , err := areResourcesDifferent (oldConf , newConf )
55
+ different , err := areResourcesDifferent (lbc . logger , oldConf , newConf )
56
56
if err != nil {
57
- glog . V ( 3 ). Infof ( "Error when comparing LogConfs %v" , err )
57
+ nl . Debugf ( lbc . logger , "Error when comparing LogConfs %v" , err )
58
58
lbc .AddSyncQueue (newConf )
59
59
}
60
60
if different {
61
- glog . V ( 3 ). Infof ( "ApLogConf %v changed, syncing" , oldConf .GetName ())
61
+ nl . Debugf ( lbc . logger , "ApLogConf %v changed, syncing" , oldConf .GetName ())
62
62
lbc .AddSyncQueue (newConf )
63
63
}
64
64
},
@@ -73,19 +73,19 @@ func createAppProtectUserSigHandlers(lbc *LoadBalancerController) cache.Resource
73
73
handlers := cache.ResourceEventHandlerFuncs {
74
74
AddFunc : func (obj interface {}) {
75
75
sig := obj .(* unstructured.Unstructured )
76
- glog . V ( 3 ). Infof ( "Adding AppProtectUserSig: %v" , sig .GetName ())
76
+ nl . Debugf ( lbc . logger , "Adding AppProtectUserSig: %v" , sig .GetName ())
77
77
lbc .AddSyncQueue (sig )
78
78
},
79
79
UpdateFunc : func (oldObj , obj interface {}) {
80
80
oldSig := oldObj .(* unstructured.Unstructured )
81
81
newSig := obj .(* unstructured.Unstructured )
82
- different , err := areResourcesDifferent (oldSig , newSig )
82
+ different , err := areResourcesDifferent (lbc . logger , oldSig , newSig )
83
83
if err != nil {
84
- glog . V ( 3 ). Infof ( "Error when comparing UserSigs %v" , err )
84
+ nl . Debugf ( lbc . logger , "Error when comparing UserSigs %v" , err )
85
85
lbc .AddSyncQueue (newSig )
86
86
}
87
87
if different {
88
- glog . V ( 3 ). Infof ( "ApUserSig %v changed, syncing" , oldSig .GetName ())
88
+ nl . Debugf ( lbc . logger , "ApUserSig %v changed, syncing" , oldSig .GetName ())
89
89
lbc .AddSyncQueue (newSig )
90
90
}
91
91
},
@@ -125,7 +125,7 @@ func (nsi *namespacedInformer) addAppProtectUserSigHandler(handlers cache.Resour
125
125
126
126
func (lbc * LoadBalancerController ) syncAppProtectPolicy (task task ) {
127
127
key := task .Key
128
- glog . V ( 3 ). Infof ( "Syncing AppProtectPolicy %v" , key )
128
+ nl . Debugf ( lbc . logger , "Syncing AppProtectPolicy %v" , key )
129
129
130
130
var obj interface {}
131
131
var polExists bool
@@ -142,11 +142,11 @@ func (lbc *LoadBalancerController) syncAppProtectPolicy(task task) {
142
142
var problems []appprotect.Problem
143
143
144
144
if ! polExists {
145
- glog . V ( 2 ). Infof ( "Deleting AppProtectPolicy: %v\n " , key )
145
+ nl . Debugf ( lbc . logger , "Deleting AppProtectPolicy: %v\n " , key )
146
146
147
147
changes , problems = lbc .appProtectConfiguration .DeletePolicy (key )
148
148
} else {
149
- glog . V ( 2 ). Infof ( "Adding or Updating AppProtectPolicy: %v\n " , key )
149
+ nl . Debugf ( lbc . logger , "Adding or Updating AppProtectPolicy: %v\n " , key )
150
150
151
151
changes , problems = lbc .appProtectConfiguration .AddOrUpdatePolicy (obj .(* unstructured.Unstructured ))
152
152
}
@@ -157,7 +157,7 @@ func (lbc *LoadBalancerController) syncAppProtectPolicy(task task) {
157
157
158
158
func (lbc * LoadBalancerController ) syncAppProtectLogConf (task task ) {
159
159
key := task .Key
160
- glog . V ( 3 ). Infof ( "Syncing AppProtectLogConf %v" , key )
160
+ nl . Debugf ( lbc . logger , "Syncing AppProtectLogConf %v" , key )
161
161
var obj interface {}
162
162
var confExists bool
163
163
var err error
@@ -173,11 +173,11 @@ func (lbc *LoadBalancerController) syncAppProtectLogConf(task task) {
173
173
var problems []appprotect.Problem
174
174
175
175
if ! confExists {
176
- glog . V ( 2 ). Infof ( "Deleting AppProtectLogConf: %v\n " , key )
176
+ nl . Debugf ( lbc . logger , "Deleting AppProtectLogConf: %v\n " , key )
177
177
178
178
changes , problems = lbc .appProtectConfiguration .DeleteLogConf (key )
179
179
} else {
180
- glog . V ( 2 ). Infof ( "Adding or Updating AppProtectLogConf: %v\n " , key )
180
+ nl . Debugf ( lbc . logger , "Adding or Updating AppProtectLogConf: %v\n " , key )
181
181
182
182
changes , problems = lbc .appProtectConfiguration .AddOrUpdateLogConf (obj .(* unstructured.Unstructured ))
183
183
}
@@ -188,7 +188,7 @@ func (lbc *LoadBalancerController) syncAppProtectLogConf(task task) {
188
188
189
189
func (lbc * LoadBalancerController ) syncAppProtectUserSig (task task ) {
190
190
key := task .Key
191
- glog . V ( 3 ). Infof ( "Syncing AppProtectUserSig %v" , key )
191
+ nl . Debugf ( lbc . logger , "Syncing AppProtectUserSig %v" , key )
192
192
var obj interface {}
193
193
var sigExists bool
194
194
var err error
@@ -204,11 +204,11 @@ func (lbc *LoadBalancerController) syncAppProtectUserSig(task task) {
204
204
var problems []appprotect.Problem
205
205
206
206
if ! sigExists {
207
- glog . V ( 2 ). Infof ( "Deleting AppProtectUserSig: %v\n " , key )
207
+ nl . Debugf ( lbc . logger , "Deleting AppProtectUserSig: %v\n " , key )
208
208
209
209
change , problems = lbc .appProtectConfiguration .DeleteUserSig (key )
210
210
} else {
211
- glog . V ( 2 ). Infof ( "Adding or Updating AppProtectUserSig: %v\n " , key )
211
+ nl . Debugf ( lbc . logger , "Adding or Updating AppProtectUserSig: %v\n " , key )
212
212
213
213
change , problems = lbc .appProtectConfiguration .AddOrUpdateUserSig (obj .(* unstructured.Unstructured ))
214
214
}
@@ -353,7 +353,7 @@ func (lbc *LoadBalancerController) getAppProtectPolicy(ing *networking.Ingress)
353
353
}
354
354
355
355
func (lbc * LoadBalancerController ) processAppProtectChanges (changes []appprotect.Change ) {
356
- glog . V ( 3 ). Infof ( "Processing %v App Protect changes" , len (changes ))
356
+ nl . Debugf ( lbc . logger , "Processing %v App Protect changes" , len (changes ))
357
357
358
358
for _ , c := range changes {
359
359
if c .Op == appprotect .AddOrUpdate {
@@ -463,13 +463,13 @@ func (lbc *LoadBalancerController) processAppProtectUserSigChange(change appprot
463
463
464
464
warnings , err := lbc .configurator .RefreshAppProtectUserSigs (change .UserSigs , delPols , allIngExes , allMergeableIngresses , allVsExes )
465
465
if err != nil {
466
- glog .Errorf ("Error when refreshing App Protect Policy User defined signatures: %v" , err )
466
+ nl .Errorf (lbc . logger , "Error when refreshing App Protect Policy User defined signatures: %v" , err )
467
467
}
468
468
lbc .updateResourcesStatusAndEvents (allResources , warnings , err )
469
469
}
470
470
471
471
func (lbc * LoadBalancerController ) processAppProtectProblems (problems []appprotect.Problem ) {
472
- glog . V ( 3 ). Infof ( "Processing %v App Protect problems" , len (problems ))
472
+ nl . Debugf ( lbc . logger , "Processing %v App Protect problems" , len (problems ))
473
473
474
474
for _ , p := range problems {
475
475
eventType := api_v1 .EventTypeWarning
@@ -479,7 +479,7 @@ func (lbc *LoadBalancerController) processAppProtectProblems(problems []appprote
479
479
480
480
func (lbc * LoadBalancerController ) cleanupUnwatchedAppWafResources (nsi * namespacedInformer ) {
481
481
for _ , obj := range nsi .appProtectPolicyLister .List () {
482
- glog . V ( 3 ). Infof ( "Cleaning up unwatched appprotect policies in namespace: %v" , nsi .namespace )
482
+ nl . Debugf ( lbc . logger , "Cleaning up unwatched appprotect policies in namespace: %v" , nsi .namespace )
483
483
appPol := obj .((* unstructured.Unstructured ))
484
484
namespace := appPol .GetNamespace ()
485
485
name := appPol .GetName ()
@@ -489,7 +489,7 @@ func (lbc *LoadBalancerController) cleanupUnwatchedAppWafResources(nsi *namespac
489
489
lbc .processAppProtectProblems (problems )
490
490
}
491
491
for _ , obj := range nsi .appProtectLogConfLister .List () {
492
- glog . V ( 3 ). Infof ( "Cleaning up unwatched approtect logconfs in namespace: %v" , nsi .namespace )
492
+ nl . Debugf ( lbc . logger , "Cleaning up unwatched approtect logconfs in namespace: %v" , nsi .namespace )
493
493
appLogConf := obj .((* unstructured.Unstructured ))
494
494
namespace := appLogConf .GetNamespace ()
495
495
name := appLogConf .GetName ()
@@ -499,7 +499,7 @@ func (lbc *LoadBalancerController) cleanupUnwatchedAppWafResources(nsi *namespac
499
499
lbc .processAppProtectProblems (problems )
500
500
}
501
501
for _ , obj := range nsi .appProtectUserSigLister .List () {
502
- glog . V ( 3 ). Infof ( "Cleaning up unwatched usersigs in namespace: %v" , nsi .namespace )
502
+ nl . Debugf ( lbc . logger , "Cleaning up unwatched usersigs in namespace: %v" , nsi .namespace )
503
503
appUserSig := obj .((* unstructured.Unstructured ))
504
504
namespace := appUserSig .GetNamespace ()
505
505
name := appUserSig .GetName ()
0 commit comments