Skip to content

Commit efdd281

Browse files
authored
fix: [NPM] reduce log noise for reconcile periodic task (Azure#1209)
* fix: [NPM] reduce log noise for reconcile periodic task * removing info logs in pod controller * more info logs removed
1 parent 50a10c1 commit efdd281

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

npm/pkg/controlplane/controllers/v2/namespaceController.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,13 @@ func (nsc *NamespaceController) needSync(obj interface{}, event string) (string,
124124
return key, needSync
125125
}
126126

127-
klog.Infof("[NAMESPACE %s EVENT] for namespace [%s]", event, key)
128-
129127
needSync = true
130128
return key, needSync
131129
}
132130

133131
func (nsc *NamespaceController) addNamespace(obj interface{}) {
134132
key, needSync := nsc.needSync(obj, "ADD")
135133
if !needSync {
136-
klog.Infof("[NAMESPACE ADD EVENT] No need to sync this namespace [%s]", key)
137134
return
138135
}
139136
nsc.workqueue.Add(key)
@@ -142,15 +139,13 @@ func (nsc *NamespaceController) addNamespace(obj interface{}) {
142139
func (nsc *NamespaceController) updateNamespace(old, newns interface{}) {
143140
key, needSync := nsc.needSync(newns, "UPDATE")
144141
if !needSync {
145-
klog.Infof("[NAMESPACE UPDATE EVENT] No need to sync this namespace [%s]", key)
146142
return
147143
}
148144

149145
nsObj, _ := newns.(*corev1.Namespace)
150146
oldNsObj, ok := old.(*corev1.Namespace)
151147
if ok {
152148
if oldNsObj.ResourceVersion == nsObj.ResourceVersion {
153-
klog.Infof("[NAMESPACE UPDATE EVENT] Resourceversion is same for this namespace [%s]", key)
154149
return
155150
}
156151
}

npm/pkg/controlplane/controllers/v2/podController.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,11 @@ func (c *PodController) needSync(eventType string, obj interface{}) (string, boo
151151
return key, needSync
152152
}
153153

154-
klog.Infof("[POD %s EVENT] for %s in %s", eventType, podObj.Name, podObj.Namespace)
155-
156154
if !hasValidPodIP(podObj) {
157155
return key, needSync
158156
}
159157

160158
if isHostNetworkPod(podObj) {
161-
klog.Infof("[POD %s EVENT] HostNetwork POD IGNORED: [%s/%s/%s/%+v%s]",
162-
eventType, podObj.GetObjectMeta().GetUID(), podObj.Namespace, podObj.Name, podObj.Labels, podObj.Status.PodIP)
163159
return key, needSync
164160
}
165161

@@ -194,7 +190,6 @@ func (c *PodController) addPod(obj interface{}) {
194190
func (c *PodController) updatePod(old, newp interface{}) {
195191
key, needSync := c.needSync("UPDATE", newp)
196192
if !needSync {
197-
klog.Infof("[POD UPDATE EVENT] No need to sync this pod")
198193
return
199194
}
200195

@@ -205,7 +200,6 @@ func (c *PodController) updatePod(old, newp interface{}) {
205200
if oldPod.ResourceVersion == newPod.ResourceVersion {
206201
// Periodic resync will send update events for all known pods.
207202
// Two different versions of the same pods will always have different RVs.
208-
klog.Infof("[POD UPDATE EVENT] Two pods have the same RVs")
209203
return
210204
}
211205
}
@@ -234,7 +228,6 @@ func (c *PodController) deletePod(obj interface{}) {
234228

235229
klog.Infof("[POD DELETE EVENT] for %s in %s", podObj.Name, podObj.Namespace)
236230
if isHostNetworkPod(podObj) {
237-
klog.Infof("[POD DELETE EVENT] HostNetwork POD IGNORED: [%s/%s/%s/%+v%s]", podObj.UID, podObj.Namespace, podObj.Name, podObj.Labels, podObj.Status.PodIP)
238231
return
239232
}
240233

npm/pkg/dataplane/policies/chain-management_linux.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,18 @@ func (pMgr *PolicyManager) bootup(_ []string) error {
193193
// - creates the jump rule from FORWARD chain to AZURE-NPM chain (if it does not exist) and makes sure it's after the jumps to KUBE-FORWARD & KUBE-SERVICES chains (if they exist).
194194
// - cleans up stale policy chains. It can be forced to stop this process if reconcileManager.forceLock() is called.
195195
func (pMgr *PolicyManager) reconcile() {
196-
klog.Infof("repositioning azure chain jump rule")
197196
if err := pMgr.positionAzureChainJumpRule(); err != nil {
198197
klog.Errorf("failed to reconcile jump rule to Azure-NPM due to %s", err.Error())
199198
}
200199

201200
pMgr.reconcileManager.Lock()
202201
defer pMgr.reconcileManager.Unlock()
203202
staleChains := pMgr.staleChains.emptyAndGetAll()
203+
204+
if len(staleChains) == 0 {
205+
return
206+
}
207+
204208
klog.Infof("cleaning up these stale chains: %+v", staleChains)
205209
if err := pMgr.cleanupChains(staleChains); err != nil {
206210
klog.Errorf("failed to clean up old policy chains with the following error: %s", err.Error())

0 commit comments

Comments
 (0)