@@ -81,8 +81,7 @@ type DataPlane struct {
81
81
func NewDataPlane (nodeName string , ioShim * common.IOShim , cfg * Config , stopChannel <- chan struct {}) (* DataPlane , error ) {
82
82
metrics .InitializeAll ()
83
83
if util .IsWindowsDP () {
84
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
85
- // klog.Infof("[DataPlane] enabling AddEmptySetToLists for Windows")
84
+ klog .Infof ("[DataPlane] enabling AddEmptySetToLists for Windows" )
86
85
cfg .IPSetManagerCfg .AddEmptySetToLists = true
87
86
}
88
87
@@ -113,8 +112,7 @@ func NewDataPlane(nodeName string, ioShim *common.IOShim, cfg *Config, stopChann
113
112
return nil , ErrInvalidApplyConfig
114
113
}
115
114
} else {
116
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
117
- // klog.Info("[DataPlane] dataplane configured to NOT apply in background")
115
+ klog .Info ("[DataPlane] dataplane configured to NOT apply in background" )
118
116
dp .updatePodCache = newUpdatePodCache (1 )
119
117
}
120
118
@@ -152,8 +150,7 @@ func (dp *DataPlane) FinishBootupPhase() {
152
150
dp .applyInfo .Lock ()
153
151
defer dp .applyInfo .Unlock ()
154
152
155
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
156
- // klog.Infof("[DataPlane] finished bootup phase")
153
+ klog .Infof ("[DataPlane] finished bootup phase" )
157
154
dp .applyInfo .inBootupPhase = false
158
155
}
159
156
@@ -260,8 +257,7 @@ func (dp *DataPlane) AddToSets(setNames []*ipsets.IPSetMetadata, podMetadata *Po
260
257
}
261
258
262
259
if dp .shouldUpdatePod () && podMetadata .NodeName == dp .nodeName {
263
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
264
- // klog.Infof("[DataPlane] Updating Sets to Add for pod key %s", podMetadata.PodKey)
260
+ klog .Infof ("[DataPlane] Updating Sets to Add for pod key %s" , podMetadata .PodKey )
265
261
266
262
// lock updatePodCache while reading/modifying or setting the updatePod in the cache
267
263
dp .updatePodCache .Lock ()
@@ -283,8 +279,7 @@ func (dp *DataPlane) RemoveFromSets(setNames []*ipsets.IPSetMetadata, podMetadat
283
279
}
284
280
285
281
if dp .shouldUpdatePod () && podMetadata .NodeName == dp .nodeName {
286
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
287
- // klog.Infof("[DataPlane] Updating Sets to Remove for pod key %s", podMetadata.PodKey)
282
+ klog .Infof ("[DataPlane] Updating Sets to Remove for pod key %s" , podMetadata .PodKey )
288
283
289
284
// lock updatePodCache while reading/modifying or setting the updatePod in the cache
290
285
dp .updatePodCache .Lock ()
@@ -333,27 +328,23 @@ func (dp *DataPlane) ApplyDataPlane() error {
333
328
newCount := dp .applyInfo .numBatches
334
329
dp .applyInfo .Unlock ()
335
330
336
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
337
- // klog.Infof("[DataPlane] [%s] new batch count: %d", contextApplyDP, newCount)
331
+ klog .Infof ("[DataPlane] [%s] new batch count: %d" , contextApplyDP , newCount )
338
332
339
333
if newCount >= dp .ApplyMaxBatches {
340
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
341
- // klog.Infof("[DataPlane] [%s] applying now since reached maximum batch count: %d", contextApplyDP, newCount)
334
+ klog .Infof ("[DataPlane] [%s] applying now since reached maximum batch count: %d" , contextApplyDP , newCount )
342
335
return dp .applyDataPlaneNow (contextApplyDP )
343
336
}
344
337
345
338
return nil
346
339
}
347
340
348
341
func (dp * DataPlane ) applyDataPlaneNow (context string ) error {
349
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
350
- // klog.Infof("[DataPlane] [ApplyDataPlane] [%s] starting to apply ipsets", context)
342
+ klog .Infof ("[DataPlane] [ApplyDataPlane] [%s] starting to apply ipsets" , context )
351
343
err := dp .ipsetMgr .ApplyIPSets ()
352
344
if err != nil {
353
345
return fmt .Errorf ("[DataPlane] [%s] error while applying IPSets: %w" , context , err )
354
346
}
355
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
356
- // klog.Infof("[DataPlane] [ApplyDataPlane] [%s] finished applying ipsets", context)
347
+ klog .Infof ("[DataPlane] [ApplyDataPlane] [%s] finished applying ipsets" , context )
357
348
358
349
// see comment in RemovePolicy() for why this is here
359
350
dp .setRemovePolicyFailure (false )
@@ -374,8 +365,7 @@ func (dp *DataPlane) applyDataPlaneNow(context string) error {
374
365
}
375
366
dp .updatePodCache .Unlock ()
376
367
377
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
378
- // klog.Infof("[DataPlane] [ApplyDataPlane] [%s] refreshing endpoints before updating pods", context)
368
+ klog .Infof ("[DataPlane] [ApplyDataPlane] [%s] refreshing endpoints before updating pods" , context )
379
369
380
370
err := dp .refreshPodEndpoints ()
381
371
if err != nil {
@@ -384,16 +374,14 @@ func (dp *DataPlane) applyDataPlaneNow(context string) error {
384
374
return nil
385
375
}
386
376
387
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
388
- // klog.Infof("[DataPlane] [ApplyDataPlane] [%s] refreshed endpoints", context)
377
+ klog .Infof ("[DataPlane] [ApplyDataPlane] [%s] refreshed endpoints" , context )
389
378
390
379
// lock updatePodCache while driving goal state to kernel
391
380
// prevents another ApplyDataplane call from updating the same pods
392
381
dp .updatePodCache .Lock ()
393
382
defer dp .updatePodCache .Unlock ()
394
383
395
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
396
- // klog.Infof("[DataPlane] [ApplyDataPlane] [%s] starting to update pods", context)
384
+ klog .Infof ("[DataPlane] [ApplyDataPlane] [%s] starting to update pods" , context )
397
385
for ! dp .updatePodCache .isEmpty () {
398
386
pod := dp .updatePodCache .dequeue ()
399
387
if pod == nil {
@@ -411,16 +399,14 @@ func (dp *DataPlane) applyDataPlaneNow(context string) error {
411
399
}
412
400
}
413
401
414
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
415
- // klog.Infof("[DataPlane] [ApplyDataPlane] [%s] finished updating pods", context)
402
+ klog .Infof ("[DataPlane] [ApplyDataPlane] [%s] finished updating pods" , context )
416
403
}
417
404
return nil
418
405
}
419
406
420
407
// AddPolicy takes in a translated NPMNetworkPolicy object and applies on dataplane
421
408
func (dp * DataPlane ) AddPolicy (policy * policies.NPMNetworkPolicy ) error {
422
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
423
- // klog.Infof("[DataPlane] Add Policy called for %s", policy.PolicyKey)
409
+ klog .Infof ("[DataPlane] Add Policy called for %s" , policy .PolicyKey )
424
410
425
411
if ! dp .netPolInBackground {
426
412
return dp .addPolicies ([]* policies.NPMNetworkPolicy {policy })
@@ -434,12 +420,10 @@ func (dp *DataPlane) AddPolicy(policy *policies.NPMNetworkPolicy) error {
434
420
dp .netPolQueue .enqueue (policy )
435
421
newCount := dp .netPolQueue .len ()
436
422
437
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
438
- // klog.Infof("[DataPlane] [%s] new pending netpol count: %d", contextAddNetPol, newCount)
423
+ klog .Infof ("[DataPlane] [%s] new pending netpol count: %d" , contextAddNetPol , newCount )
439
424
440
425
if newCount >= dp .MaxPendingNetPols {
441
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
442
- // klog.Infof("[DataPlane] [%s] applying now since reached maximum batch count: %d", contextAddNetPol, newCount)
426
+ klog .Infof ("[DataPlane] [%s] applying now since reached maximum batch count: %d" , contextAddNetPol , newCount )
443
427
dp .addPoliciesWithRetry (contextAddNetPol )
444
428
}
445
429
return nil
@@ -449,14 +433,12 @@ func (dp *DataPlane) AddPolicy(policy *policies.NPMNetworkPolicy) error {
449
433
// The caller must lock netPolQueue.
450
434
func (dp * DataPlane ) addPoliciesWithRetry (context string ) {
451
435
netPols := dp .netPolQueue .dump ()
452
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
453
- // klog.Infof("[DataPlane] adding policies %+v", netPols)
436
+ klog .Infof ("[DataPlane] adding policies %+v" , netPols )
454
437
455
438
err := dp .addPolicies (netPols )
456
439
if err == nil {
457
440
// clear queue and return on success
458
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
459
- // klog.Infof("[DataPlane] [%s] added policies successfully", context)
441
+ klog .Infof ("[DataPlane] [%s] added policies successfully" , context )
460
442
dp .netPolQueue .clear ()
461
443
return
462
444
}
@@ -469,8 +451,7 @@ func (dp *DataPlane) addPoliciesWithRetry(context string) {
469
451
err = dp .addPolicies ([]* policies.NPMNetworkPolicy {netPol })
470
452
if err == nil {
471
453
// remove from queue on success
472
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
473
- // klog.Infof("[DataPlane] [%s] added policy successfully one at a time. policyKey: %s", context, netPol.PolicyKey)
454
+ klog .Infof ("[DataPlane] [%s] added policy successfully one at a time. policyKey: %s" , context , netPol .PolicyKey )
474
455
dp .netPolQueue .delete (netPol .PolicyKey )
475
456
} else {
476
457
// keep in queue on failure
@@ -488,8 +469,7 @@ func (dp *DataPlane) addPolicies(netPols []*policies.NPMNetworkPolicy) error {
488
469
}
489
470
490
471
if len (netPols ) == 0 {
491
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
492
- // klog.Infof("[DataPlane] expected to have at least one NetPol in dp.addPolicies()")
472
+ klog .Infof ("[DataPlane] expected to have at least one NetPol in dp.addPolicies()" )
493
473
return nil
494
474
}
495
475
@@ -533,8 +513,7 @@ func (dp *DataPlane) addPolicies(netPols []*policies.NPMNetworkPolicy) error {
533
513
// Create and add references for Rule IPSets
534
514
err = dp .createIPSetsAndReferences (netPol .RuleIPSets , netPol .PolicyKey , ipsets .NetPolType )
535
515
if err != nil {
536
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
537
- // klog.Infof("[DataPlane] error while adding Rule IPSet references: %s", err.Error())
516
+ klog .Infof ("[DataPlane] error while adding Rule IPSet references: %s" , err .Error ())
538
517
return fmt .Errorf ("[DataPlane] error while adding Rule IPSet references: %w" , err )
539
518
}
540
519
@@ -547,18 +526,15 @@ func (dp *DataPlane) addPolicies(netPols []*policies.NPMNetworkPolicy) error {
547
526
// increment batch and apply IPSets if needed
548
527
dp .applyInfo .numBatches ++
549
528
newCount := dp .applyInfo .numBatches
550
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
551
- // klog.Infof("[DataPlane] [%s] new batch count: %d", contextAddNetPolBootup, newCount)
529
+ klog .Infof ("[DataPlane] [%s] new batch count: %d" , contextAddNetPolBootup , newCount )
552
530
if newCount >= dp .ApplyMaxBatches {
553
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
554
- // klog.Infof("[DataPlane] [%s] applying now since reached maximum batch count: %d", contextAddNetPolBootup, newCount)
555
- // klog.Infof("[DataPlane] [%s] starting to apply ipsets", contextAddNetPolBootup)
531
+ klog .Infof ("[DataPlane] [%s] applying now since reached maximum batch count: %d" , contextAddNetPolBootup , newCount )
532
+ klog .Infof ("[DataPlane] [%s] starting to apply ipsets" , contextAddNetPolBootup )
556
533
err = dp .ipsetMgr .ApplyIPSets ()
557
534
if err != nil {
558
535
return fmt .Errorf ("[DataPlane] [%s] error while applying IPSets: %w" , contextAddNetPolBootup , err )
559
536
}
560
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
561
- // klog.Infof("[DataPlane] [%s] finished applying ipsets", contextAddNetPolBootup)
537
+ klog .Infof ("[DataPlane] [%s] finished applying ipsets" , contextAddNetPolBootup )
562
538
563
539
// see comment in RemovePolicy() for why this is here
564
540
dp .setRemovePolicyFailure (false )
@@ -598,8 +574,7 @@ func (dp *DataPlane) addPolicies(netPols []*policies.NPMNetworkPolicy) error {
598
574
599
575
// RemovePolicy takes in network policyKey (namespace/name of network policy) and removes it from dataplane and cache
600
576
func (dp * DataPlane ) RemovePolicy (policyKey string ) error {
601
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
602
- // klog.Infof("[DataPlane] Remove Policy called for %s", policyKey)
577
+ klog .Infof ("[DataPlane] Remove Policy called for %s" , policyKey )
603
578
604
579
if dp .netPolInBackground {
605
580
// make sure to not add this NetPol if we're deleting it
@@ -675,12 +650,10 @@ func (dp *DataPlane) RemovePolicy(policyKey string) error {
675
650
// UpdatePolicy takes in updated policy object, calculates the delta and applies changes
676
651
// onto dataplane accordingly
677
652
func (dp * DataPlane ) UpdatePolicy (policy * policies.NPMNetworkPolicy ) error {
678
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
679
- // klog.Infof("[DataPlane] Update Policy called for %s", policy.PolicyKey)
653
+ klog .Infof ("[DataPlane] Update Policy called for %s" , policy .PolicyKey )
680
654
ok := dp .policyMgr .PolicyExists (policy .PolicyKey )
681
655
if ! ok {
682
- // TODO: Refactor non-error/warning klogs with Zap and set the following logs to "debug" level
683
- // klog.Infof("[DataPlane] Policy %s is not found.", policy.PolicyKey)
656
+ klog .Infof ("[DataPlane] Policy %s is not found." , policy .PolicyKey )
684
657
return dp .AddPolicy (policy )
685
658
}
686
659
0 commit comments