Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions sensor/common/clusterentities/store_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@ func (e *endpointsStore) purgeNoLock(deploymentID string) {
// so let's make a temporary copy.
endpointsSet := e.reverseEndpointMap[deploymentID]
for ep := range endpointsSet {
if e.historyEnabled() {
e.moveToHistory(deploymentID, ep)
} else {
e.deleteFromCurrent(deploymentID, ep)
}
e.moveToHistory(deploymentID, ep)
}
}

Expand Down Expand Up @@ -216,9 +212,12 @@ func (e *endpointsStore) removeFromHistoryIfExpired(deploymentID string, ep net.
return false
}

// moveToHistory is a convenience function that removes data from the current map and adds it to history
// moveToHistory is a convenience function that removes data from the current map and adds it to history.
// If history is disabled, it just deletes the data from the current map.
func (e *endpointsStore) moveToHistory(deploymentID string, ep net.NumericEndpoint) {
e.addToHistory(deploymentID, ep)
if e.historyEnabled() {
e.addToHistory(deploymentID, ep)
}
e.deleteFromCurrent(deploymentID, ep)
}

Expand Down
38 changes: 38 additions & 0 deletions sensor/common/clusterentities/store_endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,44 @@ func (s *ClusterEntitiesStoreTestSuite) TestMemoryAboutPastEndpoints() {
},
},
},
"IP changing owner with memory disabled should not retain previous deployment in history": {
numTicksToRemember: 0,
entityUpdates: map[int][]eUpdate{
0: {
{
deploymentID: "depl1",
containerID: "pod1",
ipAddr: "10.0.0.1",
port: 80,
portName: "http",
incremental: true,
},
},
2: {
{
deploymentID: "depl2",
containerID: "pod2",
ipAddr: "10.0.0.1",
port: 80,
portName: "http",
incremental: false, // overwrite
},
},
},
operationAfterTick: map[int]operation{},
lookupResultsAfterTick: map[int][]expectation{
0: {expectDeployment80("10.0.0.1", "depl1", "http", theMap)},
1: {expectDeployment80("10.0.0.1", "depl1", "http", theMap)},
2: {
expectDeployment80("10.0.0.1", "depl1", "http", nowhere),
expectDeployment80("10.0.0.1", "depl2", "http", theMap),
},
3: {
expectDeployment80("10.0.0.1", "depl1", "http", nowhere),
expectDeployment80("10.0.0.1", "depl2", "http", theMap),
},
},
},
}
for name, tCase := range cases {
s.Run(name, func() {
Expand Down
Loading