Skip to content

✨ POC for a read-your-own-write client#3472

Open
alvaroaleman wants to merge 18 commits intokubernetes-sigs:mainfrom
alvaroaleman:consistency
Open

✨ POC for a read-your-own-write client#3472
alvaroaleman wants to merge 18 commits intokubernetes-sigs:mainfrom
alvaroaleman:consistency

Conversation

@alvaroaleman
Copy link
Copy Markdown
Member

Related to #3320
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 8, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 8, 2026
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 8, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@alvaroaleman: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-controller-runtime-test 3f46126 link true /test pull-controller-runtime-test
pull-controller-runtime-apidiff 3f46126 link false /test pull-controller-runtime-apidiff

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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-sigs/prow repository. I understand the commands that are listed here.

return fmt.Errorf("failed to get GVK for list %T: %w", list, err)
}

keys := c.lockedKeysByGVK.getOrCreate(gvk).allValues()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gvk.Kind = strings.TrimSuffix(gvk.Kind, "List")

return c.clusterCache.AddRequiredDeleteForObject(obj)
} else if cache, ok := c.namespaceToCache[ns]; ok {
return cache.AddRequiredDeleteForObject(obj)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like not handle global cache namespaceToCache[metav1.NamespaceAll]

if ctx.Err() != nil {
break
}
h.pendingDeletesCond.Wait()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Wait() only wakes on Broadcast(), and Broadcast() only happens when new informer events arrive, the goroutine will leak

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I am aware, but I think that's acceptable - If someone started waiting, the assumption is that an event will come so this won't be blocked for long

if ctx.Err() != nil {
break
}
h.rvCond.Wait()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Wait() only wakes on Broadcast(), and Broadcast() only happens when new informer events arrive, the goroutine will leak

@@ -0,0 +1,257 @@
package client_test
Copy link
Copy Markdown
Member

@sbueringer sbueringer Mar 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please double check (eventually, I know this is just a POC for now) that we have coverage that read-your-own write also works correctly with the multi namespace cache

cache cache

// lockedKeysByGVK maps gvk -> key -> keyLocker
lockedKeysByGVK threadSafeMap[schema.GroupVersionKind, *threadSafeMap[types.NamespacedName, *keyLocker]]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I saw correctly we only add but never remove from this map. While it doesn't take a lot of memory I wonder if this adds up

(didn't thoroughly review the entire PR, so I might have missed the cleanup)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants