Skip to content

API-1835: Scaffold dynamic informers - #7477

Merged
openshift-merge-bot[bot] merged 2 commits into
openshift:mainfrom
p0lyn0mial:om-phase-2-om-dyn-inf-stub
Jan 21, 2026
Merged

API-1835: Scaffold dynamic informers#7477
openshift-merge-bot[bot] merged 2 commits into
openshift:mainfrom
p0lyn0mial:om-phase-2-om-dyn-inf-stub

Conversation

@p0lyn0mial

@p0lyn0mial p0lyn0mial commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Adds an input resource initializer runnable for OpenShiftManager that discovers
input resources and wires informers, and registers it in the controller setup.

Notes: discovery is still a stub and we still need to register informer handlers and add filtering.

requires: #7445

@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 14, 2026
@openshift-ci-robot

openshift-ci-robot commented Jan 14, 2026

Copy link
Copy Markdown

@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:

Adds an input resource initializer runnable for OpenShiftManager that discovers
input resources and wires informers, and registers it in the controller setup.

Notes: discovery is still a stub and we still need to register informer handlers and add filtering.

requires: #7445

please review only the last commit.

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.

@coderabbitai

coderabbitai Bot commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a non-exported inputResourceInitializer that discovers and validates operator input resources, resolves GVKs via the management RESTMapper, starts deduplicated informers on the management cache and waits for cache sync; wires the initializer into controller setup, adds unit tests, and updates go.mod.

Changes

Cohort / File(s) Summary
Input Resource Initializer Implementation
control-plane-operator/controllers/openshiftmanager/input_resource_initializer.go
New file introducing inputResourceInitializer and newInputResourceInitializer; implements Start(ctx) error, stubbed discoverInputResources(), checkSupportedInputResources, GVK resolution via RESTMapper, deduplicated informer start via cache.GetInformerForKind + BlockUntilSynced, cache sync wait, and TODOs for event handlers.
Controller Integration
control-plane-operator/controllers/openshiftmanager/openshiftmanager_controller.go
Replaces a not-implemented return with creation and registration of the inputResourceInitializer using mgr.GetRESTMapper() and mgr.GetCache(); removes an unused fmt import.
Unit Tests & Test Helpers
control-plane-operator/controllers/openshiftmanager/input_resource_initializer_test.go
New tests exercising checkSupportedInputResources and startAndWaitForInformersFor; includes fakeCache, fakeRESTMapperFor, scenarios for GVK deduplication, mapper errors, informer errors, and cache sync outcomes.
Module Dependencies
go.mod
Adds github.com/openshift/multi-operator-manager v0.0.0-20260112172834-b64ebc8c627b and new indirect dependencies (github.com/PaesslerAG/gval, github.com/PaesslerAG/jsonpath, github.com/shopspring/decimal).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing touches
  • 📝 Generate docstrings

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

@p0lyn0mial

Copy link
Copy Markdown
Contributor Author

/assign @benluddy @bertinatto @csrwng

@openshift-ci
openshift-ci Bot requested review from jparrill and sjenning January 14, 2026 13:07
@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 14, 2026
}

func (r *inputResourceInitializer) discoverInputResources() (map[string]*libraryinputresources.InputResources, error) {
return nil, fmt.Errorf("not implemented")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@benluddy this is where we could use the file sytem queue client to discover the input-res per operator.

}

if registeredGVK.Has(gvk.String()) {
continue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

so that we don't register multiple event handlers for the same gvk

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.

We could register multiple even handlers once we have more than one operator, right? Would make sense to move the declaration of registeredGVK out of the loop?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that gvk can only be registered once. For operators requiring the same gvk we will register multiple filters.

//
// TODO: in the future we need to extend to full list
registeredGVK := sets.NewString()
for _, exactResource := range resources.ApplyConfigurationResources.ExactResources {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

for the poc we only support ApplyConfigurationResources.ExactResources in the future we need to cover the entire list

return ctx.Err()
}
return fmt.Errorf("caches did not sync")
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i forgot to add a TODO but at the end we need to send a signal to the main controller the caches are ready.

if err != nil {
return err
}
// TODO: register informer event handlers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

events will be passed to a different component that will be responsible for mapping resources to an operator and trigger the main controller. something like "if X resource(s) change then call/rigger this operator"

"context"
"fmt"

"github.com/openshift/multi-operator-manager/pkg/library/libraryinputresources"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we will also pull a new dep

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do modules that depend on multi-operator-manager need to keep their Kube dependencies in sync with multi-operator-manager's Kube dependencies? I don't know if we will (in the future) want/need to either (a) avoid a specific dependency in multi-operator-manager or (b) split multi-operator-manager into separate modules for e.g. parent, child, API.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, I think the modules need to keep their Kube deps in sync with the multi-operator-manager’s Kube deps.

this is a similar situation to what we already have today with library-go, which is used by HyperShift and also depends on a specific Kube version.

moreover, multi-operator-manager also uses library-go.

because of these intertwined dependencies, I think that we will be forced to keep all of the deps at the same level.

@p0lyn0mial
p0lyn0mial force-pushed the om-phase-2-om-dyn-inf-stub branch 3 times, most recently from ab546fb to 29cde6f Compare January 16, 2026 11:31
@openshift-ci-robot

openshift-ci-robot commented Jan 16, 2026

Copy link
Copy Markdown

@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:

Adds an input resource initializer runnable for OpenShiftManager that discovers
input resources and wires informers, and registers it in the controller setup.

Notes: discovery is still a stub and we still need to register informer handlers and add filtering.

requires: #7445

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.

@csrwng

csrwng commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

/approve

Looks like you need to fix your commit messages.

@openshift-ci

openshift-ci Bot commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

[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

@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
@p0lyn0mial
p0lyn0mial force-pushed the om-phase-2-om-dyn-inf-stub branch from b6fda8d to b153504 Compare January 19, 2026 13:51
@p0lyn0mial

Copy link
Copy Markdown
Contributor Author

/verified by CI

@p0lyn0mial

Copy link
Copy Markdown
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 20, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@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.

@p0lyn0mial
p0lyn0mial force-pushed the om-phase-2-om-dyn-inf-stub branch from bd90b05 to 2a4b59b Compare January 20, 2026 11:27
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Jan 20, 2026
@p0lyn0mial

Copy link
Copy Markdown
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 20, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@control-plane-operator/controllers/openshiftmanager/input_resource_initializer.go`:
- Around line 36-49: The discoverInputResources function currently returns a
"not implemented" error which causes inputResourceInitializer.Start to always
fail; change discoverInputResources to return an empty
map[string]*libraryinputresources.InputResources and a nil error (i.e., make it
a no-op stub) so Start can proceed to checkSupportedInputResources and
startAndWaitForInformersFor without failing; update the function body of
discoverInputResources (referenced by inputResourceInitializer.Start) to return
make(map[string]*libraryinputresources.InputResources), nil.
♻️ Duplicate comments (1)
control-plane-operator/controllers/openshiftmanager/input_resource_initializer.go (1)

51-86: Deduplicate GVK registrations across operators.

registeredGVK is reset per-operator, so shared GVKs across operators will repeat GetInformerForKind calls and could lead to duplicate event handlers later. Consider de-duplicating across all operators.

♻️ Suggested refactor
 func (r *inputResourceInitializer) startAndWaitForInformersFor(ctx context.Context, inputResources map[string]*libraryinputresources.InputResources) error {
-	for operator, resources := range inputResources {
+	registeredGVK := sets.NewString()
+	for operator, resources := range inputResources {
 		// note that for the POC we are only interested in ApplyConfigurationResources.ExactResources
 		// the checkSupportedInputResources ensures no other resources were provided.
 		//
 		// TODO: in the future we need to extend to full list
-		registeredGVK := sets.NewString()
 		for _, exactResource := range resources.ApplyConfigurationResources.ExactResources {
 			gvr := schema.GroupVersionResource{Group: exactResource.Group, Version: exactResource.Version, Resource: exactResource.Resource}
 			gvk, err := r.managementClusterRESTMapper.KindFor(gvr)

Comment on lines +36 to +49
func (r *inputResourceInitializer) Start(ctx context.Context) error {
inputResources, err := r.discoverInputResources()
if err != nil {
return err
}
if err = r.checkSupportedInputResources(inputResources); err != nil {
return err
}
return r.startAndWaitForInformersFor(ctx, inputResources)
}

func (r *inputResourceInitializer) discoverInputResources() (map[string]*libraryinputresources.InputResources, error) {
return nil, fmt.Errorf("not implemented")
}

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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n control-plane-operator/controllers/openshiftmanager/input_resource_initializer.go

Repository: openshift/hypershift

Length of output: 6116


🏁 Script executed:

cd control-plane-operator/controllers/openshiftmanager && rg -A 5 -B 5 "newInputResourceInitializer|inputResourceInitializer" --type go

Repository: openshift/hypershift

Length of output: 6171


🏁 Script executed:

cd control-plane-operator && rg -B 5 -A 5 "SetupWithManager" controllers/openshiftmanager/openshiftmanager_controller.go

Repository: openshift/hypershift

Length of output: 426


🏁 Script executed:

cd control-plane-operator/controllers/openshiftmanager && git log --oneline -n 20 input_resource_initializer.go

Repository: openshift/hypershift

Length of output: 114


🏁 Script executed:

cd control-plane-operator/controllers/openshiftmanager && git log --oneline -n 50 | head -20

Repository: openshift/hypershift

Length of output: 114


🏁 Script executed:

cd control-plane-operator/controllers/openshiftmanager && git show 2a4b59b46 --stat

Repository: openshift/hypershift

Length of output: 50378


🏁 Script executed:

cd control-plane-operator/controllers/openshiftmanager && grep -r "SetupWithManager\|Add.*inputResInitializer" --include="*.go" -B 10 -A 2

Repository: openshift/hypershift

Length of output: 1002


🏁 Script executed:

cd control-plane-operator && rg "SetupWithManager.*OpenShiftManager\|openshiftmanager_controller.Reconciler" --include="*.go" -B 5 -A 5

Repository: openshift/hypershift

Length of output: 505


🏁 Script executed:

cd control-plane-operator && rg "SetupWithManager" -t go -B 5 -A 5 | head -50

Repository: openshift/hypershift

Length of output: 2730


🏁 Script executed:

cd control-plane-operator && rg "openshiftmanager.*Reconciler\|OpenShiftManager" -t go -B 3 -A 3

Repository: openshift/hypershift

Length of output: 46


🏁 Script executed:

cd control-plane-operator && rg "openshiftmanager" -t go -i

Repository: openshift/hypershift

Length of output: 558


🏁 Script executed:

cd control-plane-operator && rg "openshiftmanager.Reconciler\|controllers/openshiftmanager" -t go -B 5 -A 5

Repository: openshift/hypershift

Length of output: 46


🏁 Script executed:

cd control-plane-operator && find . -name "main.go" -type f | xargs grep -l "openshiftmanager\|OpenShiftManager" 2>/dev/null

Repository: openshift/hypershift

Length of output: 48


🏁 Script executed:

cd control-plane-operator && find . -name "*.go" -type f | xargs grep -l "SetupWithManager" | head -5

Repository: openshift/hypershift

Length of output: 352


🏁 Script executed:

cd control-plane-operator && find . -name "main.go" | xargs cat | grep -B 10 -A 10 "openshiftmanager"

Repository: openshift/hypershift

Length of output: 46


🏁 Script executed:

cd control-plane-operator && find . -name "main.go" -o -name "setup.go" | head -5

Repository: openshift/hypershift

Length of output: 364


Return empty map instead of error to prevent startup failure.

The Start method will always fail with the "not implemented" error from discoverInputResources, causing manager startup to fail whenever this initializer is enabled. The suggested fix to return an empty map is the appropriate mitigation until discovery is implemented.

🛠️ Suggested no-op stub to avoid startup failure
 func (r *inputResourceInitializer) discoverInputResources() (map[string]*libraryinputresources.InputResources, error) {
-	return nil, fmt.Errorf("not implemented")
+	// TODO: implement discovery; for now return no input resources.
+	return map[string]*libraryinputresources.InputResources{}, nil
 }
🤖 Prompt for AI Agents
In
`@control-plane-operator/controllers/openshiftmanager/input_resource_initializer.go`
around lines 36 - 49, The discoverInputResources function currently returns a
"not implemented" error which causes inputResourceInitializer.Start to always
fail; change discoverInputResources to return an empty
map[string]*libraryinputresources.InputResources and a nil error (i.e., make it
a no-op stub) so Start can proceed to checkSupportedInputResources and
startAndWaitForInformersFor without failing; update the function body of
discoverInputResources (referenced by inputResourceInitializer.Start) to return
make(map[string]*libraryinputresources.InputResources), nil.


_, err = r.managementClusterCache.GetInformerForKind(ctx, gvk, cache.BlockUntilSynced(true))
if err != nil {
return err

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.

nit: maybe add some context for this error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can do that in a follow-up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Had to rebase (Konflux) the PR and decided to add more context.

}

if registeredGVK.Has(gvk.String()) {
continue

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.

We could register multiple even handlers once we have more than one operator, right? Would make sense to move the declaration of registeredGVK out of the loop?

@bertinatto bertinatto left a comment

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.

/lgtm

I think we can follow-up with a different PR if we need other changes.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jan 20, 2026
@openshift-ci-robot

Copy link
Copy Markdown

/retest-required

Remaining retests: 0 against base HEAD ee28abe and 2 for PR HEAD 2a4b59b in total

Adds an input resource initializer runnable for OpenShiftManager that discovers
input resources and wires informers, and registers it in the controller setup.

Notes: discovery is still a stub and we still need to register informer handlers and add filtering.
updated dependencies reqired by the changes
introduced in 7477 PR.
@p0lyn0mial
p0lyn0mial force-pushed the om-phase-2-om-dyn-inf-stub branch from 2a4b59b to e47fe05 Compare January 21, 2026 08:28
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Jan 21, 2026
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 21, 2026
@p0lyn0mial

Copy link
Copy Markdown
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 21, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@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.

@p0lyn0mial

Copy link
Copy Markdown
Contributor Author

/retest-required

@p0lyn0mial

Copy link
Copy Markdown
Contributor Author

/verified by CI

@openshift-ci-robot

Copy link
Copy Markdown

@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
Copy Markdown
Member

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jan 21, 2026
@openshift-ci

openshift-ci Bot commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

@p0lyn0mial: all tests passed!

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-merge-bot
openshift-merge-bot Bot merged commit 3678760 into openshift:main Jan 21, 2026
21 checks passed
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 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.

5 participants