Skip to content

cache/informer: add type-safe informer support - #3553

Draft
sttts wants to merge 3 commits into
kubernetes-sigs:mainfrom
sttts:sttts-port-informer-constructs
Draft

cache/informer: add type-safe informer support#3553
sttts wants to merge 3 commits into
kubernetes-sigs:mainfrom
sttts:sttts-port-informer-constructs

Conversation

@sttts

@sttts sttts commented Jul 17, 2026

Copy link
Copy Markdown

What

This ports controller-runtime informer/source wiring to the type-safe informer constructs from kubernetes/kubernetes#139821.

  • Adds cache.TypedInformer, cache.NewTypedInformer, and cache.GetTypedInformer.
  • Routes source.Kind and source.TypedInformer through TypedResourceEventHandler.
  • Uses typed deleted-object tombstones instead of local untyped tombstone decoding in controller-runtime.
  • Updates source tests to use generated typed informers.
  • Adds adapter coverage for typed handlers, typed indexers, and deleted final state handling.

Impact

This intentionally allows breaking code changes:

  • source.Kind / source.TypedKind objects now need to satisfy cache.TypedObject.
  • source.TypedInformer.Informer now expects cache.TypedInformer[T].

The Kubernetes module replaces point at the current head used for kubernetes/kubernetes#139821 until those APIs are available from upstream Kubernetes modules.

Validation

  • make test
  • git diff --check

@kubernetes-prow

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubernetes-prow kubernetes-prow Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 17, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sttts
Once this PR has been reviewed and has the lgtm label, please assign sbueringer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 17, 2026
Comment thread pkg/cache/cache.go Outdated
// TypedObject is a client.Object that can be used with the type-safe informer API.
type TypedObject interface {
client.Object
toolscache.Object

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.

@sttts Could you tell your LLM to update this to just extend client.Object to be comparable to avoid all the noise?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in 06b411f: TypedObject now embeds client.Object and comparable directly instead of toolscache.Object.

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.

Wondering if toolscache.Object absolutely has to be comparable. Because if it would not be this problem wouldn't exist

@kubernetes-prow kubernetes-prow Bot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jul 20, 2026
Comment thread pkg/source/source.go
// TypedInformer is used to provide a source of events originating inside the cluster from Watches using generic
// event handlers and predicates.
type TypedInformer[object any, request comparable] struct {
type TypedInformer[object toolscache.Object, request comparable] struct {

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.

Looks like this reverts: #3520

@sttts
sttts force-pushed the sttts-port-informer-constructs branch from 06b411f to 22c8bff Compare July 21, 2026 12:42
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Invalid commit message issues detected

Fixup/amend/squash commits

Temporary commits like fixup!, amend!, or squash! are not allowed.

Use git rebase --autosquash to fix them.

  • f489618 fixup! cache/informer: add type-safe informer support
  • 22c8bff fixup! cache/informer: add type-safe informer support

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.

@kubernetes-prow kubernetes-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 24, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

PR needs rebase.

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.

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants