Skip to content

Commit 6e56bba

Browse files
committed
added querying to l1vh hns only if npm lite is enabled
1 parent ae849be commit 6e56bba

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

npm/cmd/start.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ func start(config npmconfig.Config, flags npmconfig.Flags) error {
137137
stopChannel := wait.NeverStop
138138
if config.Toggles.EnableV2NPM {
139139
// update the dataplane config
140+
npmV2DataplaneCfg.EnableNPMLite = config.Toggles.EnableV2NPM
141+
140142
npmV2DataplaneCfg.MaxBatchedACLsPerPod = config.MaxBatchedACLsPerPod
141143

142144
npmV2DataplaneCfg.NetPolInBackground = config.Toggles.NetPolInBackground

npm/pkg/dataplane/dataplane.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type Config struct {
4545
NetPolInBackground bool
4646
MaxPendingNetPols int
4747
NetPolInterval time.Duration
48+
EnableNPMLite bool
4849
*ipsets.IPSetManagerCfg
4950
*policies.PolicyManagerCfg
5051
}
@@ -130,7 +131,6 @@ func NewDataPlane(nodeName string, ioShim *common.IOShim, cfg *Config, stopChann
130131
} else {
131132
metrics.SendLog(util.DaemonDataplaneID, "[DataPlane] dataplane configured to NOT add netpols in background", true)
132133
}
133-
134134
return dp, nil
135135
}
136136

npm/pkg/dataplane/dataplane_windows.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,15 +350,23 @@ func (dp *DataPlane) getEndpointsToApplyPolicies(netPols []*policies.NPMNetworkP
350350
func (dp *DataPlane) getLocalPodEndpoints() ([]*hcn.HostComputeEndpoint, error) {
351351
klog.Info("getting local endpoints")
352352
timer := metrics.StartNewTimer()
353-
endpointsAttachedSharing, err := dp.ioShim.Hns.ListEndpointsQuery(dp.endpointQuery.query)
354-
endpointsAttached, err := dp.ioShim.Hns.ListEndpointsQuery(dp.endpointQueryL1VH.query)
353+
endpoints, err := dp.ioShim.Hns.ListEndpointsQuery(dp.endpointQuery.query)
354+
klog.Infof("There are %+v endpoints in AttachedSharing state", len(endpoints))
355355
metrics.RecordListEndpointsLatency(timer)
356356
if err != nil {
357357
metrics.IncListEndpointsFailures()
358358
return nil, npmerrors.SimpleErrorWrapper("failed to get local pod endpoints", err)
359359
}
360-
endpoints := append(endpointsAttachedSharing, endpointsAttached...)
361-
klog.Infof("there are %+v endpoints in endpointsAttachedSharing and %+v endpoints in Attached", len(endpointsAttachedSharing), len(endpointsAttached))
360+
if dp.EnableNPMLite {
361+
timer = metrics.StartNewTimer()
362+
endpointsAttached, errL1vh := dp.ioShim.Hns.ListEndpointsQuery(dp.endpointQueryL1VH.query)
363+
if errL1vh != nil {
364+
metrics.IncListEndpointsFailures()
365+
return nil, npmerrors.SimpleErrorWrapper("failed to get local pod endpoints in L1VH", err)
366+
}
367+
klog.Infof("There are %+v endpoints in Attached state on l1vh", len(endpointsAttached))
368+
endpoints = append(endpoints, endpointsAttached...)
369+
}
362370
epPointers := make([]*hcn.HostComputeEndpoint, 0, len(endpoints))
363371
for k := range endpoints {
364372
epPointers = append(epPointers, &endpoints[k])

0 commit comments

Comments
 (0)