Skip to content

OSAC-2238: expose dispatcher manager resolution as pkg/ utility for cross-operator import - #158

Closed
danmanor wants to merge 3 commits into
osac-project:mainfrom
danmanor:feat/OSAC-2238-dispatcher-pkg-export
Closed

OSAC-2238: expose dispatcher manager resolution as pkg/ utility for cross-operator import#158
danmanor wants to merge 3 commits into
osac-project:mainfrom
danmanor:feat/OSAC-2238-dispatcher-pkg-export

Conversation

@danmanor

@danmanor danmanor commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

OSAC-2238: Expose dispatcher manager resolution as pkg/ utility for cross-operator import

Jira: https://redhat.atlassian.net/browse/OSAC-2238

Summary

The pkg/dispatcher package's Resolver depended on privatev1.NetworkClassesClient from internal/api/, which blocked bare-metal-fulfillment-operator from importing it (Go's internal/ visibility rules). This PR introduces a NetworkClassFetcher interface in pkg/dispatcher/ that abstracts the NetworkClass fetch, and provides a gRPC adapter in internal/adapters/ for osac-operator's own use.

Changes

pkg/dispatcher/

  • Added NetworkClassFetcher interface and NetworkClassInfo struct (network_class_fetcher.go)
  • Updated Resolver to accept NetworkClassFetcher instead of privatev1.NetworkClassesClient
  • Removed internal/api/ import from resolver.go
  • Updated all test stubs (resolver, cached resolver, dispatcher tests) to implement the new interface

internal/adapters/

  • Added GRPCNetworkClassFetcher that wraps privatev1.NetworkClassesClient to implement dispatcher.NetworkClassFetcher
  • Full test coverage (4 tests: both managers, fabric-only, gRPC error, nil object)

Testing

  • Unit tests: 29 existing tests updated to use new interface (all pass), 4 new adapter tests added
  • Integration tests: N/A — no component interaction changes
  • Coverage: pkg/dispatcher 92.5%, internal/adapters 100%

Acceptance Criteria

  • pkg/dispatcher is importable by bare-metal-fulfillment-operator (no internal/ imports)
  • Resolver has no internal/api/ dependency in its public API
  • All existing dispatcher tests pass
  • Unblocks OSAC-2047 (BM reconcileNetworking)

Summary by CodeRabbit

  • New Features

    • Added support for retrieving network class configuration, including fabric and optional Kubernetes manager details.
    • Improved separation between network class retrieval and dispatch resolution.
  • Bug Fixes

    • Network class retrieval now handles client errors and missing response objects consistently.
  • Tests

    • Added coverage for successful retrieval, optional manager handling, error propagation, caching, and resolver behavior.

Define a NetworkClassFetcher interface and NetworkClassInfo struct that
abstract the NetworkClass fetch operation, allowing bare-metal-fulfillment-
operator (and other external modules) to import pkg/dispatcher without
depending on internal/api/ types.

Assisted-by: Claude Code <noreply@anthropic.com>
Signed-off-by: Dan Manor <dmanor@redhat.com>
Replace the privatev1.NetworkClassesClient dependency with the
NetworkClassFetcher interface, removing the internal/api/ import from
pkg/dispatcher. Update all test stubs to implement the new interface.

Assisted-by: Claude Code <noreply@anthropic.com>
Signed-off-by: Dan Manor <dmanor@redhat.com>
Provide GRPCNetworkClassFetcher in internal/adapters that wraps the
generated privatev1.NetworkClassesClient to implement the
dispatcher.NetworkClassFetcher interface. This gives osac-operator a
drop-in adapter for its existing gRPC client setup.

Assisted-by: Claude Code <noreply@anthropic.com>
Signed-off-by: Dan Manor <dmanor@redhat.com>
@openshift-ci-robot

openshift-ci-robot commented Aug 5, 2026

Copy link
Copy Markdown

@danmanor: This pull request references OSAC-2238 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 task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

OSAC-2238: Expose dispatcher manager resolution as pkg/ utility for cross-operator import

Jira: https://redhat.atlassian.net/browse/OSAC-2238

Summary

The pkg/dispatcher package's Resolver depended on privatev1.NetworkClassesClient from internal/api/, which blocked bare-metal-fulfillment-operator from importing it (Go's internal/ visibility rules). This PR introduces a NetworkClassFetcher interface in pkg/dispatcher/ that abstracts the NetworkClass fetch, and provides a gRPC adapter in internal/adapters/ for osac-operator's own use.

Changes

pkg/dispatcher/

  • Added NetworkClassFetcher interface and NetworkClassInfo struct (network_class_fetcher.go)
  • Updated Resolver to accept NetworkClassFetcher instead of privatev1.NetworkClassesClient
  • Removed internal/api/ import from resolver.go
  • Updated all test stubs (resolver, cached resolver, dispatcher tests) to implement the new interface

internal/adapters/

  • Added GRPCNetworkClassFetcher that wraps privatev1.NetworkClassesClient to implement dispatcher.NetworkClassFetcher
  • Full test coverage (4 tests: both managers, fabric-only, gRPC error, nil object)

Testing

  • Unit tests: 29 existing tests updated to use new interface (all pass), 4 new adapter tests added
  • Integration tests: N/A — no component interaction changes
  • Coverage: pkg/dispatcher 92.5%, internal/adapters 100%

Acceptance Criteria

  • pkg/dispatcher is importable by bare-metal-fulfillment-operator (no internal/ imports)
  • Resolver has no internal/api/ dependency in its public API
  • All existing dispatcher tests pass
  • Unblocks OSAC-2047 (BM reconcileNetworking)

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-ci

openshift-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danmanor

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 label Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 23560fb2-323e-4438-9dac-8dcfb27fd3f9

📥 Commits

Reviewing files that changed from the base of the PR and between a06cb2c and 91bc6b3.

📒 Files selected for processing (8)
  • osac-operator/internal/adapters/adapters_suite_test.go
  • osac-operator/internal/adapters/grpc_network_class_fetcher.go
  • osac-operator/internal/adapters/grpc_network_class_fetcher_test.go
  • osac-operator/pkg/dispatcher/dispatch_test.go
  • osac-operator/pkg/dispatcher/network_class_fetcher.go
  • osac-operator/pkg/dispatcher/resolver.go
  • osac-operator/pkg/dispatcher/resolver_cache_test.go
  • osac-operator/pkg/dispatcher/resolver_test.go

Walkthrough

The dispatcher now retrieves NetworkClass manager names through a NetworkClassFetcher interface. A gRPC adapter implements the interface, and resolver, cache, dispatch, and adapter tests use the new abstraction.

Changes

NetworkClass fetching and resolution

Layer / File(s) Summary
Resolver fetcher contract and integration
osac-operator/pkg/dispatcher/network_class_fetcher.go, osac-operator/pkg/dispatcher/resolver.go, osac-operator/pkg/dispatcher/*_test.go
NetworkClassInfo and NetworkClassFetcher define the lookup contract. Resolver consumes the fetcher and validates manager names. Resolver cache and dispatch tests use direct fetcher stubs.
gRPC fetcher adapter and coverage
osac-operator/internal/adapters/grpc_network_class_fetcher.go, osac-operator/internal/adapters/grpc_network_class_fetcher_test.go, osac-operator/internal/adapters/adapters_suite_test.go
The adapter calls the gRPC Get endpoint, propagates errors, rejects nil objects, and maps manager names into NetworkClassInfo. Ginkgo coverage validates these cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: tzvatot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants