据我了解(和经验)- kubernetes 线人调用 updateFunc
其缓存的每个“同步”事件 - 据我所知,这是由于 this烦人的代码和平。
线人定义示例:
informer:= NewInformer(
&cache.ListWatch{
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
return kubeClient.Batch().Jobs(api.NamespaceAll).List(options)
},
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
return kubeClient.Batch().Jobs(api.NamespaceAll).Watch(options)
},....)
...
informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}){},
// Make this function be called *only* on update.
UpdateFunc: func(old, current interface{}){},
DeleteFunc: func(current interface{}){},
})
但对于我的用例 - 调用 updateFunc
应该只在该资源更新时才真正发生(例如,我正在对每次更新或进行 I/O 进行一些密集计算)。
我在想有没有办法只在更新时调用 updateFunc
?
最佳答案
我找到了答案 in this github issue :
If resourceVersion differs between old and new, an actual update event was observed.
关于go - 如何避免在同步时调用 `updateFunc`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53803992/