-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
[WIP][PoC] cacher: Attempt serving paginated LIST calls from watchCache #108392
[WIP][PoC] cacher: Attempt serving paginated LIST calls from watchCache #108392
Conversation
@MadhavJivrajani: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@MadhavJivrajani: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/skip |
@wojtek-t for now only the btree backed cache is implemented for |
/retest |
/triage accepted |
1ff6d73
to
0a04f68
Compare
return nil | ||
} | ||
|
||
// TODO(MadhavJivrajani): This is un-implemented for now. Stubbing this out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general you would need to reimplement something similar to https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/tools/cache/thread_safe_store.go#L135-L323
However - our case is somewhat special, as there is exactly one index defined and only for pods.
So we can probably shortcut it and:
- implement just a single index using a btree [it will be btree with key="index value" and value="set of keys matching that value"]
- use that here (we can have a strict validation that will fail creation if there is more than 1 indexer)
[we can eventually generalize it, but it's not needed now]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually thought about that and in the KEP I proposed to ignored indexes in general:
kubernetes/enhancements#3274
PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
Thanks @wojtek-t! Will get back to this post release :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I described here:
https://github.com/kubernetes/enhancements/pull/3274/files#diff-3d93eb20b3400b8a937e7ab25e0aca359f73d8600271605df260b3b83bad06a7R301-R303
let make that very simple:
(1) if we're at "now" - let's have the index implemented the same way as we have now:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/tools/cache/thread_safe_store.go#L70
[so basically something like:
store.lock()
current := store.btree.Clone()
indexed := store.index[myvalue] (probably deep-copied, depending on the implementation)
store.unlock()
// procee the request using "current" and "indexed"
(2) let's ignore that for continuation
[index is just an optimization, and for continuation, we can just go ahead and process all items
@wojtek-t 👋🏼 I am having some difficulty with the implementation:
func (t *btreeStore) LimitPrefixRead(limit int64, key string) []interface{} {
t.lock.RLock()
defer t.lock.Unlock()
var result []interface{}
var elementsRetrieved int64
t.tree.AscendGreaterOrEqual(&storeElement{Key: key}, func(i btree.Item) bool {
elementKey := i.(*storeElement).Key
if elementsRetrieved == limit {
return false
}
if !strings.HasPrefix(elementKey, key) {
return false
}
elementsRetrieved++
result = append(result, i.(interface{}))
return true
})
return result
} and I call it as treeClone := cloneOrGetFromContinuationCache()
treeClone.LimitPrefixRead(listOpts.Predicate.Limit, somehowDecodedKeyFromContinueToken)
Done so far:
type btreeIndexer interface {
cache.Store
Clone() btreeIndexer
LimitPrefixRead(limit int64, key string) []interface{}
}
Will push the progress once things are more stitched together, the implementation as of now is sort of disparate. |
More-or-less but we should be much simpler:
Yeah - that sounds roughly what I expected
I thought I described it here, but apparently not.
I don't fully understand the question - can you clarify? |
Please feel free to tag /remove-sig auth |
@MadhavJivrajani: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
storeClone = w.continueCache.cache[resourceVersion] | ||
} else { | ||
storeClone = w.store.Clone() | ||
w.continueCache.cache[resourceVersion] = storeClone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs a lock to avoid concurrenct map read/write, which crashes the kube-apiserver
I am thinking, rather than fix the watch cache like this, what if we focused on making clients use watch w/ catch up event as in kubernetes/enhancements#3667? |
If you still need this PR then please rebase, if not, please close the PR |
This PR has the label work-in-progress, please revisit to see if you still need this, please close if not |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
This work-in-progress PR needs a rebase. please rebase if this PR is still needed for the upcoming release. |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What type of PR is this?
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/sig api-machinery scalability
/assign @wojtek-t
/cc @nikhita
Related to #108003