@@ -66,7 +66,6 @@ func (dp *DataPlane) initializeDataPlane() error {
6666 return errors .Wrap (err , "failed to marshal endpoint filter map for attachedsharing state" )
6767 }
6868 dp .endpointQuery .query .Filter = string (filter )
69- klog .Infof ("Attached Sharing State filter- %+v" , string (filter ))
7069
7170 // Filter out any endpoints that are not in "Attached" State. All running Windows L1VH pods with networking must be in this state.
7271 filterMapAttached := map [string ]uint16 {"State" : hcnEndpointStateAttached }
@@ -75,7 +74,6 @@ func (dp *DataPlane) initializeDataPlane() error {
7574 return errors .Wrap (err , "failed to marshal endpoint filter map for attched state on L1VH Node" )
7675 }
7776 dp .endpointQueryAttachedState .query .Filter = string (filterAttached )
78- klog .Infof ("AttachedState filter- %+v" , string (filterAttached ))
7977
8078 // reset endpoint cache so that netpol references are removed for all endpoints while refreshing pod endpoints
8179 // no need to lock endpointCache at boot up
@@ -348,15 +346,10 @@ func (dp *DataPlane) getEndpointsToApplyPolicies(netPols []*policies.NPMNetworkP
348346
349347func (dp * DataPlane ) getLocalPodEndpoints () ([]* hcn.HostComputeEndpoint , error ) {
350348 klog .Info ("getting local endpoints" )
351- klog .Infof ("npm lite is enabled: %+v" , dp .EnableNPMLite ) // Will remove after debugging
352349
353350 // Gets endpoints in state: Attached
354351 timer := metrics .StartNewTimer ()
355352 endpointsAttached , err := dp .ioShim .Hns .ListEndpointsQuery (dp .endpointQueryAttachedState .query )
356- klog .Infof ("Attached: There are %+v endpoints with state: attached" , len (endpointsAttached )) // Will remove after debugging
357- for _ , endpoint := range endpointsAttached {
358- klog .Infof ("ID: %s, Name: %+v" , endpoint .Id , endpoint .Name )
359- }
360353 metrics .RecordListEndpointsLatency (timer )
361354 if err != nil {
362355 metrics .IncListEndpointsFailures ()
@@ -366,20 +359,14 @@ func (dp *DataPlane) getLocalPodEndpoints() ([]*hcn.HostComputeEndpoint, error)
366359 // Gets endpoints in state: AttachedSharing
367360 timer = metrics .StartNewTimer ()
368361 endpoints , err := dp .ioShim .Hns .ListEndpointsQuery (dp .endpointQuery .query )
369- for _ , endpoint1 := range endpoints {
370- klog .Infof (" AttachedSharing: ID: %s, Name: %+v" , endpoint1 .Id , endpoint1 .Name )
371- }
372- klog .Infof ("There are %+v endpoints with state: attached sharing" , len (endpoints )) // Will remove after debugging
373362 metrics .RecordListEndpointsLatency (timer )
374363 if err != nil {
375364 metrics .IncListEndpointsFailures ()
376365 return nil , errors .Wrap (err , "failed to get local pod endpoints in state: attachedSharing" )
377366 }
367+
378368 // Filtering out any of the same endpoints between endpoints with state attached and attachedSharing
379369 endpoints = removeCommonEndpoints (& endpoints , & endpointsAttached )
380- for _ , endpoint := range endpoints {
381- klog .Infof ("combined enpoints ID: %s, Name: %+v" , endpoint .Id , endpoint .Name )
382- }
383370
384371 epPointers := make ([]* hcn.HostComputeEndpoint , 0 , len (endpoints ))
385372 for k := range endpoints {
@@ -389,27 +376,28 @@ func (dp *DataPlane) getLocalPodEndpoints() ([]*hcn.HostComputeEndpoint, error)
389376}
390377
391378func removeCommonEndpoints (endpoints , endpointsAttached * []hcn.HostComputeEndpoint ) []hcn.HostComputeEndpoint {
379+ // Choose smaller and larger lists based on length for efficiency
392380 smallerEndpointsList , largerEndpointsList := endpoints , endpointsAttached
393381 if len (* endpoints ) > len (* endpointsAttached ) {
394382 smallerEndpointsList , largerEndpointsList = endpointsAttached , endpoints
395383 }
396384
397- // add endpoints from smaller array into a map
385+ // Store IDs of smaller list in a map for quick lookup
398386 idMap := make (map [string ]struct {}, len (* smallerEndpointsList ))
399387 for i := 0 ; i < len (* smallerEndpointsList ); i ++ {
400388 ep := & (* smallerEndpointsList )[i ]
401389 idMap [ep .Id ] = struct {}{}
402390 }
403391
404- // checking for common endpoints among two endpoint arrays
392+ // Append endpoints from larger list and remove common IDs from map
405393 var result []hcn.HostComputeEndpoint
406394 for i := 0 ; i < len (* largerEndpointsList ); i ++ {
407395 ep := (* largerEndpointsList )[i ]
408396 result = append (result , ep )
409397 delete (idMap , ep .Id )
410398 }
411399
412- // Appending remaining unique elements from the smaller endpoint array
400+ // Append remaining unique endpoints from smaller list to result
413401 for i := 0 ; i < len (* smallerEndpointsList ); i ++ {
414402 ep := (* smallerEndpointsList )[i ]
415403 if _ , found := idMap [ep .Id ]; found {
0 commit comments