MCPcopy
hub / github.com/microsoft/retina / updateSvc

Method updateSvc

pkg/controllers/cache/cache.go:260–287  ·  view source on GitHub ↗

updateSvc updates the cache with the given retina service.

(svc *common.RetinaSvc)

Source from the content-addressed store, hash-verified

258
259// updateSvc updates the cache with the given retina service.
260func (c *Cache) updateSvc(svc *common.RetinaSvc) error {
261 // TODO check if a service already exists here
262 ip, err := svc.GetPrimaryIP()
263 if err != nil {
264 c.l.Error("updateSvc: error getting primary IP for service", zap.String("service", svc.Key()), zap.Error(err))
265 return err
266 }
267
268 // delete if any existing object is using this IP
269 // send a delete event for the existing object
270 err = c.deleteByIP(ip, svc.Key())
271 if err != nil {
272 c.l.Error("updateSvc: error deleting existing object for IP",
273 zap.String("svc", svc.Key()),
274 zap.String("ip", ip),
275 zap.Error(err),
276 )
277 return err
278 }
279
280 c.ipToSvcKey[ip] = svc.Key()
281 c.svcMap[svc.Key()] = svc
282
283 // notify pubsub
284 c.publish(EventTypeSvcAdded, svc)
285
286 return nil
287}
288
289// UpdateRetinaNode updates the cache with the given retina node.
290func (c *Cache) UpdateRetinaNode(node *common.RetinaNode) error {

Callers 1

UpdateRetinaSvcMethod · 0.95

Calls 6

deleteByIPMethod · 0.95
publishMethod · 0.95
GetPrimaryIPMethod · 0.80
KeyMethod · 0.80
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected