-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add apiserver-lite proposal #4
base: master
Are you sure you want to change the base?
Conversation
@GsssC cc |
List请求和Watch请求的时间差在k8s List Watch 机制中, List请求和Watch请求并不是同时发向api-server的, 两者之间存在一个时间差, 伪代码表示如下: ListResp := client.Do(ListReq)
/---------------时间差开始------------------/
//主要关注返回list的最大rv(resource version)
//表示此rv前的数据我已经收到, 想我发送此rv之后的事件
WatchReq := BuildWatchReq(ListResp.MaxRv)
/---------------时间差结束------------------/
WatchResp := client.Do(WatchReq) 如果watch请求不带rv, 客户端将会遗漏时间差内的资源变更事件watch.Event, 因此watch请求都是带rv的. 因此, apiserver同时对于每一种类资源对象(以GroupVersionKind区分), 都会维护一份WatchCache, 缓存一定量的资源变更事件, 根据代码 const(
// defaultLowerBoundCapacity is a default value for event cache capacity's lower bound.
// TODO: Figure out, to what value we can decreased it.
defaultLowerBoundCapacity = 100
)
func newWatchCache(
keyFunc func(runtime.Object) (string, error),
eventHandler func(*watchCacheEvent),
getAttrsFunc func(runtime.Object) (labels.Set, fields.Set, error),
versioner storage.Versioner,
indexers *cache.Indexers,
clock clock.Clock,
objectType reflect.Type) *watchCache {
wc := &watchCache{
capacity: defaultLowerBoundCapacity,
keyFunc: keyFunc,
getAttrsFunc: getAttrsFunc,
cache: make([]*watchCacheEvent, defaultLowerBoundCapacity),
lowerBoundCapacity: defaultLowerBoundCapacity,
upperBoundCapacity: defaultUpperBoundCapacity,
startIndex: 0,
endIndex: 0,
store: cache.NewIndexer(storeElementKey, storeElementIndexers(indexers)),
resourceVersion: 0,
listResourceVersion: 0,
eventHandler: eventHandler,
clock: clock,
versioner: versioner,
objectType: objectType,
}
wc.cond = sync.NewCond(wc.RLocker())
return wc
} 此WatchCache的容量是100, 假设Cache中对象的最小版本问MinRv, 最大版本为MaxRv, WatchReq.rv必须>=MinRv. 如果一个WatchReq.rv过于老旧(<MinRv), apiserver中没有缓存, 服务端会返回 apiserver-lite也会遇到同样的问题, 同时MetaManager没有实现资源的按版本缓存, 暂拟解决方案:
|
3c82643
to
7183a7e
Compare
2e86db0
to
b8d7f32
Compare
5141c0d
to
49e3234
Compare
this is a proposal about edgeproxy.