@@ -170,6 +170,8 @@ func (c *PodController) deletePod(obj interface{}) {
170
170
}
171
171
}
172
172
173
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
174
+ // klog.Infof("[POD DELETE EVENT] for %s in %s", podObj.Name, podObj.Namespace)
173
175
if isHostNetworkPod (podObj ) {
174
176
return
175
177
}
@@ -190,9 +192,15 @@ func (c *PodController) Run(stopCh <-chan struct{}) {
190
192
defer utilruntime .HandleCrash ()
191
193
defer c .workqueue .ShutDown ()
192
194
195
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
196
+ // klog.Infof("Starting Pod worker")
193
197
go wait .Until (c .runWorker , time .Second , stopCh )
194
198
199
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
200
+ // klog.Info("Started Pod workers")
195
201
<- stopCh
202
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
203
+ // klog.Info("Shutting down Pod workers")
196
204
}
197
205
198
206
func (c * PodController ) runWorker () {
@@ -230,6 +238,8 @@ func (c *PodController) processNextWorkItem() bool {
230
238
// Finally, if no error occurs we Forget this item so it does not
231
239
// get queued again until another change happens.
232
240
c .workqueue .Forget (obj )
241
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
242
+ // klog.Infof("Successfully synced '%s'", key)
233
243
return nil
234
244
}(obj )
235
245
if err != nil {
@@ -342,6 +352,10 @@ func (c *PodController) syncPod(key string) error {
342
352
}
343
353
344
354
func (c * PodController ) syncAddedPod (podObj * corev1.Pod ) error {
355
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
356
+ // klog.Infof("POD CREATING: [%s/%s/%s/%s/%+v/%s]", string(podObj.GetUID()), podObj.Namespace,
357
+ // podObj.Name, podObj.Spec.NodeName, podObj.Labels, podObj.Status.PodIP)
358
+
345
359
if ! util .IsIPV4 (podObj .Status .PodIP ) {
346
360
msg := fmt .Sprintf ("[syncAddedPod] warning: ADD POD [%s/%s/%s/%+v] ignored as the PodIP is not valid ipv4 address. ip: [%s]" , podObj .Namespace ,
347
361
podObj .Name , podObj .Spec .NodeName , podObj .Labels , podObj .Status .PodIP )
@@ -361,6 +375,8 @@ func (c *PodController) syncAddedPod(podObj *corev1.Pod) error {
361
375
namespaceSet := []* ipsets.IPSetMetadata {ipsets .NewIPSetMetadata (podObj .Namespace , ipsets .Namespace )}
362
376
363
377
// Add the pod ip information into namespace's ipset.
378
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
379
+ // klog.Infof("Adding pod %s (ip : %s) to ipset %s", podKey, podObj.Status.PodIP, podObj.Namespace)
364
380
if err = c .dp .AddToSets (namespaceSet , podMetadata ); err != nil {
365
381
return fmt .Errorf ("[syncAddedPod] Error: failed to add pod to namespace ipset with err: %w" , err )
366
382
}
@@ -378,13 +394,18 @@ func (c *PodController) syncAddedPod(podObj *corev1.Pod) error {
378
394
targetSetKeyValue := ipsets .NewIPSetMetadata (labelKeyValue , ipsets .KeyValueLabelOfPod )
379
395
allSets := []* ipsets.IPSetMetadata {targetSetKey , targetSetKeyValue }
380
396
397
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
398
+ // klog.Infof("Creating ipsets %+v and %+v if they do not exist", targetSetKey, targetSetKeyValue)
399
+ // klog.Infof("Adding pod %s (ip : %s) to ipset %s and %s", podKey, npmPodObj.PodIP, labelKey, labelKeyValue)
381
400
if err = c .dp .AddToSets (allSets , podMetadata ); err != nil {
382
401
return fmt .Errorf ("[syncAddedPod] Error: failed to add pod to label ipset with err: %w" , err )
383
402
}
384
403
npmPodObj .AppendLabels (map [string ]string {labelKey : labelVal }, common .AppendToExistingLabels )
385
404
}
386
405
387
406
// Add pod's named ports from its ipset.
407
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
408
+ // klog.Infof("Adding named port ipsets")
388
409
containerPorts := common .GetContainerPortList (podObj )
389
410
if err = c .manageNamedPortIpsets (containerPorts , podKey , npmPodObj .PodIP , podObj .Spec .NodeName , addNamedPort ); err != nil {
390
411
return fmt .Errorf ("[syncAddedPod] Error: failed to add pod to named port ipset with err: %w" , err )
@@ -418,6 +439,8 @@ func (c *PodController) syncAddAndUpdatePod(newPodObj *corev1.Pod) (metrics.Oper
418
439
c .npmNamespaceCache .Unlock ()
419
440
420
441
cachedNpmPod , exists := c .podMap [podKey ]
442
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
443
+ // klog.Infof("[syncAddAndUpdatePod] updating Pod with key %s", podKey)
421
444
// No cached npmPod exists. start adding the pod in a cache
422
445
if ! exists {
423
446
return metrics .CreateOp , c .syncAddedPod (newPodObj )
@@ -433,11 +456,18 @@ func (c *PodController) syncAddAndUpdatePod(newPodObj *corev1.Pod) (metrics.Oper
433
456
// NPM should clean up existing references of cached pod obj and its IP.
434
457
// then, re-add new pod obj.
435
458
if cachedNpmPod .PodIP != newPodObj .Status .PodIP {
459
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
460
+ // klog.Infof("Pod (Namespace:%s, Name:%s, newUid:%s), has cachedPodIp:%s which is different from PodIp:%s",
461
+ // newPodObj.Namespace, newPodObj.Name, string(newPodObj.UID), cachedNpmPod.PodIP, newPodObj.Status.PodIP)
436
462
463
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
464
+ // klog.Infof("Deleting cached Pod with key:%s first due to IP Mistmatch", podKey)
437
465
if er := c .cleanUpDeletedPod (podKey ); er != nil {
438
466
return metrics .UpdateOp , er
439
467
}
440
468
469
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
470
+ // klog.Infof("Adding back Pod with key:%s after IP Mistmatch", podKey)
441
471
return metrics .UpdateOp , c .syncAddedPod (newPodObj )
442
472
}
443
473
@@ -451,6 +481,8 @@ func (c *PodController) syncAddAndUpdatePod(newPodObj *corev1.Pod) (metrics.Oper
451
481
cachedPodMetadata := dataplane .NewPodMetadata (podKey , cachedNpmPod .PodIP , newPodMetadata .NodeName )
452
482
// Delete the pod from its label's ipset.
453
483
for _ , removeIPSetName := range deleteFromIPSets {
484
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
485
+ // klog.Infof("Deleting pod %s (ip : %s) from ipset %s", podKey, cachedNpmPod.PodIP, removeIPSetName)
454
486
455
487
var toRemoveSet * ipsets.IPSetMetadata
456
488
if util .IsKeyValueLabelSetName (removeIPSetName ) {
@@ -472,13 +504,18 @@ func (c *PodController) syncAddAndUpdatePod(newPodObj *corev1.Pod) (metrics.Oper
472
504
// Add the pod to its label's ipset.
473
505
for _ , addIPSetName := range addToIPSets {
474
506
507
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
508
+ // klog.Infof("Creating ipset %s if it doesn't already exist", addIPSetName)
509
+
475
510
var toAddSet * ipsets.IPSetMetadata
476
511
if util .IsKeyValueLabelSetName (addIPSetName ) {
477
512
toAddSet = ipsets .NewIPSetMetadata (addIPSetName , ipsets .KeyValueLabelOfPod )
478
513
} else {
479
514
toAddSet = ipsets .NewIPSetMetadata (addIPSetName , ipsets .KeyLabelOfPod )
480
515
}
481
516
517
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
518
+ // klog.Infof("Adding pod %s (ip : %s) to ipset %s", podKey, newPodObj.Status.PodIP, addIPSetName)
482
519
if err = c .dp .AddToSets ([]* ipsets.IPSetMetadata {toAddSet }, newPodMetadata ); err != nil {
483
520
return metrics .UpdateOp , fmt .Errorf ("[syncAddAndUpdatePod] Error: failed to add pod to label ipset with err: %w" , err )
484
521
}
@@ -521,6 +558,8 @@ func (c *PodController) syncAddAndUpdatePod(newPodObj *corev1.Pod) (metrics.Oper
521
558
522
559
// cleanUpDeletedPod cleans up all ipset associated with this pod
523
560
func (c * PodController ) cleanUpDeletedPod (cachedNpmPodKey string ) error {
561
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
562
+ // klog.Infof("[cleanUpDeletedPod] deleting Pod with key %s", cachedNpmPodKey)
524
563
// If cached npmPod does not exist, return nil
525
564
cachedNpmPod , exist := c .podMap [cachedNpmPodKey ]
526
565
if ! exist {
@@ -540,6 +579,8 @@ func (c *PodController) cleanUpDeletedPod(cachedNpmPodKey string) error {
540
579
// Get lists of podLabelKey and podLabelKey + podLavelValue ,and then start deleting them from ipsets
541
580
for labelKey , labelVal := range cachedNpmPod .Labels {
542
581
labelKeyValue := util .GetIpSetFromLabelKV (labelKey , labelVal )
582
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
583
+ // klog.Infof("Deleting pod %s (ip : %s) from ipsets %s and %s", cachedNpmPodKey, cachedNpmPod.PodIP, labelKey, labelKeyValue)
543
584
if err = c .dp .RemoveFromSets (
544
585
[]* ipsets.IPSetMetadata {
545
586
ipsets .NewIPSetMetadata (labelKey , ipsets .KeyLabelOfPod ),
@@ -572,6 +613,8 @@ func (c *PodController) manageNamedPortIpsets(portList []corev1.ContainerPort, p
572
613
return nil
573
614
}
574
615
for _ , port := range portList {
616
+ // TODO: Refactor non-error/warning klogs with Vap and set the following logs to "debug" level
617
+ // klog.Infof("port is %+v", port)
575
618
if port .Name == "" {
576
619
continue
577
620
}
0 commit comments