mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-05 09:01:06 +00:00
- Delete backing string set from a threadSafeMap index when the string set length reaches 0.
- Added thread_safe_store_test exercising new index backing string set delete at 0 functionality. - TestThreadSafeStoreDeleteRemovesEmptySetsFromIndex logic nesting inverted. - Added test case for usage of an index where post element delete there is non-zero count of elements and expect the set to still exist. - Fixed date. - Fixed awprice nits. - Fix bazel. Kubernetes-commit: 29a051388a719e0359969b8431de8e38e955e2a6
This commit is contained in:
committed by
Kubernetes Publisher
parent
dac3b9c76a
commit
ab63be7642
7
tools/cache/thread_safe_store.go
vendored
7
tools/cache/thread_safe_store.go
vendored
@@ -292,6 +292,13 @@ func (c *threadSafeMap) deleteFromIndices(obj interface{}, key string) {
|
||||
set := index[indexValue]
|
||||
if set != nil {
|
||||
set.Delete(key)
|
||||
|
||||
// If we don't delete the set when zero, indices with high cardinality
|
||||
// short lived resources can cause memory to increase over time from
|
||||
// unused empty sets. See `kubernetes/kubernetes/issues/84959`.
|
||||
if len(set) == 0 {
|
||||
delete(index, indexValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user