Skip to content

Commit 2e211ef

Browse files
authored
fix: [NPM-WIN] do not refresh endpoints if pod cache is empty (#1831)
* do not refresh endpoints if pod cache is empty * moved cache lock up * reposition cache lock * fixed incorrect logic
1 parent 2d1d551 commit 2e211ef

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

npm/pkg/dataplane/dataplane.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ func (dp *DataPlane) ApplyDataPlane() error {
216216

217217
// NOTE: ideally we won't refresh Pod Endpoints if the updatePodCache is empty
218218
if dp.shouldUpdatePod() {
219+
// do not refresh endpoints if the updatePodCache is empty
220+
dp.updatePodCache.Lock()
221+
if len(dp.updatePodCache.cache) == 0 {
222+
dp.updatePodCache.Unlock()
223+
return nil
224+
}
225+
dp.updatePodCache.Unlock()
226+
219227
err := dp.refreshPodEndpoints()
220228
if err != nil {
221229
metrics.SendErrorLogAndMetric(util.DaemonDataplaneID, "[DataPlane] failed to refresh endpoints while updating pods. err: [%s]", err.Error())

0 commit comments

Comments
 (0)