Fix forceLiveLookupCache key in namespace lifecycle admission (k8s 1.37.0 update)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Read staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission.go and the lifecycle plugin's unit tests. Check how the namespace delete stores its key and how object creation reads it; then add the requested regression coverage for a Pod in a terminating namespace and cluster scoping. Done means the lookup uses the object's namespace, the tests reject the create after the live lookup, and the kcp patch and 1.37.0 branch are updated.
Written by the indexing model from the issue text.
Description
What exists today
In the kcp Kubernetes fork update to 1.37.0 (https://github.com/kcp-dev/kubernetes/pull/198), the namespace lifecycle admission plugin builds one key and uses it for both the store and the lookup of forceLiveLookupCache:
staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle/admission.go (head 5ec79958933dfa6999e77eab9e90b691e26fbcd5)
- line 93:
namespaceKey := kcpcache.ToClusterAwareKey(clusterName.String(), "", a.GetName()) - line 101: on a Namespace delete,
l.forceLiveLookupCache.Add(namespaceKey, true, forceLiveLookupTTL). Herea.GetName()is the namespace name, so this is correct. - line 160:
l.forceLiveLookupCache.Get(namespaceKey). On this pathais the namespaced object being created (e.g. a Pod), soa.GetName()is the object name, not the namespace name.
The lookup key is cluster|<objectname> but the stored key is cluster|<namespacename>, so the lookup effectively never matches. Upstream reads a.GetNamespace() here.
Impact
The "recently deleted namespace, force a live lookup" guard never fires. When the informer cache is stale (the namespace is still Active locally after a delete), creates into a terminating namespace can be admitted. A match is only possible by accident, when an object's name equals the deleted namespace's name.
What should replace it
Use a separate key for the lookup, built from the object's namespace:
liveKey := kcpcache.ToClusterAwareKey(clusterName.String(), "", a.GetNamespace())
if _, ok := l.forceLiveLookupCache.Get(liveKey); ok {
Keep namespaceKey (from a.GetName()) for the Namespace-delete store at line 101.
Checklist
- Split the key: keep
a.GetName()for the store at line 101 and usea.GetNamespace()for the read at line 160. - Add a unit test in the lifecycle plugin: delete namespace
fooin a cluster, keep the lister showingfooasActive, then create a Pod namedbarinfoo. The create must go through the live lookup and be rejected oncefooisTerminating. - Cover cluster scoping in that test: a delete in cluster A must not force a live lookup in cluster B.
- Update the kcp patch in https://github.com/kcp-dev/kubernetes-patches/pull/2 and the 1.37.0 branch accordingly.
References
- Dominant language
- Go
- Stars
- 2.9k
- Forks
- 471
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 77
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from kcp-dev/kcp
-
bug: PartitionSet endlessly recreates Partitions when a dimension is also in shardSelector.matchLabelsPossibly taken @officialasishkumar claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 36/100
Maintainers usually reply within 1 day
Similar issues
-
desktop v3 windows
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
esengine/DeepSeek-Reasonix#15016 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
OneBusAway/vehicle-positions#260 ·
Maintainers usually reply within 1 day
-
Panic on startup when the GitHub releases API returns no `tag_name` (rate limit / network failure)Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
blurfx/KakaoTalkAdBlock#113 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
discobox-ai/discobox#860 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day