Skip to content

API-1835: Scaffold event dispatcher #7543

Open
p0lyn0mial wants to merge 1 commit intoopenshift:mainfrom
p0lyn0mial:om-phase-2-in-res-dispatcher-stub
Open

API-1835: Scaffold event dispatcher #7543
p0lyn0mial wants to merge 1 commit intoopenshift:mainfrom
p0lyn0mial:om-phase-2-in-res-dispatcher-stub

Conversation

@p0lyn0mial
Copy link
Contributor

@p0lyn0mial p0lyn0mial commented Jan 19, 2026

requires #7477

// inputResourceDispatcher is a simple dispatcher that applies GVK scoped filters
// and forwards matching events.
//
// Each GVK has its own set of filters. Today these
// may include name/namespace checks, and in the future label selectors.
//
// Longer term, this dispatcher is expected to track which input resources are
// associated with which operator.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jan 19, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 19, 2026

@p0lyn0mial: This pull request references API-1835 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "4.22.0" version, but no target version was set.

Details

In response to this:

requires #7477

// inputResourceDispatcher is a simple dispatcher that applies GVK scoped filters
// and forwards matching events.
//
// Each GVK has its own set of filters. Today these
// may include name/namespace checks, and in the future label selectors.
//
// Longer term, this dispatcher is expected to track which input resources are
// associated with which operator.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 19, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Walkthrough

Adds a new per-GVK input resource dispatcher for filtering and forwarding Kubernetes events, alongside comprehensive unit tests validating the dispatch logic across multiple filter scenarios.

Changes

Cohort / File(s) Summary
Input Resource Dispatcher
control-plane-operator/controllers/openshiftmanager/input_resource_dispatcher.go, input_resource_dispatcher_test.go
Implements event dispatcher with per-GVK filtering; provides Handle method for event forwarding based on filter matches and ResultChan method for event consumption. Includes unit tests covering dispatch behavior for matching/non-matching filters, absent filters, and multiple filter scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@p0lyn0mial
Copy link
Contributor Author

/assign @benluddy @bertinatto @csrwng

@openshift-ci openshift-ci bot added area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release and removed do-not-merge/needs-area labels Jan 19, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 19, 2026

@p0lyn0mial: This pull request references API-1835 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "4.22.0" version, but no target version was set.

Details

In response to this:

requires #7477

// inputResourceDispatcher is a simple dispatcher that applies GVK scoped filters
// and forwards matching events.
//
// Each GVK has its own set of filters. Today these
// may include name/namespace checks, and in the future label selectors.
//
// Longer term, this dispatcher is expected to track which input resources are
// associated with which operator.

please review feat(openshiftmanager-phase2): intro inputResourceDispatcher only

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 openshift-eng/jira-lifecycle-plugin repository.


func newInputResourceDispatcher(filters map[schema.GroupVersionKind][]inputResourceEventFilter) *inputResourceDispatcher {
return &inputResourceDispatcher{
eventsCh: make(chan event.GenericEvent, 10),
Copy link
Contributor Author

@p0lyn0mial p0lyn0mial Jan 19, 2026

Choose a reason for hiding this comment

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

I think I will change it to an unbuffered channel.
(let's start simple)

@p0lyn0mial p0lyn0mial force-pushed the om-phase-2-in-res-dispatcher-stub branch from 1445b4c to d2cb8af Compare January 19, 2026 13:44
@csrwng
Copy link
Contributor

csrwng commented Jan 19, 2026

/approve

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 19, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@control-plane-operator/controllers/openshiftmanager/input_resource_initializer.go`:
- Around line 47-49: The discoverInputResources function currently always
returns a "not implemented" error which blocks manager startup; change its
implementation in the inputResourceInitializer type so it returns an empty map
and nil error (e.g. make(map[string]*libraryinputresources.InputResources), nil)
to unblock startup, or implement the actual discovery logic used by
Start()/SetupWithManager if you prefer; locate and update discoverInputResources
(and ensure any callers like Start() handle an empty map) so the manager can
start successfully.

Comment on lines 47 to 49
func (r *inputResourceInitializer) discoverInputResources() (map[string]*libraryinputresources.InputResources, error) {
return nil, fmt.Errorf("not implemented")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find registration/usage of the initializer
rg -n -C3 '\bnewInputResourceInitializer\b|\binputResourceInitializer\b'

Repository: openshift/hypershift

Length of output: 8472


🏁 Script executed:

# Get the file structure and locate the Start method
fd 'input_resource_initializer.go' --exec cat -n {}

Repository: openshift/hypershift

Length of output: 5887


🏁 Script executed:

# Search for where this might be registered in the manager setup
rg -n -C5 'inputResourceInitializer|discoverInputResources'

Repository: openshift/hypershift

Length of output: 10105


discoverInputResources blocks manager startup with "not implemented" error.

The initializer is registered in SetupWithManager and its Start() method immediately calls discoverInputResources(), which returns an error. This prevents the manager from starting. Either implement the discovery or return an empty map temporarily to unblock startup.

💡 Suggested interim fix
 func (r *inputResourceInitializer) discoverInputResources() (map[string]*libraryinputresources.InputResources, error) {
-	return nil, fmt.Errorf("not implemented")
+	// TODO: implement discovery.
+	return map[string]*libraryinputresources.InputResources{}, nil
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func (r *inputResourceInitializer) discoverInputResources() (map[string]*libraryinputresources.InputResources, error) {
return nil, fmt.Errorf("not implemented")
}
func (r *inputResourceInitializer) discoverInputResources() (map[string]*libraryinputresources.InputResources, error) {
// TODO: implement discovery.
return map[string]*libraryinputresources.InputResources{}, nil
}
🤖 Prompt for AI Agents
In
`@control-plane-operator/controllers/openshiftmanager/input_resource_initializer.go`
around lines 47 - 49, The discoverInputResources function currently always
returns a "not implemented" error which blocks manager startup; change its
implementation in the inputResourceInitializer type so it returns an empty map
and nil error (e.g. make(map[string]*libraryinputresources.InputResources), nil)
to unblock startup, or implement the actual discovery logic used by
Start()/SetupWithManager if you prefer; locate and update discoverInputResources
(and ensure any callers like Start() handle an empty map) so the manager can
start successfully.

filters := d.filters[gvk]
if len(filters) == 0 {
d.eventsCh <- event.GenericEvent{Object: cObj}
return
Copy link
Member

Choose a reason for hiding this comment

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

Why dispatch the event if there are no filters? Is this an oversight?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Filter will be added in #7552

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, so i misunderstood you question.

don't have a good answer here, i can change it to return if there a no filters and we can always adjust the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it seems like, the initial list will contain "exact resources" only, xref: https://github.com/openshift/cluster-authentication-operator/blob/master/pkg/cmd/mom/input_resources_command.go#L18

so, it looks like we will always require some filters.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 22, 2026

@p0lyn0mial: This pull request references API-1835 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "4.22.0" version, but no target version was set.

Details

In response to this:

requires #7477

// inputResourceDispatcher is a simple dispatcher that applies GVK scoped filters
// and forwards matching events.
//
// Each GVK has its own set of filters. Today these
// may include name/namespace checks, and in the future label selectors.
//
// Longer term, this dispatcher is expected to track which input resources are
// associated with which operator.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 22, 2026
inputResourceDispatcher is a simple dispatcher that applies GVK scoped filters
and forwards matching events.

Each GVK has its own set of filters. Today these
may include name/namespace checks, and in the future label selectors.

Longer term, this dispatcher is expected to track which input resources are
associated with which operator.
@p0lyn0mial p0lyn0mial force-pushed the om-phase-2-in-res-dispatcher-stub branch from 76bb8a5 to c7512a9 Compare January 22, 2026 09:32
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 22, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: csrwng, p0lyn0mial

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

Copy link
Member

@bertinatto bertinatto left a comment

Choose a reason for hiding this comment

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

/lgmt

@p0lyn0mial
Copy link
Contributor Author

/verified by CI

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jan 22, 2026
@openshift-ci-robot
Copy link

@p0lyn0mial: This PR has been marked as verified by CI.

Details

In response to this:

/verified by CI

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 openshift-eng/jira-lifecycle-plugin repository.

@bertinatto
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 22, 2026
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD a4c53d1 and 2 for PR HEAD c7512a9 in total

@p0lyn0mial
Copy link
Contributor Author

/test e2e-aws

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 9f235bb and 1 for PR HEAD c7512a9 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 23d2d8d and 0 for PR HEAD c7512a9 in total

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 23, 2026

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

Test name Commit Details Required Rerun command
ci/prow/e2e-aws c7512a9 link true /test e2e-aws

Full PR test history. Your PR dashboard.

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.

@openshift-ci-robot
Copy link

/hold

Revision c7512a9 was retested 3 times: holding

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 23, 2026
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. area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants