MCPcopy
hub / github.com/cilium/cilium / OnUpsert

Method OnUpsert

pkg/allocator/cache.go:138–168  ·  view source on GitHub ↗
(id idpool.ID, key AllocatorKey)

Source from the content-addressed store, hash-verified

136}
137
138func (c *cache) OnUpsert(id idpool.ID, key AllocatorKey) {
139 for _, validator := range c.allocator.cacheValidators {
140 if err := validator(AllocatorChangeUpsert, id, key); err != nil {
141 c.logger.Warn(
142 "Skipping event for invalid identity",
143 logfields.Error, err,
144 logfields.Identity, id,
145 logfields.Event, AllocatorChangeUpsert,
146 )
147 return
148 }
149 }
150
151 c.mutex.Lock()
152 defer c.mutex.Unlock()
153
154 if k, ok := c.nextCache[id]; ok {
155 delete(c.nextKeyCache, k.GetKey())
156 }
157
158 c.nextCache[id] = key
159 if key != nil {
160 c.nextKeyCache[key.GetKey()] = id
161 }
162
163 c.allocator.idPool.Remove(id)
164
165 c.emitChange(AllocatorChange{Kind: AllocatorChangeUpsert, ID: id, Key: key})
166
167 c.sendEvent(AllocatorChangeUpsert, id, key)
168}
169
170func (c *cache) OnDelete(id idpool.ID, key AllocatorKey) {
171 for _, validator := range c.allocator.cacheValidators {

Callers

nothing calls this directly

Calls 6

sendEventMethod · 0.95
WarnMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65
GetKeyMethod · 0.65
RemoveMethod · 0.65

Tested by

no test coverage detected