← Back to Pull requests

OSAC-3132: migrate networking feedback controllers to Bridge #401

Merged
vladikr merged 4 files (1065 lines) on Jul 29, 2026 13:16 UTC
View on GitHub
vladikr vladikr commented on Jul 29, 2026 11:57 UTC
Author

Summary

Migrate four networking feedback controllers to use the feedback.Bridge extracted in PR #387. Each controller is migrated in a separate commit for easy review.

| Commit | Controller | Lines removed |
|--------|-----------|---------------|
| 1 | VirtualNetwork | 273 → 120 |
| 2 | SecurityGroup | 278 → 118 |
| 3 | NATGateway | 245 → 117 |
| 4 | ExternalIPPool | 299 → 121 |

All four follow the exact same pattern as the Subnet migration in #387 — the reconciler struct is thinned to hold only the Bridge and namespace, the constructor wires the Bridge callbacks, and Reconcile delegates to bridge.Reconcile. Only the resource-specific sync functions (phase mapping, delete state mapping) remain.

Changes per controller

  • Replaced the 6-step hand-written Reconcile with bridge.Reconcile delegation

  • Removed FeedbackReconcilerTask struct, fetch, save, handleUpdate, handleDelete methods

  • Kept resource-specific syncPhase and syncDelete as standalone functions

  • Added nil guard on GetObject() in Fetch callbacks (consistent with Subnet in #387)

  • SetupWithManager unchanged
  • Notable: VirtualNetwork

    VN proto has no DELETING/DELETE_FAILED states — deletion maps Failed → FAILED and everything else → PENDING. This behavior is preserved exactly from the original.

    What's next

    Per the migration plan in #387:

  • ~~Subnet~~ (PR #387)

  • VirtualNetwork, SecurityGroup, NATGateway, ExternalIPPool (this PR)

  • ComputeInstance (gains missing NotFound fix)

  • ClusterOrder (gains missing NotFound fix)

  • ExternalIP (uses IsNotFound)

  • ExternalIPAttachment (uses PostSaveOnDelete)
  • Test plan

  • make lint — 0 issues

  • make test — all pass (controller coverage 72.0%)

  • All existing feedback controller tests pass unchanged for each migrated controller
  • Jira: https://redhat.atlassian.net/browse/OSAC-3132

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    Refactor
    Improved synchronization of external IP pools, NAT gateways, security groups, and virtual networks with the fulfillment service.
    Standardized update and deletion handling across supported networking resources.
    Improved propagation of resource phases and deletion failures to corresponding remote states.
    Preserved existing controller registration and namespace-based event filtering.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 1065 lines (+251 / -814) across 4 files Reviewer: tzvatot Review duration: 78m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.71) × (1 − Review Confidence (0.75)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.71 · 1065 lines diff across 4 files
    0.71
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.53 · 5 substantive comment(s)
    0.53
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    75%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Sensitive Paths sensitive_paths
    0.071
    Real PR Conversation Timeline
    11 items
    openshift-ci-robot openshift-ci-robot commented on Jul 29, 2026 11:57 UTC
    Contributor

    @vladikr: This pull request references OSAC-3132 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:

    >## Summary

    >Migrate four networking feedback controllers to use the feedback.Bridge extracted in PR #387. Each controller is migrated in a separate commit for easy review.

    >| Commit | Controller | Lines removed |

    >|--------|-----------|---------------|
    >| 1 | VirtualNetwork | 273 → 120 |
    >| 2 | SecurityGroup | 278 → 118 |
    >| 3 | NATGateway | 245 → 117 |
    >| 4 | ExternalIPPool | 299 → 121 |
    >All four follow the exact same pattern as the Subnet migration in #387 — the reconciler struct is thinned to hold only the Bridge and namespace, the constructor wires the Bridge callbacks, and Reconcile delegates to bridge.Reconcile. Only the resource-specific sync functions (phase mapping, delete state mapping) remain.

    >## Changes per controller

    >- Replaced the 6-step hand-written Reconcile with bridge.Reconcile delegation

    >- Removed FeedbackReconcilerTask struct, fetch, save, handleUpdate, handleDelete methods
    >- Kept resource-specific sync
    Phase and sync*Delete as standalone functions
    >- Added nil guard on GetObject() in Fetch callbacks (consistent with Subnet in #387)
    >- SetupWithManager unchanged
    >## Notable: VirtualNetwork

    >VN proto has no DELETING/DELETE_FAILED states — deletion maps Failed → FAILED and everything else → PENDING. This behavior is preserved exactly from the original.

    >## What's next

    >Per the migration plan in #387:

    >- [x] ~~Subnet~~ (PR #387)

    >- [x] VirtualNetwork, SecurityGroup, NATGateway, ExternalIPPool (this PR)
    >- [ ] ComputeInstance (gains missing NotFound fix)
    >- [ ] ClusterOrder (gains missing NotFound fix)
    >- [ ] ExternalIP (uses IsNotFound)
    >- [ ] ExternalIPAttachment (uses PostSaveOnDelete)
    >## Test plan

    >- [x] make lint — 0 issues

    >- [x] make test — all pass (controller coverage 72.0%)
    >- [x] All existing feedback controller tests pass unchanged for each migrated controller
    >Jira: https://redhat.atlassian.net/browse/OSAC-3132

    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.
    </details>

    coderabbitai[bot] coderabbitai[bot] commented on Jul 29, 2026 11:58 UTC
    Bot

    <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
    <!-- review_stack_entry_start -->

    ![Review Change Stack](https://app.coderabbit.ai/change-stack/osac-project/osac-operator/pull/401?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

    <!-- review_stack_entry_end -->
    <!-- This is an auto-generated comment: rate limited by coderabbit.ai -->

    [!WARNING]

    ## Review limit reached

    > @vladikr, you've reached your PR review limit, so we couldn't start this review.

    > Next review available in: 40 minutes

    > Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.

    You're only billed for reviews past your plan's rate limits ($0.25/file).

    > <details>

    <summary>How can I continue?</summary>

    > After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

    > To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

    > </details>

    >

    <details>

    <summary>How do review limits work?</summary>

    > CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

    > For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

    > Please refer docs for additional details.

    > </details>

    > <details>

    <summary>Review details</summary>

    > <details>

    <summary>⚙️ Run configuration</summary>

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

    > Review profile: ASSERTIVE

    > Plan: Pro Plus

    > Run ID: f8e856cc-da44-4aff-98a9-e4a293f3310a

    > </details>

    > <details>

    <summary>📥 Commits</summary>

    > Reviewing files that changed from the base of the PR and between 39dc67adf02720cb4534de883bc81ca925610915 and 674c2b84de48fd1716f3f0cec50cdbf8f59e9378.

    > </details>

    > <details>

    <summary>📒 Files selected for processing (1)</summary>

    > internal/controller/externalippool_feedback_controller.go

    > </details>

    > </details>

    <!-- end of auto-generated comment: rate limited by coderabbit.ai -->

    <!-- walkthrough_start -->

    Walkthrough

    Four feedback controllers were refactored to use a shared feedback.Bridge. Constructors configure fulfillment-service callbacks and phase synchronization, while Reconcile delegates to the bridge.

    Changes

    Feedback bridge reconciliation

    |Layer / File(s)|Summary|
    |---|---|
    |Bridge construction and callback wiring <br> internal/controller/
    _feedback_controller.go|The four reconcilers now store typed bridges configured with fulfillment-service fetch, save, signal, object initialization, identity metadata, and synchronization callbacks.|
    |Delegated reconciliation and phase synchronization <br> internal/controller/*_feedback_controller.go|Reconcile delegates to bridge.Reconcile; update and delete callbacks map CR phases to fulfillment-service states, including deletion failure handling and unknown-phase logging.|

    Estimated code review effort: 4 (Complex) | ~45 minutes

    Possibly related PRs

  • osac-project/osac-operator#387: Introduces the shared feedback.Bridge pattern used by these controller refactors.

  • osac-project/osac-operator#384: Modifies deletion and gRPC NotFound handling in the same feedback controllers.

  • osac-project/osac-operator#346: Adds the NATGateway feedback controller whose reconciliation is refactored here.
  • Suggested labels: ok-to-test

    Suggested reviewers: alosadagrande

    <!-- walkthrough_end -->
    <!-- pre_merge_checks_walkthrough_start -->

    <details>
    <summary>🚥 Pre-merge checks | ✅ 11</summary>

    <details>
    <summary>✅ Passed checks (11 passed)</summary>

    | Check name | Status | Explanation |
    | :------------------------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
    | Title check | ✅ Passed | The title clearly matches the main change: migrating networking feedback controllers to the shared Bridge abstraction. |
    | Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
    | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
    | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
    | No-Hardcoded-Secrets | ✅ Passed | Scanned the four modified controllers; no hardcoded secrets, embedded-credential URLs, private keys, base64 blobs, or credential-named string literals found. |
    | No-Weak-Crypto | ✅ Passed | PASS: Reviewed the migrated controllers and shared bridge; no MD5/SHA1/DES/RC4/ECB, custom crypto, or secret-comparison code was added. |
    | No-Injection-Vectors | ✅ Passed | PASS: The touched controllers only use typed gRPC builders and bridge delegation; no eval/exec, shell, yaml.load, os.system, pickle, SQL, or unsafe DOM sinks found. |
    | Container-Privileges | ✅ Passed | Repo-wide scan found no privileged/hostPID/hostNetwork/hostIPC/SYS_ADMIN/use-as-root settings; manifests only show allowPrivilegeEscalation: false. |
    | No-Sensitive-Data-In-Logs | ✅ Passed | Only generic unknown-phase logs appear, and they print a phase enum—not secrets, PII, hostnames, or customer data. |
    | Ai-Attribution | ✅ Passed | All four PR commits include Assisted-by: Claude Code trailers, and the PR range has no Co-Authored-By AI attribution. |

    </details>

    </details>

    <!-- pre_merge_checks_walkthrough_end -->
    <!-- finishing_touch_checkbox_start -->

    <details>
    <summary>✨ Finishing Touches</summary>

    <details>
    <summary>🧪 Generate unit tests (beta)</summary>

  • <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests
  • </details>

    </details>

    <!-- finishing_touch_checkbox_end -->
    <!-- tips_start -->

    ---

    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.

    <details>
    <summary>❤️ Share</summary>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </details>

    <sub>Comment @coderabbitai help to get the list of available commands.</sub>

    <!-- tips_end -->

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 29, 2026 12:01 UTC
    Code Review
    internal/controller/externalippool_feedback_controller.go:1
    @@ -18,50 +18,71 @@ import (
     	"fmt"
     
     	"google.golang.org/grpc"
    -	"google.golang.org/grpc/codes"
    -	"google.golang.org/grpc/status"
     	ctrl "sigs.k8s.io/controller-runtime"
     	"sigs.k8s.io/controller-runtime/pkg/builder"
     	clnt "sigs.k8s.io/controller-runtime/pkg/client"
    -	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
     	ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
     	mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager"
     
     	"github.com/osac-project/osac-operator/api/v1alpha1"
     	privatev1 "github.com/osac-project/osac-operator/internal/api/osac/private/v1"
    +	"github.com/osac-project/osac-operator/internal/controller/feedback"
     )
     
    -// ExternalIPPoolFeedbackReconciler watches ExternalIPPool CRs on the hub cluster and reports their phase and capacity back
    -// to the fulfillment service via gRPC. This is the reverse channel: the provisioning controller drives the CR forward,
    -// while this controller keeps the fulfillment service in sync with the CR's current state.
    +// ExternalIPPoolFeedbackReconciler sends updates to the fulfillment service.
     type ExternalIPPoolFeedbackReconciler struct {
    -	hubClient            clnt.Client
    -	externalIPPoolClient privatev1.ExternalIPPoolsClient
    -	networkingNamespace  string
    -}
    -
    -// externalIPPoolFeedbackReconcilerTask is a per-reconciliation scratch pad. It holds a clone of the proto object so we
    -// can mutate it freely and then diff against the original to decide whether a gRPC Update is actually needed, avoiding
    -// unnecessary API calls when nothing changed.
    -type externalIPPoolFeedbackReconcilerTask struct {
    -	r              *ExternalIPPoolFeedbackReconciler
    -	object         *v1alpha1.ExternalIPPool
    -	externalIPPool *privatev1.ExternalIPPool
    +	bridge              *feedback.Bridge[*v1alpha1.ExternalIPPool, *privatev1.ExternalIPPool]
    +	networkingNamespace string
     }
     
     // NewExternalIPPoolFeedbackReconciler creates a reconciler that sends to the fulfillment service updates about
     // external IP pools.
     func NewExternalIPPoolFeedbackReconciler(hubClient clnt.Client, grpcConn *grpc.ClientConn, networkingNamespace string) *ExternalIPPoolFeedbackReconciler {
    -	return &ExternalIPPoolFeedbackReconciler{
    -		hubClient:            hubClient,
    -		externalIPPoolClient: privatev1.NewExternalIPPoolsClient(grpcConn),
    -		networkingNamespace:  networkingNamespace,
    +	poolClient := privatev1.NewExternalIPPoolsClient(grpcConn)
    +	r := &ExternalIPPoolFeedbackReconciler{networkingNamespace: networkingNamespace}
    +	r.bridge = &feedback.Bridge[*v1alpha1.ExternalIPPool, *privatev1.ExternalIPPool]{
    +		Client:    hubClient,
    +		Finalizer: osacExternalIPPoolFeedbackFinalizer,
    +		IDLabel:   osacExternalIPPoolIDLabel,
    +		Kind:      "ExternalIPPool",
    +		IDKey:     "externalIPPoolID",
    +		NewObject: func() *v1alpha1.ExternalIPPool { return &v1alpha1.ExternalIPPool{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.ExternalIPPool, error) {
    +			response, err := poolClient.Get(ctx, privatev1.ExternalIPPoolsGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
    +			}
    +			pool := response.GetObject()
    +			if pool == nil {
    +				return nil, fmt.Errorf("external IP pool not found: response contained nil object")
    +			}
    +			if !pool.HasSpec() {
    +				pool.SetSpec(&privatev1.ExternalIPPoolSpec{})
    +			}
    +			if !pool.HasStatus() {
    +				pool.SetStatus(&privatev1.ExternalIPPoolStatus{})
    +			}
    +			return pool, nil
    +		},

    _📐 Maintainability & Code Quality_ | _🔵 Trivial_ | _💤 Low value_

    Use errors.New here for consistency with the sibling controllers.

    fmt.Errorf with no format verbs is just errors.New; the other three migrated controllers already use errors.New. Some linters (perfsprint) flag this too.

    <details>
    <summary>♻️ Suggested tweak</summary>

    -			if pool == nil {
    -				return nil, fmt.Errorf("external IP pool not found: response contained nil object")
    -			}
    +			if pool == nil {
    +				return nil, errors.New("external IP pool response contained nil object")
    +			}
    

    Add the import:

    import (
    	"errors"
    	"fmt"
    )
    

    </details>

    <!-- suggestion_start -->

    <details>
    <summary>📝 Committable suggestion</summary>

    ‼️ 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.

    		Fetch: func(ctx context.Context, id string) (*privatev1.ExternalIPPool, error) {
    			response, err := poolClient.Get(ctx, privatev1.ExternalIPPoolsGetRequest_builder{Id: id}.Build())
    			if err != nil {
    				return nil, err
    			}
    			pool := response.GetObject()
    			if pool == nil {
    				return nil, errors.New("external IP pool response contained nil object")
    			}
    			if !pool.HasSpec() {
    				pool.SetSpec(&privatev1.ExternalIPPoolSpec{})
    			}
    			if !pool.HasStatus() {
    				pool.SetStatus(&privatev1.ExternalIPPoolStatus{})
    			}
    			return pool, nil
    		},
    

    </details>

    <!-- suggestion_end -->

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@internal/controller/externalippool_feedback_controller.go` around lines 50 -
    66, In the Fetch callback, replace the fmt.Errorf call used for the nil pool
    response with errors.New, and add the errors import while retaining fmt if used
    elsewhere in the file. Keep the existing error message unchanged.
    

    </details>

    <!-- fingerprinting:phantom:medusa:komodo -->

    <!-- cr-indicator-types:nitpick -->

    <!-- cr-comment:v1:3454a6b280786270e38baddb -->

    <!-- This is an auto-generated reply by CodeRabbit -->

    ✅ Addressed in commit 674c2b8

    coderabbitai[bot] coderabbitai[bot] requested changes on Jul 29, 2026 12:01 UTC
    Changes Requested Reviewer

    Actionable comments posted: 1

    <details>
    <summary>🤖 Prompt for all review comments with AI agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    Inline comments:
    In `@internal/controller/externalippool_feedback_controller.go`:
    - Around line 50-66: In the Fetch callback, replace the fmt.Errorf call used for
    the nil pool response with errors.New, and add the errors import while retaining
    fmt if used elsewhere in the file. Keep the existing error message unchanged.
    

    </details>

    <details>
    <summary>🪄 Autofix (Beta)</summary>

    Fix all unresolved CodeRabbit comments on this PR:

  • <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)

  • <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes
  • </details>

    ---

    <details>
    <summary>ℹ️ Review info</summary>

    <details>
    <summary>⚙️ Run configuration</summary>

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

    Review profile: ASSERTIVE

    Plan: Pro Plus

    Run ID: 2e08bb6f-ccf4-4e84-820e-6594859fc1bd

    </details>

    <details>
    <summary>📥 Commits</summary>

    Reviewing files that changed from the base of the PR and between 919373435f94b9a8a997baeb3a90e9a06980617f and 39dc67adf02720cb4534de883bc81ca925610915.

    </details>

    <details>
    <summary>📒 Files selected for processing (4)</summary>

    internal/controller/externalippool_feedback_controller.go
    internal/controller/natgateway_feedback_controller.go
    internal/controller/securitygroup_feedback_controller.go
    internal/controller/virtualnetwork_feedback_controller.go

    </details>

    </details>

    <!-- This is an auto-generated comment by CodeRabbit for review status -->

    coderabbitai[bot] coderabbitai[bot] approved these changes on Jul 29, 2026 12:18 UTC
    Approved Reviewer

    Approved these changes.

    vladikr vladikr commented on code on Jul 29, 2026 12:18 UTC
    Code Review
    internal/controller/externalippool_feedback_controller.go:1
    @@ -18,50 +18,71 @@ import (
     	"fmt"
     
     	"google.golang.org/grpc"
    -	"google.golang.org/grpc/codes"
    -	"google.golang.org/grpc/status"
     	ctrl "sigs.k8s.io/controller-runtime"
     	"sigs.k8s.io/controller-runtime/pkg/builder"
     	clnt "sigs.k8s.io/controller-runtime/pkg/client"
    -	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
     	ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
     	mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager"
     
     	"github.com/osac-project/osac-operator/api/v1alpha1"
     	privatev1 "github.com/osac-project/osac-operator/internal/api/osac/private/v1"
    +	"github.com/osac-project/osac-operator/internal/controller/feedback"
     )
     
    -// ExternalIPPoolFeedbackReconciler watches ExternalIPPool CRs on the hub cluster and reports their phase and capacity back
    -// to the fulfillment service via gRPC. This is the reverse channel: the provisioning controller drives the CR forward,
    -// while this controller keeps the fulfillment service in sync with the CR's current state.
    +// ExternalIPPoolFeedbackReconciler sends updates to the fulfillment service.
     type ExternalIPPoolFeedbackReconciler struct {
    -	hubClient            clnt.Client
    -	externalIPPoolClient privatev1.ExternalIPPoolsClient
    -	networkingNamespace  string
    -}
    -
    -// externalIPPoolFeedbackReconcilerTask is a per-reconciliation scratch pad. It holds a clone of the proto object so we
    -// can mutate it freely and then diff against the original to decide whether a gRPC Update is actually needed, avoiding
    -// unnecessary API calls when nothing changed.
    -type externalIPPoolFeedbackReconcilerTask struct {
    -	r              *ExternalIPPoolFeedbackReconciler
    -	object         *v1alpha1.ExternalIPPool
    -	externalIPPool *privatev1.ExternalIPPool
    +	bridge              *feedback.Bridge[*v1alpha1.ExternalIPPool, *privatev1.ExternalIPPool]
    +	networkingNamespace string
     }
     
     // NewExternalIPPoolFeedbackReconciler creates a reconciler that sends to the fulfillment service updates about
     // external IP pools.
     func NewExternalIPPoolFeedbackReconciler(hubClient clnt.Client, grpcConn *grpc.ClientConn, networkingNamespace string) *ExternalIPPoolFeedbackReconciler {
    -	return &ExternalIPPoolFeedbackReconciler{
    -		hubClient:            hubClient,
    -		externalIPPoolClient: privatev1.NewExternalIPPoolsClient(grpcConn),
    -		networkingNamespace:  networkingNamespace,
    +	poolClient := privatev1.NewExternalIPPoolsClient(grpcConn)
    +	r := &ExternalIPPoolFeedbackReconciler{networkingNamespace: networkingNamespace}
    +	r.bridge = &feedback.Bridge[*v1alpha1.ExternalIPPool, *privatev1.ExternalIPPool]{
    +		Client:    hubClient,
    +		Finalizer: osacExternalIPPoolFeedbackFinalizer,
    +		IDLabel:   osacExternalIPPoolIDLabel,
    +		Kind:      "ExternalIPPool",
    +		IDKey:     "externalIPPoolID",
    +		NewObject: func() *v1alpha1.ExternalIPPool { return &v1alpha1.ExternalIPPool{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.ExternalIPPool, error) {
    +			response, err := poolClient.Get(ctx, privatev1.ExternalIPPoolsGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
    +			}
    +			pool := response.GetObject()
    +			if pool == nil {
    +				return nil, fmt.Errorf("external IP pool not found: response contained nil object")
    +			}
    +			if !pool.HasSpec() {
    +				pool.SetSpec(&privatev1.ExternalIPPoolSpec{})
    +			}
    +			if !pool.HasStatus() {
    +				pool.SetStatus(&privatev1.ExternalIPPoolStatus{})
    +			}
    +			return pool, nil
    +		},

    done

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 29, 2026 12:18 UTC
    Code Review
    internal/controller/externalippool_feedback_controller.go:1
    @@ -18,50 +18,71 @@ import (
     	"fmt"
     
     	"google.golang.org/grpc"
    -	"google.golang.org/grpc/codes"
    -	"google.golang.org/grpc/status"
     	ctrl "sigs.k8s.io/controller-runtime"
     	"sigs.k8s.io/controller-runtime/pkg/builder"
     	clnt "sigs.k8s.io/controller-runtime/pkg/client"
    -	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
     	ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
     	mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager"
     
     	"github.com/osac-project/osac-operator/api/v1alpha1"
     	privatev1 "github.com/osac-project/osac-operator/internal/api/osac/private/v1"
    +	"github.com/osac-project/osac-operator/internal/controller/feedback"
     )
     
    -// ExternalIPPoolFeedbackReconciler watches ExternalIPPool CRs on the hub cluster and reports their phase and capacity back
    -// to the fulfillment service via gRPC. This is the reverse channel: the provisioning controller drives the CR forward,
    -// while this controller keeps the fulfillment service in sync with the CR's current state.
    +// ExternalIPPoolFeedbackReconciler sends updates to the fulfillment service.
     type ExternalIPPoolFeedbackReconciler struct {
    -	hubClient            clnt.Client
    -	externalIPPoolClient privatev1.ExternalIPPoolsClient
    -	networkingNamespace  string
    -}
    -
    -// externalIPPoolFeedbackReconcilerTask is a per-reconciliation scratch pad. It holds a clone of the proto object so we
    -// can mutate it freely and then diff against the original to decide whether a gRPC Update is actually needed, avoiding
    -// unnecessary API calls when nothing changed.
    -type externalIPPoolFeedbackReconcilerTask struct {
    -	r              *ExternalIPPoolFeedbackReconciler
    -	object         *v1alpha1.ExternalIPPool
    -	externalIPPool *privatev1.ExternalIPPool
    +	bridge              *feedback.Bridge[*v1alpha1.ExternalIPPool, *privatev1.ExternalIPPool]
    +	networkingNamespace string
     }
     
     // NewExternalIPPoolFeedbackReconciler creates a reconciler that sends to the fulfillment service updates about
     // external IP pools.
     func NewExternalIPPoolFeedbackReconciler(hubClient clnt.Client, grpcConn *grpc.ClientConn, networkingNamespace string) *ExternalIPPoolFeedbackReconciler {
    -	return &ExternalIPPoolFeedbackReconciler{
    -		hubClient:            hubClient,
    -		externalIPPoolClient: privatev1.NewExternalIPPoolsClient(grpcConn),
    -		networkingNamespace:  networkingNamespace,
    +	poolClient := privatev1.NewExternalIPPoolsClient(grpcConn)
    +	r := &ExternalIPPoolFeedbackReconciler{networkingNamespace: networkingNamespace}
    +	r.bridge = &feedback.Bridge[*v1alpha1.ExternalIPPool, *privatev1.ExternalIPPool]{
    +		Client:    hubClient,
    +		Finalizer: osacExternalIPPoolFeedbackFinalizer,
    +		IDLabel:   osacExternalIPPoolIDLabel,
    +		Kind:      "ExternalIPPool",
    +		IDKey:     "externalIPPoolID",
    +		NewObject: func() *v1alpha1.ExternalIPPool { return &v1alpha1.ExternalIPPool{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.ExternalIPPool, error) {
    +			response, err := poolClient.Get(ctx, privatev1.ExternalIPPoolsGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
    +			}
    +			pool := response.GetObject()
    +			if pool == nil {
    +				return nil, fmt.Errorf("external IP pool not found: response contained nil object")
    +			}
    +			if !pool.HasSpec() {
    +				pool.SetSpec(&privatev1.ExternalIPPoolSpec{})
    +			}
    +			if !pool.HasStatus() {
    +				pool.SetStatus(&privatev1.ExternalIPPoolStatus{})
    +			}
    +			return pool, nil
    +		},

    @vladikr, confirmed — the nil-response error now uses errors.New consistently. Thanks for addressing it.

    <!-- <review_comment_addressed> -->

    ---

    <!-- This is an auto-generated comment: tweet message by coderabbit.ai -->

    If you found this review helpful, would you consider giving us a shout-out on X?

    Thank you for using CodeRabbit!

    <!-- end of auto-generated comment: tweet message by coderabbit.ai -->

    <!-- This is an auto-generated reply by CodeRabbit -->

    vladikr vladikr commented on Jul 29, 2026 12:19 UTC
    Author

    @tzvatot, just a follow-up, migrating the next set of controllers.
    I separated each to a separate commit so it will be easier to review.

    tzvatot tzvatot approved these changes on Jul 29, 2026 12:26 UTC
    Approved Reviewer

    Clean mechanical migration of four feedback controllers to the shared feedback.Bridge from PR #387. Each controller follows the exact same pattern as the Subnet migration: constructor wires Bridge callbacks, Reconcile becomes a one-liner, and only resource-specific phase mapping remains. Net reduction of 563 lines with all existing tests passing unchanged.

    Verified:

  • All 4 controllers follow the identical Bridge wiring pattern

  • Phase mappings preserved exactly from originals

  • VirtualNetwork's special deletion mapping (no DELETING/DELETE_FAILED proto states, uses PENDING/FAILED) correctly preserved with comment

  • NATGateway's delete mapping uses FAILED (not DELETE_FAILED) because the proto lacks a DELETE_FAILED state - confirmed correct

  • Nil guard on GetObject() consistent across all Fetch callbacks

  • errors.New used consistently for nil-object errors
  • /lgtm
    /approve

    openshift-ci[bot] openshift-ci[bot] commented on Jul 29, 2026 12:26 UTC
    Bot

    [APPROVALNOTIFIER] This PR is APPROVED

    This pull-request has been approved by: <a href="https://github.com/osac-project/osac-operator/pull/401#pullrequestreview-4808091989" title="Approved">tzvatot</a>, <a href="https://github.com/osac-project/osac-operator/pull/401#" title="Author self-approved">vladikr</a>

    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:

  • ~~OWNERS~~ [tzvatot,vladikr]
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":[]} -->

    Reviewers
    Assignees
    vladikr vladikr
    Labels
    risk: low confidence: 75.2% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 70.6% (HIGH) · Higher = larger blast radius
    70.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 75.2% · Lower = rushed or shallow review
    75.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.5% · Safe to merge
    17.5%