@@ -50,13 +50,25 @@ func (dp *DataPlane) initializeDataPlane() error {
5050 },
5151 Flags : hcn .HostComputeQueryFlagsNone ,
5252 }
53+ // Initialize Endpoint query used to filter healthy endpoints (vNIC) of Windows pods on L1VH Node
54+ dp .endpointQueryL1VH .query = hcn.HostComputeQuery {
55+ SchemaVersion : hcn.SchemaVersion {
56+ Major : hcnSchemaMajorVersion ,
57+ Minor : hcnSchemaMinorVersion ,
58+ },
59+ Flags : hcn .HostComputeQueryFlagsNone ,
60+ }
61+
5362 // Filter out any endpoints that are not in "AttachedShared" State. All running Windows pods with networking must be in this state.
5463 filterMap := map [string ]uint16 {"State" : hcnEndpointStateAttachedSharing }
55- filter , err := json .Marshal (filterMap )
56- if err != nil {
57- return npmerrors .SimpleErrorWrapper ("failed to marshal endpoint filter map" , err )
58- }
64+ filterMapL1VH := map [string ]uint16 {"State" : hcnEndpointStateAttached }
65+
66+ filter , err := marshalFilterMap (filterMap )
67+
68+ filterL1VH , err := marshalFilterMap (filterMapL1VH )
69+
5970 dp .endpointQuery .query .Filter = string (filter )
71+ dp .endpointQueryL1VH .query .Filter = string (filterL1VH )
6072
6173 // reset endpoint cache so that netpol references are removed for all endpoints while refreshing pod endpoints
6274 // no need to lock endpointCache at boot up
@@ -65,6 +77,14 @@ func (dp *DataPlane) initializeDataPlane() error {
6577 return nil
6678}
6779
80+ func marshalFilterMap (filtermap map [string ]uint16 ) ([]byte , error ) {
81+ filter , err := json .Marshal (filtermap )
82+ if err != nil {
83+ return nil , npmerrors .SimpleErrorWrapper ("failed to marshal endpoint filter map" , err )
84+ }
85+ return filter , nil
86+ }
87+
6888func (dp * DataPlane ) getNetworkInfo () error {
6989 retryNumber := 0
7090 ticker := time .NewTicker (time .Second * time .Duration (maxNoNetSleepTime ))
@@ -330,13 +350,15 @@ func (dp *DataPlane) getEndpointsToApplyPolicies(netPols []*policies.NPMNetworkP
330350func (dp * DataPlane ) getLocalPodEndpoints () ([]* hcn.HostComputeEndpoint , error ) {
331351 klog .Info ("getting local endpoints" )
332352 timer := metrics .StartNewTimer ()
333- endpoints , err := dp .ioShim .Hns .ListEndpointsQuery (dp .endpointQuery .query )
353+ endpointsAttachedSharing , err := dp .ioShim .Hns .ListEndpointsQuery (dp .endpointQuery .query )
354+ endpointsAttached , err := dp .ioShim .Hns .ListEndpointsQuery (dp .endpointQueryL1VH .query )
334355 metrics .RecordListEndpointsLatency (timer )
335356 if err != nil {
336357 metrics .IncListEndpointsFailures ()
337358 return nil , npmerrors .SimpleErrorWrapper ("failed to get local pod endpoints" , err )
338359 }
339-
360+ endpoints := append (endpointsAttachedSharing , endpointsAttached ... )
361+ klog .Infof ("there are %+v endpoints in endpointsAttachedSharing and %+v endpoints in Attached" , len (endpointsAttachedSharing ), len (endpointsAttached ))
340362 epPointers := make ([]* hcn.HostComputeEndpoint , 0 , len (endpoints ))
341363 for k := range endpoints {
342364 epPointers = append (epPointers , & endpoints [k ])
0 commit comments