← Back to Pull requests

OSAC-3132: migrate ComputeInstance and ClusterOrder feedback controllers to Bridge #402

Merged
vladikr merged 5 files (917 lines) on Jul 30, 2026 13:33 UTC
View on GitHub
vladikr vladikr commented on Jul 30, 2026 02:21 UTC
Author

Summary

Migrate ComputeInstance and ClusterOrder feedback controllers to use the feedback.Bridge. Each controller is in a separate commit.

| Commit | Controller | Notes |
|--------|-----------|-------|
| 1 | ComputeInstance | Syncs 6 conditions, 7 phases, IP addresses, lastRestartedAt |
| 2 | ClusterOrder | Syncs conditions, phases (with HostedCluster fetch on Ready), node requests; drops logger field |

Behavioral improvements

Both controllers previously had no NotFound-during-deletion handling — if the fulfillment service archived the record before the feedback finalizer was removed, the controller would error-loop indefinitely. The Bridge fixes this automatically.

ClusterOrder details

  • SyncUpdate closure captures hubClient for HostedCluster lookups on the Ready phase

  • Constructor signature drops the logger logr.Logger parameter — the Bridge uses ctrllog.FromContext(ctx) consistently (matching all other feedback controllers)

  • cmd/main.go updated accordingly

  • clone/equal generic helpers remain in feedback_controller.go — still used by ExternalIP and ExternalIPAttachment (migrated in the next PR)

  • Extracted newClusterOrderFeedbackBridge helper so tests can wire the Bridge with mock clients
  • What's next

    Per the migration plan in #387:

  • ~~Subnet~~ (#387)

  • ~~VirtualNetwork, SecurityGroup, NATGateway, ExternalIPPool~~ (#401)

  • ComputeInstance, ClusterOrder (this PR)

  • ExternalIP (uses IsNotFound)

  • ExternalIPAttachment (uses PostSaveOnDelete)
  • Test plan

  • make lint — 0 issues

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

  • All 36 ComputeInstance and 15 ClusterOrder feedback tests pass unchanged
  • Jira: https://redhat.atlassian.net/browse/OSAC-3132

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

    Summary by CodeRabbit

    Bug Fixes
    Improved synchronization of cluster order and compute instance feedback with fulfillment services, keeping conditions, phases, node requests, service URLs, IP addresses, and restart timestamps current.
    Preserved safe behavior when the fulfillment connection is unavailable by keeping feedback reconciliation disabled.

    Refactor
    Refactored cluster order and compute instance feedback reconciliation to use a shared bridge, unifying update/delete handling and related sync logic.

    Tests
    * Updated feedback reconciler and compute instance feedback reconciler tests to match the new bridge-based wiring.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 917 lines (+249 / -668) across 5 files Reviewer: tzvatot Review duration: 671m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.77) × (1 − Review Confidence (0.76)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.77 · 917 lines diff across 5 files
    0.77
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.55 · 5 substantive comment(s)
    0.55
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    76%
    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.077
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    22 items
    openshift-ci-robot openshift-ci-robot commented on Jul 30, 2026 02:22 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 ComputeInstance and ClusterOrder feedback controllers to use the feedback.Bridge. Each controller is in a separate commit.

    >| Commit | Controller | Notes |

    >|--------|-----------|-------|
    >| 1 | ComputeInstance | Syncs 6 conditions, 7 phases, IP addresses, lastRestartedAt |
    >| 2 | ClusterOrder | Syncs conditions, phases (with HostedCluster fetch on Ready), node requests; drops logger field |
    >## Behavioral improvements

    >Both controllers previously had no NotFound-during-deletion handling — if the fulfillment service archived the record before the feedback finalizer was removed, the controller would error-loop indefinitely. The Bridge fixes this automatically.

    >## ClusterOrder details

    >- SyncUpdate closure captures hubClient for HostedCluster lookups on the Ready phase

    >- Constructor signature drops the logger logr.Logger parameter — the Bridge uses ctrllog.FromContext(ctx) consistently (matching all other feedback controllers)
    >- cmd/main.go updated accordingly
    >- clone/equal generic helpers remain in feedback_controller.go — still used by ExternalIP and ExternalIPAttachment (migrated in the next PR)
    >- Extracted newClusterOrderFeedbackBridge helper so tests can wire the Bridge with mock clients
    >## What's next

    >Per the migration plan in #387:

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

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

    >- [x] make lint — 0 issues

    >- [x] make test — all pass (controller coverage 72.2%)
    >- [x] All 36 ComputeInstance and 15 ClusterOrder feedback tests pass unchanged
    >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 30, 2026 02:22 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/402?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: 56 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: 0257a4c7-c7c5-43a2-8a4b-75ff7902d7a3

    > </details>

    > <details>

    <summary>📥 Commits</summary>

    > Reviewing files that changed from the base of the PR and between c45ae6dc1a467ab867e8d47a9af705c6276f3b56 and 4910b88c556c7daba3bed7234df269603fd4e516.

    > </details>

    > <details>

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

    > cmd/main.go

    internal/controller/clusterorder_feedback_controller_test.go

    internal/controller/computeinstance_feedback_controller.go

    internal/controller/computeinstance_feedback_controller_test.go

    internal/controller/feedback_controller.go

    > </details>

    > </details>

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

    <!-- walkthrough_start -->

    Walkthrough

    ClusterOrder and ComputeInstance feedback reconcilers now use shared feedback.Bridge instances for reconciliation and fulfillment-service synchronization. Constructors, controller setup, tests, and resource-specific synchronization helpers were updated.

    Changes

    Feedback bridge migration

    |Layer / File(s)|Summary|
    |---|---|
    |Bridge wiring and reconciler construction <br> internal/controller/feedback_controller.go, internal/controller/computeinstance_feedback_controller.go, cmd/main.go, internal/controller/
    _feedback_controller_test.go|Reconciler state and constructors now use typed bridges, with controller setup and test initialization updated for the revised signatures and fields.|
    |ClusterOrder bridge synchronization <br> internal/controller/feedback_controller.go|ClusterOrder reconciliation delegates fetching, saving, signaling, deletion, condition and phase updates, hosted-cluster URLs, and node-request synchronization to bridge callbacks.|
    |ComputeInstance bridge synchronization <br> internal/controller/computeinstance_feedback_controller.go|ComputeInstance reconciliation delegates to bridge callbacks and synchronizes conditions, phase, IP addresses, and restart timestamps through standalone helpers.|

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

    Sequence Diagram(s)

    sequenceDiagram
      participant FeedbackReconciler
      participant feedback.Bridge
      participant ClustersClient
      participant HubClient
      FeedbackReconciler->>feedback.Bridge: Reconcile request
      feedback.Bridge->>ClustersClient: Fetch and save Cluster
      feedback.Bridge->>HubClient: Fetch HostedCluster for URLs
      feedback.Bridge->>ClustersClient: Signal Cluster
    

    Possibly related PRs

  • osac-project/osac-operator#358: Modifies ClusterOrder feedback deletion handling preserved by this bridge refactor.

  • osac-project/osac-operator#384: Changes fulfillment-service NotFound handling in the same feedback reconciliation paths.

  • osac-project/osac-operator#387: Introduces the shared feedback.Bridge integration used by these controllers.
  • Suggested labels: ok-to-test

    Suggested reviewers: akshaynadkarni, tzvatot, 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 accurately summarizes the main change: migrating the ComputeInstance and ClusterOrder feedback controllers to Bridge. |
    | 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 | No hardcoded secrets were introduced; the changes only add bridge wiring and mock test setup, with no credential literals or embedded credentials. |
    | No-Weak-Crypto | ✅ Passed | No weak crypto or custom crypto appears in the changed files; the only crypto-related code is standard TLS setup and protobuf equality. |
    | No-Injection-Vectors | ✅ Passed | No flagged injection patterns appear in the changed files; the PR only rewires feedback controllers and tests, with no SQL, shell, eval, pickle, YAML, or innerHTML sinks. |
    | Container-Privileges | ✅ Passed | The PR touches only Go code, and a repo scan found no privileged, hostPID/hostNetwork/hostIPC, SYS_ADMIN, or allowPrivilegeEscalation:true settings. |
    | No-Sensitive-Data-In-Logs | ✅ Passed | No new logs expose secrets/PII; added bridge/controller logs only emit phases, conditions, resource classes, and opaque IDs. |
    | Ai-Attribution | ✅ Passed | PASS: PR commits mention Claude Code and each relevant commit has an Assisted-by trailer; no Co-Authored-By appears in inspected history. |

    </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 30, 2026 02:25 UTC
    Code Review
    internal/controller/computeinstance_feedback_controller.go:1
    @@ -71,260 +59,95 @@ func (r *ComputeInstanceFeedbackReconciler) SetupWithManager(mgr mcmanager.Manag
     		Complete(r)
     }
     
    -// Reconcile is the implementation of the reconciler interface.
    -func (r *ComputeInstanceFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error) {
    -	log := ctrllog.FromContext(ctx)
    -
    -	// Step 1: Fetch the CR from the hub cluster.
    -	object := &ckv1alpha1.ComputeInstance{}
    -	err = r.hubClient.Get(ctx, request.NamespacedName, object)
    -	if err != nil {
    -		if !apierrors.IsNotFound(err) {
    -			return result, err
    -		}
    -		// CR is gone. With the finalizer this shouldn't normally happen, but
    -		// handle gracefully (e.g. finalizer was removed externally).
    -		log.Info("CR not found, nothing to do")
    -		err = nil
    -		return result, err
    -	}
    -
    -	// Step 2: Get the compute instance ID from labels. CRs without this label
    -	// weren't created by the fulfillment service, so we ignore them.
    -	ciID, ok := object.Labels[osacComputeInstanceIDLabel]
    -	if !ok {
    -		// If being deleted and somehow has our finalizer, remove it to unblock deletion.
    -		if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -			log.Info("CR without CI ID label is being deleted, removing feedback finalizer")
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    +// Reconcile delegates to the shared feedback Bridge.
    +func (r *ComputeInstanceFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
    +	return r.bridge.Reconcile(ctx, request)
    +}
    +
    +// newComputeInstanceFeedbackBridge creates a Bridge wired to the given client. Exported for testing.
    +func newComputeInstanceFeedbackBridge(hubClient clnt.Client, ciClient privatev1.ComputeInstancesClient) *feedback.Bridge[*ckv1alpha1.ComputeInstance, *privatev1.ComputeInstance] {
    +	return &feedback.Bridge[*ckv1alpha1.ComputeInstance, *privatev1.ComputeInstance]{
    +		Client:    hubClient,
    +		Finalizer: osacComputeInstanceFeedbackFinalizer,
    +		IDLabel:   osacComputeInstanceIDLabel,
    +		Kind:      "ComputeInstance",
    +		IDKey:     "ciID",
    +		NewObject: func() *ckv1alpha1.ComputeInstance { return &ckv1alpha1.ComputeInstance{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.ComputeInstance, error) {
    +			response, err := ciClient.Get(ctx, privatev1.ComputeInstancesGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
     			}
    -			return result, err
    -		}
    -		log.Info(
    -			"There is no label containing the compute instance identifier, will ignore it",
    -			"label", osacComputeInstanceIDLabel,
    -		)
    -		return result, err
    -	}
    -
    -	// Step 3: Fetch the compute instance record from the fulfillment service
    -	// so we can compare before/after and only push changes.
    -	ci, err := r.fetchComputeInstance(ctx, ciID)
    -	if err != nil {
    -		if !object.DeletionTimestamp.IsZero() && status.Code(err) == codes.NotFound {
    -			log.Info("Compute instance record not found during deletion, removing feedback finalizer", "ciID", ciID)
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				return result, r.hubClient.Update(ctx, object)
    +			ci := response.GetObject()
    +			if ci == nil {
    +				return nil, errors.New("compute instance response contained nil object")
     			}
    -			return result, nil
    -		}
    -		return result, err
    -	}
    -
    -	t := &computeInstanceFeedbackReconcilerTask{
    -		r:      r,
    -		object: object,
    -		ci:     clone(ci),
    -	}
    -
    -	// Step 4: Sync CR state to the fulfillment service record.
    -	// handleUpdate also adds our finalizer; handleDelete only syncs state
    -	// (e.g. DELETING phase).
    -	if object.DeletionTimestamp.IsZero() {
    -		err = t.handleUpdate(ctx)
    -	} else {
    -		t.handleDelete(ctx)
    -	}
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 5: Persist synced state to the fulfillment service.
    -	err = r.saveComputeInstance(ctx, ci, t.ci)
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 6: Handle finalizer removal and signal for deletions. This must
    -	// happen after step 5 so the DELETING state is persisted before the CR
    -	// is garbage collected.
    -	if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -		if len(object.GetFinalizers()) == 1 {
    -			// We're the last finalizer. Remove it to trigger CR garbage
    -			// collection, then signal the fulfillment service to immediately
    -			// re-reconcile. Finalizer is removed first so the CR is gone
    -			// before the fulfillment controller checks — avoiding a race
    -			// where it sees the CR still exists and skips archival.
    -			log.Info(
    -				"Feedback finalizer is last remaining, removing finalizer and signaling",
    -				"ciID", ciID,
    -			)
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    -				if err != nil {
    -					return result, err
    -				}
    +			if !ci.HasSpec() {
    +				ci.SetSpec(&privatev1.ComputeInstanceSpec{})
     			}
    -			_, signalErr := r.computeInstancesClient.Signal(ctx, privatev1.ComputeInstancesSignalRequest_builder{
    -				Id: ciID,
    -			}.Build())
    -			if signalErr != nil {
    -				log.Error(
    -					signalErr,
    -					"Failed to signal fulfillment service, periodic sync will handle cleanup",
    -					"ciID", ciID,
    -				)
    +			if !ci.HasStatus() {
    +				ci.SetStatus(&privatev1.ComputeInstanceStatus{})
     			}
    -		} else {
    -			// Other finalizers still present — another controller hasn't
    -			// finished cleanup yet. When it removes its finalizer, the
    -			// Update event will trigger a new reconcile.
    -			log.Info(
    -				"Other finalizers still present, waiting",
    -				"finalizers", object.GetFinalizers(),
    -			)
    -		}
    -	}
    -
    -	return result, err
    -}
    -
    -// fetchComputeInstance retrieves a compute instance record from the fulfillment
    -// service by its ID, ensuring spec and status are initialized.
    -func (r *ComputeInstanceFeedbackReconciler) fetchComputeInstance(ctx context.Context, id string) (vm *privatev1.ComputeInstance, err error) {
    -	response, err := r.computeInstancesClient.Get(ctx, privatev1.ComputeInstancesGetRequest_builder{
    -		Id: id,
    -	}.Build())
    -	if err != nil {
    -		return
    -	}
    -	vm = response.GetObject()
    -	if !vm.HasSpec() {
    -		vm.SetSpec(&privatev1.ComputeInstanceSpec{})
    -	}
    -	if !vm.HasStatus() {
    -		vm.SetStatus(&privatev1.ComputeInstanceStatus{})
    -	}
    -	return
    -}
    -
    -// saveComputeInstance sends an update to the fulfillment service if the compute
    -// instance record has changed.
    -func (r *ComputeInstanceFeedbackReconciler) saveComputeInstance(ctx context.Context, before, after *privatev1.ComputeInstance) error {
    -	log := ctrllog.FromContext(ctx)
    -
    -	if !equal(after, before) {
    -		log.Info(
    -			"Updating compute instance",
    -			"before", before,
    -			"after", after,
    -		)
    -		_, err := r.computeInstancesClient.Update(ctx, privatev1.ComputeInstancesUpdateRequest_builder{
    -			Object: after,
    -		}.Build())
    -		if err != nil {
    +			return ci, nil
    +		},
    +		Save: func(ctx context.Context, remote *privatev1.ComputeInstance) error {
    +			_, err := ciClient.Update(ctx, privatev1.ComputeInstancesUpdateRequest_builder{
    +				Object: remote,
    +			}.Build())
     			return err
    -		}
    -	}
    -	return nil
    -}
    -
    -// handleUpdate ensures our finalizer is present and syncs the CR state to the
    -// fulfillment service. Called when the CR is not being deleted.
    -func (t *computeInstanceFeedbackReconcilerTask) handleUpdate(ctx context.Context) error {
    -	if controllerutil.AddFinalizer(t.object, osacComputeInstanceFeedbackFinalizer) {
    -		if err := t.r.hubClient.Update(ctx, t.object); err != nil {
    +		},
    +		Signal: func(ctx context.Context, id string) error {
    +			_, err := ciClient.Signal(ctx, privatev1.ComputeInstancesSignalRequest_builder{
    +				Id: id,
    +			}.Build())
     			return err
    -		}
    +		},
    +		SyncUpdate: syncComputeInstanceUpdate,
    +		SyncDelete: syncComputeInstanceDelete,
     	}
    -	t.syncState(ctx)
    -	return nil
    -}
    -
    -// handleDelete syncs the CR state (including the DELETING phase) to the
    -// fulfillment service. Called when the CR is being deleted.
    -func (t *computeInstanceFeedbackReconcilerTask) handleDelete(ctx context.Context) {
    -	t.syncState(ctx)
    -}
    -
    -// syncState synchronizes the CR's conditions, phase, IP addresses, and last
    -// restarted time to the fulfillment service's compute instance record.
    -func (t *computeInstanceFeedbackReconcilerTask) syncState(ctx context.Context) {
    -	t.syncConditions(ctx)
    -	t.syncPhase(ctx)
    -	t.syncIPAddresses()
    -	t.syncLastRestartedAt()
    -}
    -
    -func (t *computeInstanceFeedbackReconcilerTask) syncConditions(ctx context.Context) {
    -	t.syncConfigurationApplied(ctx)
    -	t.syncReady(ctx)
    -	t.syncRestartInProgress(ctx)
    -	t.syncRestartFailed(ctx)
    -	t.syncProvisioned(ctx)
    -	t.syncRestartRequired(ctx)
     }
     
    -// syncConfigurationApplied synchronizes the CONFIGURATION_APPLIED VM condition from the ConfigurationApplied CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncConfigurationApplied(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionConfigurationApplied)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_CONFIGURATION_APPLIED, crCondition)
    -}
    -
    -// syncReady synchronizes the READY VM condition from the Ready CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncReady(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionReady)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_READY, crCondition)
    -}
    -
    -// syncRestartInProgress synchronizes the RESTART_IN_PROGRESS VM condition from the RestartInProgress CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncRestartInProgress(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionRestartInProgress)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_RESTART_IN_PROGRESS, crCondition)
    -}
    -
    -// syncRestartFailed synchronizes the RESTART_FAILED VM condition from the RestartFailed CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncRestartFailed(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionRestartFailed)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_RESTART_FAILED, crCondition)
    +func syncComputeInstanceUpdate(ctx context.Context, obj *ckv1alpha1.ComputeInstance, remote *privatev1.ComputeInstance) error {
    +	syncCIConditions(obj, remote)
    +	syncCIPhase(ctx, obj, remote)
    +	syncCIIPAddresses(obj, remote)
    +	syncCILastRestartedAt(obj, remote)
    +	return nil
     }
     
    -// syncProvisioned synchronizes the PROVISIONED VM condition from the Provisioned CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncProvisioned(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionProvisioned)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_PROVISIONED, crCondition)
    +func syncComputeInstanceDelete(ctx context.Context, obj *ckv1alpha1.ComputeInstance, remote *privatev1.ComputeInstance) error {
    +	syncCIConditions(obj, remote)
    +	syncCIPhase(ctx, obj, remote)
    +	syncCIIPAddresses(obj, remote)
    +	syncCILastRestartedAt(obj, remote)
    +	return nil
     }

    _🗄️ Data Integrity & Integration_ | _🟠 Major_ | _⚡ Quick win_

    <details>
    <summary>🧩 Analysis chain</summary>

    🏁 Script executed:

    #!/bin/bash
    git log -1 --format=%H
    git show HEAD~2:internal/controller/computeinstance_feedback_controller.go 2>/dev/null | rg -n -A20 'COMPUTE_INSTANCE_STATE_DELETING'
    

    Repository: osac-project/osac-operator

    Length of output: 1190

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    # Locate and inspect the affected controller plus related bridge delete-state handling.
    printf 'Files matching computeinstance_feedback_controller.go:\n'
    fd -a 'computeinstance_feedback_controller\.go$' . || true
    
    printf '\nCurrent controller section:\n'
    sed -n '1,180p' internal/controller/computeinstance_feedback_controller.go
    
    printf '\nSearch for syncComputeInstanceUpdate/Delete usage and ClusterOrder delete state handling:\n'
    rg -n 'syncComputeInstanceUpdate|syncComputeInstanceDelete|SyncUpdate|SyncDelete|ClusterOrder|SetState\(.*DELETING\)|GetPhaseMappingFor' internal/controller -S
    

    Repository: osac-project/osac-operator

    Length of output: 50382

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    # Inspect relevant definitions and tests for ComputeInstance Phase mappings and delete behavior.
    printf 'Candidate files:\n'
    rg -l 'func ComputeInstancePhase|ComputeInstancePhase|ComputeInstanceState_|DELETING|ClusterOrder' internal pkg . --glob '!vendor/**' --glob '!node_modules/**' || true
    
    printf '\nDefinitions/usages around phase mapping:\n'
    rg -n 'func .*Phase|PhaseMapping|Phase.*Delete|Delete.*Phase|DELETING|GetStatus.*SetState|SetState\(.*DELETING\)' internal pkg --glob '*.go' || true
    
    printf '\nRelevant test snippets with Deleting/DELETING:\n'
    rg -n -C 4 'Deleting|DELETING|computeinstance_feedback|SyncDelete' --glob '*_test.go' || true
    

    Repository: osac-project/osac-operator

    Length of output: 39209

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    printf 'ComputeInstance feedback test delete/state snippets:\n'
    sed -n '230,280p' internal/controller/computeinstance_feedback_controller_test.go
    sed -n '630,690p' internal/controller/computeinstance_feedback_controller_test.go
    
    printf '\nNon-deleting delete-state examples for comparison:\n'
    sed -n '80,130p' internal/controller/subnet_feedback_controller.go
    sed -n '80,130p' internal/controller/natgateway_feedback_controller.go
    sed -n '80,130p' internal/controller/externalippool_feedback_controller.go
    
    printf '\nBridge delete lifecycle references:\n'
    sed -n '1,220p' internal/controller/feedback/bridge.go
    

    Repository: osac-project/osac-operator

    Length of output: 17111

    ---

    </details>

    Force DELETING on the ComputeInstance delete sync, or rename syncComputeInstanceDelete as dead code.

    ComputeInstancePhaseRunning does not map to COMPUTE_INSTANCE_STATE_DELETING, but the delete Update call should record deletion state before the finalizer is removed. The current tests cover only Phase = Deleting, so a running instance deleted with other finalizers would signal the fulfillment service as RUNNING. Mirror the subnet/NAT/Gateway delete handlers: preserve Failed if needed, otherwise set DELETING.

    <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/computeinstance_feedback_controller.go` around lines 110
    - 124, Update syncComputeInstanceDelete to force the ComputeInstance phase to
    DELETING during deletion, preserving Failed when applicable, before the
    finalizer is removed. Mirror the existing subnet/NAT/Gateway delete-handler
    behavior and leave syncComputeInstanceUpdate unchanged.
    

    </details>

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

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

    <!-- cr-comment:v1:7d04efec7f993992513c95c8 -->

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

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 30, 2026 02:25 UTC
    Code Review
    internal/controller/feedback_controller.go:1
    @@ -77,245 +62,105 @@ func (r *FeedbackReconciler) SetupWithManager(mgr mcmanager.Manager) error {
     		Complete(r)
     }
     
    -// Reconcile is the implementation of the reconciler interface.
    -func (r *FeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error) {
    -	log := ctrllog.FromContext(ctx)
    -
    -	// Step 1: Fetch the CR from the hub cluster.
    -	object := &ckv1alpha1.ClusterOrder{}
    -	err = r.hubClient.Get(ctx, request.NamespacedName, object)
    -	if err != nil {
    -		if !apierrors.IsNotFound(err) {
    -			return result, err
    -		}
    -		log.Info("CR not found, nothing to do")
    -		return result, nil
    -	}
    +// Reconcile delegates to the shared feedback Bridge.
    +func (r *FeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
    +	return r.bridge.Reconcile(ctx, request)
    +}
     
    -	// Step 2: Get the cluster ID from labels. CRs without this label
    -	// are not linked to a fulfillment-service cluster record, so we
    -	// skip them — except when being deleted with our finalizer still
    -	// present, in which case we remove it to unblock garbage collection.
    -	clusterID, ok := object.Labels[osacClusterOrderIDLabel]
    -	if !ok {
    -		if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -			log.Info("CR without cluster ID label is being deleted, removing feedback finalizer")
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    +// newClusterOrderFeedbackBridge creates a Bridge wired to the given clients. Used by both
    +// the constructor and tests.
    +func newClusterOrderFeedbackBridge(hubClient clnt.Client, clustersClient privatev1.ClustersClient) *feedback.Bridge[*ckv1alpha1.ClusterOrder, *privatev1.Cluster] {
    +	return &feedback.Bridge[*ckv1alpha1.ClusterOrder, *privatev1.Cluster]{
    +		Client:    hubClient,
    +		Finalizer: osacClusterOrderFeedbackFinalizer,
    +		IDLabel:   osacClusterOrderIDLabel,
    +		Kind:      "ClusterOrder",
    +		IDKey:     "clusterID",
    +		NewObject: func() *ckv1alpha1.ClusterOrder { return &ckv1alpha1.ClusterOrder{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.Cluster, error) {
    +			response, err := clustersClient.Get(ctx, privatev1.ClustersGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
     			}
    -			return result, err
    -		}
    -		r.logger.Info(
    -			"There is no label containing the cluster identifier, will ignore it",
    -			"label", osacClusterOrderIDLabel,
    -		)
    -		return result, nil
    -	}
    -
    -	// Step 3: Fetch the cluster record from the fulfillment service.
    -	cluster, err := r.fetchCluster(ctx, clusterID)
    -	if err != nil {
    -		if !object.DeletionTimestamp.IsZero() && status.Code(err) == codes.NotFound {
    -			log.Info("Cluster record not found during deletion, removing feedback finalizer", "clusterID", clusterID)
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				return result, r.hubClient.Update(ctx, object)
    +			cluster := response.GetObject()
    +			if cluster == nil {
    +				return nil, errors.New("cluster response contained nil object")
     			}
    -			return result, nil
    -		}
    -		return result, err
    -	}
    -
    -	// Step 4: Sync CR state to the fulfillment service record.
    -	t := &feedbackReconcilerTask{
    -		r:       r,
    -		object:  object,
    -		cluster: clone(cluster),
    -	}
    -	if object.DeletionTimestamp.IsZero() {
    -		err = t.handleUpdate(ctx)
    -	} else {
    -		err = t.handleDelete(ctx)
    -	}
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 5: Persist synced state to the fulfillment service.
    -	err = r.saveCluster(ctx, cluster, t.cluster)
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 6: Handle finalizer removal and signal for deletions.
    -	if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -		if len(object.GetFinalizers()) == 1 {
    -			log.Info(
    -				"Feedback finalizer is last remaining, removing finalizer and signaling",
    -				"clusterID", clusterID,
    -			)
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    -				if err != nil {
    -					return result, err
    -				}
    +			if !cluster.HasSpec() {
    +				cluster.SetSpec(&privatev1.ClusterSpec{})
     			}
    -			_, signalErr := r.clustersClient.Signal(ctx, privatev1.ClustersSignalRequest_builder{
    -				Id: clusterID,
    -			}.Build())
    -			if signalErr != nil {
    -				log.Error(
    -					signalErr,
    -					"Failed to signal fulfillment service, periodic sync will handle cleanup",
    -					"clusterID", clusterID,
    -				)
    +			if !cluster.HasStatus() {
    +				cluster.SetStatus(&privatev1.ClusterStatus{})
     			}
    -		} else {
    -			log.Info(
    -				"Other finalizers still present, waiting",
    -				"finalizers", object.GetFinalizers(),
    -			)
    -		}
    -	}
    -
    -	return result, err
    -}
    -
    -func (r *FeedbackReconciler) fetchCluster(ctx context.Context, id string) (cluster *privatev1.Cluster, err error) {
    -	response, err := r.clustersClient.Get(ctx, privatev1.ClustersGetRequest_builder{
    -		Id: id,
    -	}.Build())
    -	if err != nil {
    -		return
    -	}
    -	cluster = response.GetObject()
    -	if !cluster.HasSpec() {
    -		cluster.SetSpec(&privatev1.ClusterSpec{})
    -	}
    -	if !cluster.HasStatus() {
    -		cluster.SetStatus(&privatev1.ClusterStatus{})
    -	}
    -	return
    -}
    -
    -func (r *FeedbackReconciler) saveCluster(ctx context.Context, before, after *privatev1.Cluster) error {
    -	if !equal(after, before) {
    -		_, err := r.clustersClient.Update(ctx, privatev1.ClustersUpdateRequest_builder{
    -			Object: after,
    -		}.Build())
    -		if err != nil {
    +			return cluster, nil
    +		},
    +		Save: func(ctx context.Context, remote *privatev1.Cluster) error {
    +			_, err := clustersClient.Update(ctx, privatev1.ClustersUpdateRequest_builder{
    +				Object: remote,
    +			}.Build())
     			return err
    -		}
    +		},
    +		Signal: func(ctx context.Context, id string) error {
    +			_, err := clustersClient.Signal(ctx, privatev1.ClustersSignalRequest_builder{
    +				Id: id,
    +			}.Build())
    +			return err
    +		},
    +		SyncUpdate: newClusterOrderSyncUpdate(hubClient),
    +		SyncDelete: syncClusterOrderDelete,
     	}
    -	return nil
     }
     
    -func (t *feedbackReconcilerTask) handleUpdate(ctx context.Context) error {
    -	if controllerutil.AddFinalizer(t.object, osacClusterOrderFeedbackFinalizer) {
    -		if err := t.r.hubClient.Update(ctx, t.object); err != nil {
    +// newClusterOrderSyncUpdate returns a SyncUpdate function that captures hubClient
    +// for HostedCluster lookups on the Ready phase.
    +func newClusterOrderSyncUpdate(hubClient clnt.Client) func(context.Context, *ckv1alpha1.ClusterOrder, *privatev1.Cluster) error {
    +	return func(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +		syncClusterOrderConditions(ctx, obj, remote)
    +		if err := syncClusterOrderPhase(ctx, hubClient, obj, remote); err != nil {
     			return err
     		}
    +		syncClusterOrderNodeRequests(ctx, obj, remote)
    +		return nil
     	}
    -	return t.syncState(ctx)
    -}
    -
    -func (t *feedbackReconcilerTask) handleDelete(ctx context.Context) error {
    -	if err := t.syncState(ctx); err != nil {
    -		return err
    -	}
    -	return t.syncPhaseDeleting()
     }
     
    -func (t *feedbackReconcilerTask) syncState(ctx context.Context) error {
    -	if err := t.syncConditions(); err != nil {
    -		return err
    -	}
    -	if err := t.syncPhase(ctx); err != nil {
    -		return err
    -	}
    -	if err := t.syncNodeRequests(); err != nil {
    +func syncClusterOrderDelete(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +	syncClusterOrderConditions(ctx, obj, remote)
    +	if err := syncClusterOrderPhase(ctx, nil, obj, remote); err != nil {
     		return err
     	}
    +	syncClusterOrderNodeRequests(ctx, obj, remote)
    +	remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_DELETING)
     	return nil
     }

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

    nil hubClient as a "skip HostedCluster lookup" sentinel is fragile.

    syncClusterOrderDelete passes nil and syncClusterOrderPhaseReady silently returns on hubClient == nil. A future caller that forgets to wire the client gets silent no-op URL syncing instead of a compile/runtime signal. Prefer an explicit parameter.

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

    -func syncClusterOrderPhase(ctx context.Context, hubClient clnt.Client, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +// fetchURLs is false on the delete path, where the state is forced to DELETING anyway.
    +func syncClusterOrderPhase(ctx context.Context, hubClient clnt.Client, fetchURLs bool, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    

    and gate the lookup on fetchURLs rather than on a nil client.
    </details>

    Also applies to: 191-197

    <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/feedback_controller.go` around lines 127 - 135, Replace
    the nil hubClient sentinel in syncClusterOrderPhase with an explicit fetchURLs
    parameter, and make syncClusterOrderPhaseReady gate HostedCluster lookup on
    fetchURLs rather than client nilness. Update all callers, including
    syncClusterOrderDelete, to pass the intended behavior; require and use hubClient
    whenever URL fetching is enabled.
    

    </details>

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

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

    <!-- cr-comment:v1:8a434e1256a0f21732c11711 -->

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

    ✅ Addressed in commit 32424af

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 30, 2026 02:25 UTC
    Code Review
    internal/controller/feedback_controller.go:1
    @@ -77,245 +62,105 @@ func (r *FeedbackReconciler) SetupWithManager(mgr mcmanager.Manager) error {
     		Complete(r)
     }
     
    -// Reconcile is the implementation of the reconciler interface.
    -func (r *FeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error) {
    -	log := ctrllog.FromContext(ctx)
    -
    -	// Step 1: Fetch the CR from the hub cluster.
    -	object := &ckv1alpha1.ClusterOrder{}
    -	err = r.hubClient.Get(ctx, request.NamespacedName, object)
    -	if err != nil {
    -		if !apierrors.IsNotFound(err) {
    -			return result, err
    -		}
    -		log.Info("CR not found, nothing to do")
    -		return result, nil
    -	}
    +// Reconcile delegates to the shared feedback Bridge.
    +func (r *FeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
    +	return r.bridge.Reconcile(ctx, request)
    +}
     
    -	// Step 2: Get the cluster ID from labels. CRs without this label
    -	// are not linked to a fulfillment-service cluster record, so we
    -	// skip them — except when being deleted with our finalizer still
    -	// present, in which case we remove it to unblock garbage collection.
    -	clusterID, ok := object.Labels[osacClusterOrderIDLabel]
    -	if !ok {
    -		if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -			log.Info("CR without cluster ID label is being deleted, removing feedback finalizer")
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    +// newClusterOrderFeedbackBridge creates a Bridge wired to the given clients. Used by both
    +// the constructor and tests.
    +func newClusterOrderFeedbackBridge(hubClient clnt.Client, clustersClient privatev1.ClustersClient) *feedback.Bridge[*ckv1alpha1.ClusterOrder, *privatev1.Cluster] {
    +	return &feedback.Bridge[*ckv1alpha1.ClusterOrder, *privatev1.Cluster]{
    +		Client:    hubClient,
    +		Finalizer: osacClusterOrderFeedbackFinalizer,
    +		IDLabel:   osacClusterOrderIDLabel,
    +		Kind:      "ClusterOrder",
    +		IDKey:     "clusterID",
    +		NewObject: func() *ckv1alpha1.ClusterOrder { return &ckv1alpha1.ClusterOrder{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.Cluster, error) {
    +			response, err := clustersClient.Get(ctx, privatev1.ClustersGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
     			}
    -			return result, err
    -		}
    -		r.logger.Info(
    -			"There is no label containing the cluster identifier, will ignore it",
    -			"label", osacClusterOrderIDLabel,
    -		)
    -		return result, nil
    -	}
    -
    -	// Step 3: Fetch the cluster record from the fulfillment service.
    -	cluster, err := r.fetchCluster(ctx, clusterID)
    -	if err != nil {
    -		if !object.DeletionTimestamp.IsZero() && status.Code(err) == codes.NotFound {
    -			log.Info("Cluster record not found during deletion, removing feedback finalizer", "clusterID", clusterID)
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				return result, r.hubClient.Update(ctx, object)
    +			cluster := response.GetObject()
    +			if cluster == nil {
    +				return nil, errors.New("cluster response contained nil object")
     			}
    -			return result, nil
    -		}
    -		return result, err
    -	}
    -
    -	// Step 4: Sync CR state to the fulfillment service record.
    -	t := &feedbackReconcilerTask{
    -		r:       r,
    -		object:  object,
    -		cluster: clone(cluster),
    -	}
    -	if object.DeletionTimestamp.IsZero() {
    -		err = t.handleUpdate(ctx)
    -	} else {
    -		err = t.handleDelete(ctx)
    -	}
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 5: Persist synced state to the fulfillment service.
    -	err = r.saveCluster(ctx, cluster, t.cluster)
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 6: Handle finalizer removal and signal for deletions.
    -	if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -		if len(object.GetFinalizers()) == 1 {
    -			log.Info(
    -				"Feedback finalizer is last remaining, removing finalizer and signaling",
    -				"clusterID", clusterID,
    -			)
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    -				if err != nil {
    -					return result, err
    -				}
    +			if !cluster.HasSpec() {
    +				cluster.SetSpec(&privatev1.ClusterSpec{})
     			}
    -			_, signalErr := r.clustersClient.Signal(ctx, privatev1.ClustersSignalRequest_builder{
    -				Id: clusterID,
    -			}.Build())
    -			if signalErr != nil {
    -				log.Error(
    -					signalErr,
    -					"Failed to signal fulfillment service, periodic sync will handle cleanup",
    -					"clusterID", clusterID,
    -				)
    +			if !cluster.HasStatus() {
    +				cluster.SetStatus(&privatev1.ClusterStatus{})
     			}
    -		} else {
    -			log.Info(
    -				"Other finalizers still present, waiting",
    -				"finalizers", object.GetFinalizers(),
    -			)
    -		}
    -	}
    -
    -	return result, err
    -}
    -
    -func (r *FeedbackReconciler) fetchCluster(ctx context.Context, id string) (cluster *privatev1.Cluster, err error) {
    -	response, err := r.clustersClient.Get(ctx, privatev1.ClustersGetRequest_builder{
    -		Id: id,
    -	}.Build())
    -	if err != nil {
    -		return
    -	}
    -	cluster = response.GetObject()
    -	if !cluster.HasSpec() {
    -		cluster.SetSpec(&privatev1.ClusterSpec{})
    -	}
    -	if !cluster.HasStatus() {
    -		cluster.SetStatus(&privatev1.ClusterStatus{})
    -	}
    -	return
    -}
    -
    -func (r *FeedbackReconciler) saveCluster(ctx context.Context, before, after *privatev1.Cluster) error {
    -	if !equal(after, before) {
    -		_, err := r.clustersClient.Update(ctx, privatev1.ClustersUpdateRequest_builder{
    -			Object: after,
    -		}.Build())
    -		if err != nil {
    +			return cluster, nil
    +		},
    +		Save: func(ctx context.Context, remote *privatev1.Cluster) error {
    +			_, err := clustersClient.Update(ctx, privatev1.ClustersUpdateRequest_builder{
    +				Object: remote,
    +			}.Build())
     			return err
    -		}
    +		},
    +		Signal: func(ctx context.Context, id string) error {
    +			_, err := clustersClient.Signal(ctx, privatev1.ClustersSignalRequest_builder{
    +				Id: id,
    +			}.Build())
    +			return err
    +		},
    +		SyncUpdate: newClusterOrderSyncUpdate(hubClient),
    +		SyncDelete: syncClusterOrderDelete,
     	}
    -	return nil
     }
     
    -func (t *feedbackReconcilerTask) handleUpdate(ctx context.Context) error {
    -	if controllerutil.AddFinalizer(t.object, osacClusterOrderFeedbackFinalizer) {
    -		if err := t.r.hubClient.Update(ctx, t.object); err != nil {
    +// newClusterOrderSyncUpdate returns a SyncUpdate function that captures hubClient
    +// for HostedCluster lookups on the Ready phase.
    +func newClusterOrderSyncUpdate(hubClient clnt.Client) func(context.Context, *ckv1alpha1.ClusterOrder, *privatev1.Cluster) error {
    +	return func(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +		syncClusterOrderConditions(ctx, obj, remote)
    +		if err := syncClusterOrderPhase(ctx, hubClient, obj, remote); err != nil {
     			return err
     		}
    +		syncClusterOrderNodeRequests(ctx, obj, remote)
    +		return nil
     	}
    -	return t.syncState(ctx)
    -}
    -
    -func (t *feedbackReconcilerTask) handleDelete(ctx context.Context) error {
    -	if err := t.syncState(ctx); err != nil {
    -		return err
    -	}
    -	return t.syncPhaseDeleting()
     }
     
    -func (t *feedbackReconcilerTask) syncState(ctx context.Context) error {
    -	if err := t.syncConditions(); err != nil {
    -		return err
    -	}
    -	if err := t.syncPhase(ctx); err != nil {
    -		return err
    -	}
    -	if err := t.syncNodeRequests(); err != nil {
    +func syncClusterOrderDelete(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +	syncClusterOrderConditions(ctx, obj, remote)
    +	if err := syncClusterOrderPhase(ctx, nil, obj, remote); err != nil {
     		return err
     	}
    +	syncClusterOrderNodeRequests(ctx, obj, remote)
    +	remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_DELETING)
     	return nil
     }
     
    -func (t *feedbackReconcilerTask) syncConditions() error {
    -	for _, condition := range t.object.Status.Conditions {
    -		err := t.syncCondition(condition)
    -		if err != nil {
    -			return err
    +func syncClusterOrderConditions(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) {
    +	log := ctrllog.FromContext(ctx)
    +	for _, condition := range obj.Status.Conditions {
    +		switch ckv1alpha1.ClusterOrderConditionType(condition.Type) {
    +		case ckv1alpha1.ClusterOrderConditionAccepted,
    +			ckv1alpha1.ClusterOrderConditionProgressing,
    +			ckv1alpha1.ClusterOrderConditionControlPlaneAvailable,
    +			ckv1alpha1.ClusterOrderConditionAvailable:
    +			syncClusterConditionFromCR(remote, privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING, condition)
    +		default:
    +			log.Info("Unknown condition, will ignore it", "condition", condition.Type)
     		}
     	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncCondition(condition metav1.Condition) error {
    -	switch ckv1alpha1.ClusterOrderConditionType(condition.Type) {
    -	case ckv1alpha1.ClusterOrderConditionAccepted:
    -		return t.syncConditionAccepted(condition)
    -	case ckv1alpha1.ClusterOrderConditionProgressing:
    -		return t.syncConditionProgressing(condition)
    -	case ckv1alpha1.ClusterOrderConditionControlPlaneAvailable:
    -		return t.syncConditionControlPlaneAvailable(condition)
    -	case ckv1alpha1.ClusterOrderConditionAvailable:
    -		return t.syncConditionAvailable(condition)
    -	default:
    -		t.r.logger.Info(
    -			"Unknown condition, will ignore it",
    -			"condition", condition.Type,
    -		)
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncConditionAccepted(condition metav1.Condition) error {
    -	orderCondition := t.findClusterCondition(privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING)
    -	oldStatus := orderCondition.GetStatus()
    -	newStatus := t.mapConditionStatus(condition.Status)
    -	orderCondition.SetStatus(newStatus)
    -	orderCondition.SetMessage(condition.Message)
    -	if newStatus != oldStatus {
    -		orderCondition.SetLastTransitionTime(timestamppb.Now())
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncConditionProgressing(condition metav1.Condition) error {
    -	orderCondition := t.findClusterCondition(privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING)
    -	oldStatus := orderCondition.GetStatus()
    -	newStatus := t.mapConditionStatus(condition.Status)
    -	orderCondition.SetStatus(newStatus)
    -	orderCondition.SetMessage(condition.Message)
    -	if newStatus != oldStatus {
    -		orderCondition.SetLastTransitionTime(timestamppb.Now())
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncConditionControlPlaneAvailable(condition metav1.Condition) error {
    -	orderCondition := t.findClusterCondition(privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING)
    -	oldStatus := orderCondition.GetStatus()
    -	newStatus := t.mapConditionStatus(condition.Status)
    -	orderCondition.SetStatus(newStatus)
    -	orderCondition.SetMessage(condition.Message)
    -	if newStatus != oldStatus {
    -		orderCondition.SetLastTransitionTime(timestamppb.Now())
    -	}
    -	return nil
     }

    _🎯 Functional Correctness_ | _🟡 Minor_ | _⚡ Quick win_

    <details>
    <summary>🧩 Analysis chain</summary>

    🏁 Script executed:

    #!/bin/bash
    rg -n 'CLUSTER_CONDITION_TYPE_' --glob 'internal/api/**' | sort -u | head -50
    

    Repository: osac-project/osac-operator

    Length of output: 164

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    printf 'Relevant files:\n'
    fd -a 'feedback_controller.go|.*cluster.*\.(go|proto)$|.*api.*' . | sed 's#^\./##' | head -100
    
    printf '\nSearch condition symbols:\n'
    rg -n 'ClusterOrderConditionType|CLUSTER_CONDITION_TYPE_|synchron|Feedback|feedback_controller' --glob '*.go' --glob '*.proto' . | head -200
    
    printf '\nTarget file excerpt:\n'
    sed -n '120,165p' internal/controller/feedback_controller.go | cat -n
    

    Repository: osac-project/osac-operator

    Length of output: 34005

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    printf 'ClusterOrderConditionType definitions:\n'
    sed -n '1,220p' api/v1alpha1/clusterorder_conditions.go | cat -n
    
    printf '\nPrivate ClusterConditionType definitions in proto files:\n'
    rg -n 'enum.*Condition|CLUSTER_CONDITION_TYPE_|Condition.*=' api internal/api --glob '*.proto' | sed -n '1,200p'
    
    printf '\nFeedback bridge implementation excerpt:\n'
    sed -n '1,220p' internal/controller/feedback_controller.go | cat -n
    
    printf '\nCluster condition helper references:\n'
    rg -n 'findClusterCondition|setClusterCondition|Sync.*Condition|syncClusterConditionFromCR|ClusterConditionType' internal/api internal/controller --glob '*.go' | sed -n '1,200p'
    

    Repository: osac-project/osac-operator

    Length of output: 1707

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    printf 'All occurrences of cluster order condition const/typed values:\n'
    rg -n 'ClusterOrderCondition(Accepted|Progressing|ControlPlaneAvailable|Available|Type)|ClusterConditionType|ConditionStatus|metav1.Condition|last.transition|LastTransitionTime' --glob '*.go' --glob '*.proto' . | sed -n '1,240p'
    
    printf '\nClusterOrder status/condition files:\n'
    for f in api/v1alpha1/clusterorder_conditions.go api/v1alpha1/clusterorder_types.go api/v1alpha1/zz_generated.deepcopy.go internal/controller/feedback_controller.go internal/controller/clusterorder_feedback_controller_test.go; do
      if [ -f "$f" ]; then
        echo "--- $f"
        wc -l "$f"
      fi
    done
    
    printf '\nRelevant generated/type sections:\n'
    rg -n 'ClusterOrder.*Condition|Conditions.*ClusterOrderCondition|type ClusterOrderCondition|StatusCondition|SetStatusCondition|RemoveStatusCondition' api/v1alpha1 internal/controller --glob '*.go' | sed -n '1,240p'
    

    Repository: osac-project/osac-operator

    Length of output: 50382

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    printf 'feedback_controller.go relevant implementation:\n'
    sed -n '220,315p' internal/controller/feedback_controller.go | cat -n
    
    printf '\nClusterOrderFeedback tests around conditions/sync:\n'
    sed -n '1,260p' internal/controller/clusterorder_feedback_controller_test.go | cat -n
    
    printf '\nPrivate proto condition enum search exact:\n'
    find internal/api osac -maxdepth 4 -type f \( -name '*.proto' -o -name '*.pb.go' \) 2>/dev/null | xargs -r rg -n 'type ClusterConditionType|CLUSTER_CONDITION_TYPE_|ConditionType' | sed -n '1,160p'
    

    Repository: osac-project/osac-operator

    Length of output: 36281

    ---

    </details>

    Avoid collapsing ClusterOrder conditions through ClusterConditionType_UNSPECIFIED.

    syncClusterConditionFromCR(remote, privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_UNSPECIFIED, ...) always targets the same UNSPECIFIED destination condition, so multiple ClusterOrder condition types overwrite that one remote condition and make last_transition_time flip when their statuses change. Map to a single concrete remote condition only if that is intended, otherwise preserve separate remote condition types for these CR status signals.

    <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/feedback_controller.go` around lines 137 - 150, The
    syncClusterOrderConditions function currently maps all recognized ClusterOrder
    conditions to the single remote PROGRESSING condition, collapsing distinct
    status signals and causing transition timestamps to overwrite each other. Update
    the mapping so each ClusterOrder condition is synchronized to its intended
    distinct concrete privatev1.ClusterConditionType, avoiding UNSPECIFIED or any
    shared destination unless explicitly intended; leave unknown-condition handling
    unchanged.
    

    </details>

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

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

    <!-- cr-comment:v1:6acce334b81d6cdc5261bf8e -->

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

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 30, 2026 02:25 UTC
    Code Review
    internal/controller/feedback_controller.go:1
    @@ -326,177 +171,138 @@ func (t *feedbackReconcilerTask) mapConditionStatus(status metav1.ConditionStatu
     	}
     }
     
    -func (t *feedbackReconcilerTask) syncPhase(ctx context.Context) error {
    -	switch t.object.Status.Phase {
    +func syncClusterOrderPhase(ctx context.Context, hubClient clnt.Client, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +	log := ctrllog.FromContext(ctx)
    +	switch obj.Status.Phase {
     	case ckv1alpha1.ClusterOrderPhaseProgressing:
    -		return t.syncPhaseProgressing()
    +		remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_PROGRESSING)
     	case ckv1alpha1.ClusterOrderPhaseFailed:
    -		return t.syncPhaseFailed()
    +		remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_FAILED)
     	case ckv1alpha1.ClusterOrderPhaseReady:
    -		return t.syncPhaseReady(ctx)
    +		return syncClusterOrderPhaseReady(ctx, hubClient, obj, remote)
     	case ckv1alpha1.ClusterOrderPhaseDeleting:
    -		return t.syncPhaseDeleting()
    +		remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_DELETING)
     	default:
    -		t.r.logger.Info(
    -			"Unknown phase, will ignore it",
    -			"phase", t.object.Status.Phase,
    -		)
    +		log.Info("Unknown phase, will ignore it", "phase", obj.Status.Phase)
     	}
     	return nil
     }
     
    -func (t *feedbackReconcilerTask) syncPhaseProgressing() error {
    -	t.cluster.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_PROGRESSING)
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncPhaseFailed() error {
    -	t.cluster.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_FAILED)
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncPhaseReady(ctx context.Context) error {
    -	// Set the status of the cluster:
    -	clusterStatus := t.cluster.GetStatus()
    +func syncClusterOrderPhaseReady(ctx context.Context, hubClient clnt.Client, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +	clusterStatus := remote.GetStatus()
     	clusterStatus.SetState(privatev1.ClusterState_CLUSTER_STATE_READY)
     
    -	// In order to get the API and console URL we need to fetch the hosted cluster:
    -	err := t.fetchHostedCluster(ctx)
    +	if hubClient == nil {
    +		return nil
    +	}
    +
    +	hostedCluster, err := fetchHostedCluster(ctx, hubClient, obj)
     	if err != nil {
     		return err
     	}
    -	apiURL := t.calculateAPIURL()
    +	if hostedCluster == nil {
    +		return nil
    +	}
    +
    +	apiURL := calculateAPIURL(hostedCluster)
     	if apiURL != "" {
     		clusterStatus.SetApiUrl(apiURL)
     	}
    -	consoleURL := t.calculateConsoleURL()
    +	consoleURL := calculateConsoleURL(hostedCluster)
     	if consoleURL != "" {
     		clusterStatus.SetConsoleUrl(consoleURL)
     	}
    -
     	return nil
     }
     
    -func (t *feedbackReconcilerTask) syncNodeRequests() error {
    -	for i := range len(t.object.Status.NodeRequests) {
    -		err := t.syncNodeRequest(&t.object.Status.NodeRequests[i])
    -		if err != nil {
    -			return err
    +func syncClusterOrderNodeRequests(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) {
    +	log := ctrllog.FromContext(ctx)
    +	for i := range len(obj.Status.NodeRequests) {
    +		nodeRequest := &obj.Status.NodeRequests[i]
    +
    +		var nodeSetID string
    +		for candidateNodeSetID, candidateNodeSet := range remote.GetSpec().GetNodeSets() {
    +			if candidateNodeSet.GetHostType() == nodeRequest.ResourceClass {
    +				nodeSetID = candidateNodeSetID
    +				break
    +			}
     		}
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncNodeRequest(nodeRequest *ckv1alpha1.NodeRequest) error {
    -	// Find a matching node set in the spec of the cluster:
    -	var nodeSetID string
    -	for candidateNodeSetID, candidateNodeSet := range t.cluster.GetSpec().GetNodeSets() {
    -		if candidateNodeSet.GetHostType() == nodeRequest.ResourceClass {
    -			nodeSetID = candidateNodeSetID
    -			break
    +		if nodeSetID == "" {
    +			log.Error(nil, "Failed to find a matching node set", "resource_class", nodeRequest.ResourceClass)
    +			continue
     		}
    -	}
    -	if nodeSetID == "" {
    -		t.r.logger.Error(
    -			nil,
    -			"Failed to find a matching node set",
    -			"resource_class", nodeRequest.ResourceClass,
    -		)
    -		return nil
    -	}
     
    -	// Find or create the matching node set in the status of the cluster:
    -	nodeSets := t.cluster.GetStatus().GetNodeSets()
    -	if nodeSets == nil {
    -		nodeSets = map[string]*privatev1.ClusterNodeSet{}
    -		t.cluster.GetStatus().SetNodeSets(nodeSets)
    -	}
    -	nodeSet := nodeSets[nodeSetID]
    -	if nodeSet == nil {
    -		nodeSet = privatev1.ClusterNodeSet_builder{
    -			HostType: nodeRequest.ResourceClass,
    -		}.Build()
    -		nodeSets[nodeSetID] = nodeSet
    -	}
    +		nodeSets := remote.GetStatus().GetNodeSets()
    +		if nodeSets == nil {
    +			nodeSets = map[string]*privatev1.ClusterNodeSet{}
    +			remote.GetStatus().SetNodeSets(nodeSets)
    +		}
    +		nodeSet := nodeSets[nodeSetID]
    +		if nodeSet == nil {
    +			nodeSet = privatev1.ClusterNodeSet_builder{
    +				HostType: nodeRequest.ResourceClass,
    +			}.Build()
    +			nodeSets[nodeSetID] = nodeSet
    +		}
     
    -	// Copy the number of nodes:
    -	oldValue := nodeSet.GetSize()
    -	newValue := int32(nodeRequest.NumberOfNodes)
    -	if newValue != oldValue {
    -		t.r.logger.Info(
    -			"Updating node set size",
    -			"resource_class", nodeRequest.ResourceClass,
    -			"old_value", oldValue,
    -			"new_value", newValue,
    -		)
    -		nodeSet.SetSize(newValue)
    +		oldValue := nodeSet.GetSize()
    +		newValue := int32(nodeRequest.NumberOfNodes)
    +		if newValue != oldValue {
    +			log.Info("Updating node set size",
    +				"resource_class", nodeRequest.ResourceClass,
    +				"old_value", oldValue,
    +				"new_value", newValue,
    +			)
    +			nodeSet.SetSize(newValue)
    +		}

    _🗄️ Data Integrity & Integration_ | _🟡 Minor_ | _⚡ Quick win_

    <details>
    <summary>🧩 Analysis chain</summary>

    🏁 Script executed:

    #!/bin/bash
    rg -nP -B3 -A1 '\bNumberOfNodes\b' --type=go api/
    

    Repository: osac-project/osac-operator

    Length of output: 742

    ---

    🏁 Script executed:

    #!/bin/bash
    set -euo pipefail
    
    # Locate and inspect the relevant Go code around the conversion and any validation.
    ast-grep outline internal/controller/feedback_controller.go --view compact || true
    sed -n '220,270p' internal/controller/feedback_controller.go
    rg -n "NumberOfNodes|SetSize|Number of nodes|positive|minimum|min" internal/controller/policycontroller.go internal/controller api -g '*.go'
    

    Repository: osac-project/osac-operator

    Length of output: 15441

    ---

    </details>

    Bounds-check NumberOfNodes before converting to int32.

    NumberOfNodes is defined as int, so values above math.MaxInt32 wrap to a negative int32 here and can be written to node-set status. Clamp or reject before calling nodeSet.SetSize(newValue).

    <details>
    <summary>🧰 Tools</summary>

    <details>
    <summary>🪛 ast-grep (0.45.0)</summary>

    [warning] 248-248: Narrowing a non-constant integer to a smaller fixed-width type (int8/int16/int32, uint8/uint16/uint32) can silently overflow or wrap, yielding negative or truncated values that are dangerous in size, length, or index logic. Validate the source value is within the target type's range before converting (e.g. bounds-check, or use a checked helper), and avoid narrowing untrusted or len()/parsed values.
    Context: int32(nodeRequest.NumberOfNodes)
    Note: [CWE-190] Integer Overflow or Wraparound.

    (integer-overflow-narrowing-conversion-go)

    </details>

    </details>

    <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/feedback_controller.go` around lines 248 - 257, Validate
    nodeRequest.NumberOfNodes in the node-set size update flow before converting it
    to int32, rejecting or clamping values above math.MaxInt32. Update the logic
    around nodeSet.GetSize and nodeSet.SetSize so only bounded values are converted
    and written, while preserving the existing change logging and update behavior
    for valid values.
    

    </details>

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

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

    <!-- cr-comment:v1:e134308cfea33280ac048b79 -->

    _Sources: Path instructions, Linters/SAST tools_

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

    coderabbitai[bot] coderabbitai[bot] requested changes on Jul 30, 2026 02:25 UTC
    Changes Requested Reviewer

    Actionable comments posted: 4

    <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/computeinstance_feedback_controller.go`:
    - Around line 110-124: Update syncComputeInstanceDelete to force the
    ComputeInstance phase to DELETING during deletion, preserving Failed when
    applicable, before the finalizer is removed. Mirror the existing
    subnet/NAT/Gateway delete-handler behavior and leave syncComputeInstanceUpdate
    unchanged.
    
    In `@internal/controller/feedback_controller.go`:
    - Around line 127-135: Replace the nil hubClient sentinel in
    syncClusterOrderPhase with an explicit fetchURLs parameter, and make
    syncClusterOrderPhaseReady gate HostedCluster lookup on fetchURLs rather than
    client nilness. Update all callers, including syncClusterOrderDelete, to pass
    the intended behavior; require and use hubClient whenever URL fetching is
    enabled.
    - Around line 248-257: Validate nodeRequest.NumberOfNodes in the node-set size
    update flow before converting it to int32, rejecting or clamping values above
    math.MaxInt32. Update the logic around nodeSet.GetSize and nodeSet.SetSize so
    only bounded values are converted and written, while preserving the existing
    change logging and update behavior for valid values.
    - Around line 137-150: The syncClusterOrderConditions function currently maps
    all recognized ClusterOrder conditions to the single remote PROGRESSING
    condition, collapsing distinct status signals and causing transition timestamps
    to overwrite each other. Update the mapping so each ClusterOrder condition is
    synchronized to its intended distinct concrete privatev1.ClusterConditionType,
    avoiding UNSPECIFIED or any shared destination unless explicitly intended; leave
    unknown-condition handling 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: 22cbecc4-297b-4926-9023-1bcecb31454a

    </details>

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

    Reviewing files that changed from the base of the PR and between 77e1d55eae193ba00986e66ab881d534a6ee2b03 and 78837790832ca7df116e8d103a1f91d66cb244a2.

    </details>

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

    cmd/main.go
    internal/controller/clusterorder_feedback_controller_test.go
    internal/controller/computeinstance_feedback_controller.go
    internal/controller/computeinstance_feedback_controller_test.go
    internal/controller/feedback_controller.go

    </details>

    <details>
    <summary>💤 Files with no reviewable changes (1)</summary>

    cmd/main.go

    </details>

    </details>

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

    vladikr vladikr commented on code on Jul 30, 2026 02:52 UTC
    Code Review
    internal/controller/computeinstance_feedback_controller.go:1
    @@ -71,260 +59,95 @@ func (r *ComputeInstanceFeedbackReconciler) SetupWithManager(mgr mcmanager.Manag
     		Complete(r)
     }
     
    -// Reconcile is the implementation of the reconciler interface.
    -func (r *ComputeInstanceFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error) {
    -	log := ctrllog.FromContext(ctx)
    -
    -	// Step 1: Fetch the CR from the hub cluster.
    -	object := &ckv1alpha1.ComputeInstance{}
    -	err = r.hubClient.Get(ctx, request.NamespacedName, object)
    -	if err != nil {
    -		if !apierrors.IsNotFound(err) {
    -			return result, err
    -		}
    -		// CR is gone. With the finalizer this shouldn't normally happen, but
    -		// handle gracefully (e.g. finalizer was removed externally).
    -		log.Info("CR not found, nothing to do")
    -		err = nil
    -		return result, err
    -	}
    -
    -	// Step 2: Get the compute instance ID from labels. CRs without this label
    -	// weren't created by the fulfillment service, so we ignore them.
    -	ciID, ok := object.Labels[osacComputeInstanceIDLabel]
    -	if !ok {
    -		// If being deleted and somehow has our finalizer, remove it to unblock deletion.
    -		if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -			log.Info("CR without CI ID label is being deleted, removing feedback finalizer")
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    +// Reconcile delegates to the shared feedback Bridge.
    +func (r *ComputeInstanceFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
    +	return r.bridge.Reconcile(ctx, request)
    +}
    +
    +// newComputeInstanceFeedbackBridge creates a Bridge wired to the given client. Exported for testing.
    +func newComputeInstanceFeedbackBridge(hubClient clnt.Client, ciClient privatev1.ComputeInstancesClient) *feedback.Bridge[*ckv1alpha1.ComputeInstance, *privatev1.ComputeInstance] {
    +	return &feedback.Bridge[*ckv1alpha1.ComputeInstance, *privatev1.ComputeInstance]{
    +		Client:    hubClient,
    +		Finalizer: osacComputeInstanceFeedbackFinalizer,
    +		IDLabel:   osacComputeInstanceIDLabel,
    +		Kind:      "ComputeInstance",
    +		IDKey:     "ciID",
    +		NewObject: func() *ckv1alpha1.ComputeInstance { return &ckv1alpha1.ComputeInstance{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.ComputeInstance, error) {
    +			response, err := ciClient.Get(ctx, privatev1.ComputeInstancesGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
     			}
    -			return result, err
    -		}
    -		log.Info(
    -			"There is no label containing the compute instance identifier, will ignore it",
    -			"label", osacComputeInstanceIDLabel,
    -		)
    -		return result, err
    -	}
    -
    -	// Step 3: Fetch the compute instance record from the fulfillment service
    -	// so we can compare before/after and only push changes.
    -	ci, err := r.fetchComputeInstance(ctx, ciID)
    -	if err != nil {
    -		if !object.DeletionTimestamp.IsZero() && status.Code(err) == codes.NotFound {
    -			log.Info("Compute instance record not found during deletion, removing feedback finalizer", "ciID", ciID)
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				return result, r.hubClient.Update(ctx, object)
    +			ci := response.GetObject()
    +			if ci == nil {
    +				return nil, errors.New("compute instance response contained nil object")
     			}
    -			return result, nil
    -		}
    -		return result, err
    -	}
    -
    -	t := &computeInstanceFeedbackReconcilerTask{
    -		r:      r,
    -		object: object,
    -		ci:     clone(ci),
    -	}
    -
    -	// Step 4: Sync CR state to the fulfillment service record.
    -	// handleUpdate also adds our finalizer; handleDelete only syncs state
    -	// (e.g. DELETING phase).
    -	if object.DeletionTimestamp.IsZero() {
    -		err = t.handleUpdate(ctx)
    -	} else {
    -		t.handleDelete(ctx)
    -	}
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 5: Persist synced state to the fulfillment service.
    -	err = r.saveComputeInstance(ctx, ci, t.ci)
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 6: Handle finalizer removal and signal for deletions. This must
    -	// happen after step 5 so the DELETING state is persisted before the CR
    -	// is garbage collected.
    -	if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -		if len(object.GetFinalizers()) == 1 {
    -			// We're the last finalizer. Remove it to trigger CR garbage
    -			// collection, then signal the fulfillment service to immediately
    -			// re-reconcile. Finalizer is removed first so the CR is gone
    -			// before the fulfillment controller checks — avoiding a race
    -			// where it sees the CR still exists and skips archival.
    -			log.Info(
    -				"Feedback finalizer is last remaining, removing finalizer and signaling",
    -				"ciID", ciID,
    -			)
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    -				if err != nil {
    -					return result, err
    -				}
    +			if !ci.HasSpec() {
    +				ci.SetSpec(&privatev1.ComputeInstanceSpec{})
     			}
    -			_, signalErr := r.computeInstancesClient.Signal(ctx, privatev1.ComputeInstancesSignalRequest_builder{
    -				Id: ciID,
    -			}.Build())
    -			if signalErr != nil {
    -				log.Error(
    -					signalErr,
    -					"Failed to signal fulfillment service, periodic sync will handle cleanup",
    -					"ciID", ciID,
    -				)
    +			if !ci.HasStatus() {
    +				ci.SetStatus(&privatev1.ComputeInstanceStatus{})
     			}
    -		} else {
    -			// Other finalizers still present — another controller hasn't
    -			// finished cleanup yet. When it removes its finalizer, the
    -			// Update event will trigger a new reconcile.
    -			log.Info(
    -				"Other finalizers still present, waiting",
    -				"finalizers", object.GetFinalizers(),
    -			)
    -		}
    -	}
    -
    -	return result, err
    -}
    -
    -// fetchComputeInstance retrieves a compute instance record from the fulfillment
    -// service by its ID, ensuring spec and status are initialized.
    -func (r *ComputeInstanceFeedbackReconciler) fetchComputeInstance(ctx context.Context, id string) (vm *privatev1.ComputeInstance, err error) {
    -	response, err := r.computeInstancesClient.Get(ctx, privatev1.ComputeInstancesGetRequest_builder{
    -		Id: id,
    -	}.Build())
    -	if err != nil {
    -		return
    -	}
    -	vm = response.GetObject()
    -	if !vm.HasSpec() {
    -		vm.SetSpec(&privatev1.ComputeInstanceSpec{})
    -	}
    -	if !vm.HasStatus() {
    -		vm.SetStatus(&privatev1.ComputeInstanceStatus{})
    -	}
    -	return
    -}
    -
    -// saveComputeInstance sends an update to the fulfillment service if the compute
    -// instance record has changed.
    -func (r *ComputeInstanceFeedbackReconciler) saveComputeInstance(ctx context.Context, before, after *privatev1.ComputeInstance) error {
    -	log := ctrllog.FromContext(ctx)
    -
    -	if !equal(after, before) {
    -		log.Info(
    -			"Updating compute instance",
    -			"before", before,
    -			"after", after,
    -		)
    -		_, err := r.computeInstancesClient.Update(ctx, privatev1.ComputeInstancesUpdateRequest_builder{
    -			Object: after,
    -		}.Build())
    -		if err != nil {
    +			return ci, nil
    +		},
    +		Save: func(ctx context.Context, remote *privatev1.ComputeInstance) error {
    +			_, err := ciClient.Update(ctx, privatev1.ComputeInstancesUpdateRequest_builder{
    +				Object: remote,
    +			}.Build())
     			return err
    -		}
    -	}
    -	return nil
    -}
    -
    -// handleUpdate ensures our finalizer is present and syncs the CR state to the
    -// fulfillment service. Called when the CR is not being deleted.
    -func (t *computeInstanceFeedbackReconcilerTask) handleUpdate(ctx context.Context) error {
    -	if controllerutil.AddFinalizer(t.object, osacComputeInstanceFeedbackFinalizer) {
    -		if err := t.r.hubClient.Update(ctx, t.object); err != nil {
    +		},
    +		Signal: func(ctx context.Context, id string) error {
    +			_, err := ciClient.Signal(ctx, privatev1.ComputeInstancesSignalRequest_builder{
    +				Id: id,
    +			}.Build())
     			return err
    -		}
    +		},
    +		SyncUpdate: syncComputeInstanceUpdate,
    +		SyncDelete: syncComputeInstanceDelete,
     	}
    -	t.syncState(ctx)
    -	return nil
    -}
    -
    -// handleDelete syncs the CR state (including the DELETING phase) to the
    -// fulfillment service. Called when the CR is being deleted.
    -func (t *computeInstanceFeedbackReconcilerTask) handleDelete(ctx context.Context) {
    -	t.syncState(ctx)
    -}
    -
    -// syncState synchronizes the CR's conditions, phase, IP addresses, and last
    -// restarted time to the fulfillment service's compute instance record.
    -func (t *computeInstanceFeedbackReconcilerTask) syncState(ctx context.Context) {
    -	t.syncConditions(ctx)
    -	t.syncPhase(ctx)
    -	t.syncIPAddresses()
    -	t.syncLastRestartedAt()
    -}
    -
    -func (t *computeInstanceFeedbackReconcilerTask) syncConditions(ctx context.Context) {
    -	t.syncConfigurationApplied(ctx)
    -	t.syncReady(ctx)
    -	t.syncRestartInProgress(ctx)
    -	t.syncRestartFailed(ctx)
    -	t.syncProvisioned(ctx)
    -	t.syncRestartRequired(ctx)
     }
     
    -// syncConfigurationApplied synchronizes the CONFIGURATION_APPLIED VM condition from the ConfigurationApplied CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncConfigurationApplied(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionConfigurationApplied)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_CONFIGURATION_APPLIED, crCondition)
    -}
    -
    -// syncReady synchronizes the READY VM condition from the Ready CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncReady(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionReady)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_READY, crCondition)
    -}
    -
    -// syncRestartInProgress synchronizes the RESTART_IN_PROGRESS VM condition from the RestartInProgress CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncRestartInProgress(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionRestartInProgress)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_RESTART_IN_PROGRESS, crCondition)
    -}
    -
    -// syncRestartFailed synchronizes the RESTART_FAILED VM condition from the RestartFailed CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncRestartFailed(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionRestartFailed)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_RESTART_FAILED, crCondition)
    +func syncComputeInstanceUpdate(ctx context.Context, obj *ckv1alpha1.ComputeInstance, remote *privatev1.ComputeInstance) error {
    +	syncCIConditions(obj, remote)
    +	syncCIPhase(ctx, obj, remote)
    +	syncCIIPAddresses(obj, remote)
    +	syncCILastRestartedAt(obj, remote)
    +	return nil
     }
     
    -// syncProvisioned synchronizes the PROVISIONED VM condition from the Provisioned CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncProvisioned(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionProvisioned)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_PROVISIONED, crCondition)
    +func syncComputeInstanceDelete(ctx context.Context, obj *ckv1alpha1.ComputeInstance, remote *privatev1.ComputeInstance) error {
    +	syncCIConditions(obj, remote)
    +	syncCIPhase(ctx, obj, remote)
    +	syncCIIPAddresses(obj, remote)
    +	syncCILastRestartedAt(obj, remote)
    +	return nil
     }

    hmm, bu this is exactly how it was before this change. the original handleDelete called syncState without forcing DELETING

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 30, 2026 02:53 UTC
    Code Review
    internal/controller/computeinstance_feedback_controller.go:1
    @@ -71,260 +59,95 @@ func (r *ComputeInstanceFeedbackReconciler) SetupWithManager(mgr mcmanager.Manag
     		Complete(r)
     }
     
    -// Reconcile is the implementation of the reconciler interface.
    -func (r *ComputeInstanceFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error) {
    -	log := ctrllog.FromContext(ctx)
    -
    -	// Step 1: Fetch the CR from the hub cluster.
    -	object := &ckv1alpha1.ComputeInstance{}
    -	err = r.hubClient.Get(ctx, request.NamespacedName, object)
    -	if err != nil {
    -		if !apierrors.IsNotFound(err) {
    -			return result, err
    -		}
    -		// CR is gone. With the finalizer this shouldn't normally happen, but
    -		// handle gracefully (e.g. finalizer was removed externally).
    -		log.Info("CR not found, nothing to do")
    -		err = nil
    -		return result, err
    -	}
    -
    -	// Step 2: Get the compute instance ID from labels. CRs without this label
    -	// weren't created by the fulfillment service, so we ignore them.
    -	ciID, ok := object.Labels[osacComputeInstanceIDLabel]
    -	if !ok {
    -		// If being deleted and somehow has our finalizer, remove it to unblock deletion.
    -		if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -			log.Info("CR without CI ID label is being deleted, removing feedback finalizer")
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    +// Reconcile delegates to the shared feedback Bridge.
    +func (r *ComputeInstanceFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
    +	return r.bridge.Reconcile(ctx, request)
    +}
    +
    +// newComputeInstanceFeedbackBridge creates a Bridge wired to the given client. Exported for testing.
    +func newComputeInstanceFeedbackBridge(hubClient clnt.Client, ciClient privatev1.ComputeInstancesClient) *feedback.Bridge[*ckv1alpha1.ComputeInstance, *privatev1.ComputeInstance] {
    +	return &feedback.Bridge[*ckv1alpha1.ComputeInstance, *privatev1.ComputeInstance]{
    +		Client:    hubClient,
    +		Finalizer: osacComputeInstanceFeedbackFinalizer,
    +		IDLabel:   osacComputeInstanceIDLabel,
    +		Kind:      "ComputeInstance",
    +		IDKey:     "ciID",
    +		NewObject: func() *ckv1alpha1.ComputeInstance { return &ckv1alpha1.ComputeInstance{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.ComputeInstance, error) {
    +			response, err := ciClient.Get(ctx, privatev1.ComputeInstancesGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
     			}
    -			return result, err
    -		}
    -		log.Info(
    -			"There is no label containing the compute instance identifier, will ignore it",
    -			"label", osacComputeInstanceIDLabel,
    -		)
    -		return result, err
    -	}
    -
    -	// Step 3: Fetch the compute instance record from the fulfillment service
    -	// so we can compare before/after and only push changes.
    -	ci, err := r.fetchComputeInstance(ctx, ciID)
    -	if err != nil {
    -		if !object.DeletionTimestamp.IsZero() && status.Code(err) == codes.NotFound {
    -			log.Info("Compute instance record not found during deletion, removing feedback finalizer", "ciID", ciID)
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				return result, r.hubClient.Update(ctx, object)
    +			ci := response.GetObject()
    +			if ci == nil {
    +				return nil, errors.New("compute instance response contained nil object")
     			}
    -			return result, nil
    -		}
    -		return result, err
    -	}
    -
    -	t := &computeInstanceFeedbackReconcilerTask{
    -		r:      r,
    -		object: object,
    -		ci:     clone(ci),
    -	}
    -
    -	// Step 4: Sync CR state to the fulfillment service record.
    -	// handleUpdate also adds our finalizer; handleDelete only syncs state
    -	// (e.g. DELETING phase).
    -	if object.DeletionTimestamp.IsZero() {
    -		err = t.handleUpdate(ctx)
    -	} else {
    -		t.handleDelete(ctx)
    -	}
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 5: Persist synced state to the fulfillment service.
    -	err = r.saveComputeInstance(ctx, ci, t.ci)
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 6: Handle finalizer removal and signal for deletions. This must
    -	// happen after step 5 so the DELETING state is persisted before the CR
    -	// is garbage collected.
    -	if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -		if len(object.GetFinalizers()) == 1 {
    -			// We're the last finalizer. Remove it to trigger CR garbage
    -			// collection, then signal the fulfillment service to immediately
    -			// re-reconcile. Finalizer is removed first so the CR is gone
    -			// before the fulfillment controller checks — avoiding a race
    -			// where it sees the CR still exists and skips archival.
    -			log.Info(
    -				"Feedback finalizer is last remaining, removing finalizer and signaling",
    -				"ciID", ciID,
    -			)
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    -				if err != nil {
    -					return result, err
    -				}
    +			if !ci.HasSpec() {
    +				ci.SetSpec(&privatev1.ComputeInstanceSpec{})
     			}
    -			_, signalErr := r.computeInstancesClient.Signal(ctx, privatev1.ComputeInstancesSignalRequest_builder{
    -				Id: ciID,
    -			}.Build())
    -			if signalErr != nil {
    -				log.Error(
    -					signalErr,
    -					"Failed to signal fulfillment service, periodic sync will handle cleanup",
    -					"ciID", ciID,
    -				)
    +			if !ci.HasStatus() {
    +				ci.SetStatus(&privatev1.ComputeInstanceStatus{})
     			}
    -		} else {
    -			// Other finalizers still present — another controller hasn't
    -			// finished cleanup yet. When it removes its finalizer, the
    -			// Update event will trigger a new reconcile.
    -			log.Info(
    -				"Other finalizers still present, waiting",
    -				"finalizers", object.GetFinalizers(),
    -			)
    -		}
    -	}
    -
    -	return result, err
    -}
    -
    -// fetchComputeInstance retrieves a compute instance record from the fulfillment
    -// service by its ID, ensuring spec and status are initialized.
    -func (r *ComputeInstanceFeedbackReconciler) fetchComputeInstance(ctx context.Context, id string) (vm *privatev1.ComputeInstance, err error) {
    -	response, err := r.computeInstancesClient.Get(ctx, privatev1.ComputeInstancesGetRequest_builder{
    -		Id: id,
    -	}.Build())
    -	if err != nil {
    -		return
    -	}
    -	vm = response.GetObject()
    -	if !vm.HasSpec() {
    -		vm.SetSpec(&privatev1.ComputeInstanceSpec{})
    -	}
    -	if !vm.HasStatus() {
    -		vm.SetStatus(&privatev1.ComputeInstanceStatus{})
    -	}
    -	return
    -}
    -
    -// saveComputeInstance sends an update to the fulfillment service if the compute
    -// instance record has changed.
    -func (r *ComputeInstanceFeedbackReconciler) saveComputeInstance(ctx context.Context, before, after *privatev1.ComputeInstance) error {
    -	log := ctrllog.FromContext(ctx)
    -
    -	if !equal(after, before) {
    -		log.Info(
    -			"Updating compute instance",
    -			"before", before,
    -			"after", after,
    -		)
    -		_, err := r.computeInstancesClient.Update(ctx, privatev1.ComputeInstancesUpdateRequest_builder{
    -			Object: after,
    -		}.Build())
    -		if err != nil {
    +			return ci, nil
    +		},
    +		Save: func(ctx context.Context, remote *privatev1.ComputeInstance) error {
    +			_, err := ciClient.Update(ctx, privatev1.ComputeInstancesUpdateRequest_builder{
    +				Object: remote,
    +			}.Build())
     			return err
    -		}
    -	}
    -	return nil
    -}
    -
    -// handleUpdate ensures our finalizer is present and syncs the CR state to the
    -// fulfillment service. Called when the CR is not being deleted.
    -func (t *computeInstanceFeedbackReconcilerTask) handleUpdate(ctx context.Context) error {
    -	if controllerutil.AddFinalizer(t.object, osacComputeInstanceFeedbackFinalizer) {
    -		if err := t.r.hubClient.Update(ctx, t.object); err != nil {
    +		},
    +		Signal: func(ctx context.Context, id string) error {
    +			_, err := ciClient.Signal(ctx, privatev1.ComputeInstancesSignalRequest_builder{
    +				Id: id,
    +			}.Build())
     			return err
    -		}
    +		},
    +		SyncUpdate: syncComputeInstanceUpdate,
    +		SyncDelete: syncComputeInstanceDelete,
     	}
    -	t.syncState(ctx)
    -	return nil
    -}
    -
    -// handleDelete syncs the CR state (including the DELETING phase) to the
    -// fulfillment service. Called when the CR is being deleted.
    -func (t *computeInstanceFeedbackReconcilerTask) handleDelete(ctx context.Context) {
    -	t.syncState(ctx)
    -}
    -
    -// syncState synchronizes the CR's conditions, phase, IP addresses, and last
    -// restarted time to the fulfillment service's compute instance record.
    -func (t *computeInstanceFeedbackReconcilerTask) syncState(ctx context.Context) {
    -	t.syncConditions(ctx)
    -	t.syncPhase(ctx)
    -	t.syncIPAddresses()
    -	t.syncLastRestartedAt()
    -}
    -
    -func (t *computeInstanceFeedbackReconcilerTask) syncConditions(ctx context.Context) {
    -	t.syncConfigurationApplied(ctx)
    -	t.syncReady(ctx)
    -	t.syncRestartInProgress(ctx)
    -	t.syncRestartFailed(ctx)
    -	t.syncProvisioned(ctx)
    -	t.syncRestartRequired(ctx)
     }
     
    -// syncConfigurationApplied synchronizes the CONFIGURATION_APPLIED VM condition from the ConfigurationApplied CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncConfigurationApplied(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionConfigurationApplied)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_CONFIGURATION_APPLIED, crCondition)
    -}
    -
    -// syncReady synchronizes the READY VM condition from the Ready CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncReady(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionReady)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_READY, crCondition)
    -}
    -
    -// syncRestartInProgress synchronizes the RESTART_IN_PROGRESS VM condition from the RestartInProgress CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncRestartInProgress(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionRestartInProgress)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_RESTART_IN_PROGRESS, crCondition)
    -}
    -
    -// syncRestartFailed synchronizes the RESTART_FAILED VM condition from the RestartFailed CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncRestartFailed(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionRestartFailed)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_RESTART_FAILED, crCondition)
    +func syncComputeInstanceUpdate(ctx context.Context, obj *ckv1alpha1.ComputeInstance, remote *privatev1.ComputeInstance) error {
    +	syncCIConditions(obj, remote)
    +	syncCIPhase(ctx, obj, remote)
    +	syncCIIPAddresses(obj, remote)
    +	syncCILastRestartedAt(obj, remote)
    +	return nil
     }
     
    -// syncProvisioned synchronizes the PROVISIONED VM condition from the Provisioned CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncProvisioned(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionProvisioned)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_PROVISIONED, crCondition)
    +func syncComputeInstanceDelete(ctx context.Context, obj *ckv1alpha1.ComputeInstance, remote *privatev1.ComputeInstance) error {
    +	syncCIConditions(obj, remote)
    +	syncCIPhase(ctx, obj, remote)
    +	syncCIIPAddresses(obj, remote)
    +	syncCILastRestartedAt(obj, remote)
    +	return nil
     }

    @vladikr, you’re right. The original handleDelete called syncState and therefore preserved the CR’s existing phase; this migration retains that behavior through syncCIPhase. My concern describes a pre-existing behavior, not a regression introduced by this PR, so I’m withdrawing the finding.

    🐇
    <!-- <review_comment_withdrawn> -->

    ---

    <details>
    <summary>✏️ Learnings added</summary>

    Learnt from: vladikr
    Repo: osac-project/osac-operator PR: 402
    File: internal/controller/computeinstance_feedback_controller.go:110-124
    Timestamp: 2026-07-30T02:52:59.635Z
    Learning: In `internal/controller/computeinstance_feedback_controller.go`, ComputeInstance deletion feedback preserves the CR’s existing phase through the normal phase synchronization path; it does not forcibly set the remote state to `COMPUTE_INSTANCE_STATE_DELETING`. This behavior existed before the feedback.Bridge migration.
    

    Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

    </details>

    <sub>You are interacting with an AI system.</sub>

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

    vladikr vladikr commented on code on Jul 30, 2026 03:14 UTC
    Code Review
    internal/controller/feedback_controller.go:1
    @@ -326,177 +171,138 @@ func (t *feedbackReconcilerTask) mapConditionStatus(status metav1.ConditionStatu
     	}
     }
     
    -func (t *feedbackReconcilerTask) syncPhase(ctx context.Context) error {
    -	switch t.object.Status.Phase {
    +func syncClusterOrderPhase(ctx context.Context, hubClient clnt.Client, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +	log := ctrllog.FromContext(ctx)
    +	switch obj.Status.Phase {
     	case ckv1alpha1.ClusterOrderPhaseProgressing:
    -		return t.syncPhaseProgressing()
    +		remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_PROGRESSING)
     	case ckv1alpha1.ClusterOrderPhaseFailed:
    -		return t.syncPhaseFailed()
    +		remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_FAILED)
     	case ckv1alpha1.ClusterOrderPhaseReady:
    -		return t.syncPhaseReady(ctx)
    +		return syncClusterOrderPhaseReady(ctx, hubClient, obj, remote)
     	case ckv1alpha1.ClusterOrderPhaseDeleting:
    -		return t.syncPhaseDeleting()
    +		remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_DELETING)
     	default:
    -		t.r.logger.Info(
    -			"Unknown phase, will ignore it",
    -			"phase", t.object.Status.Phase,
    -		)
    +		log.Info("Unknown phase, will ignore it", "phase", obj.Status.Phase)
     	}
     	return nil
     }
     
    -func (t *feedbackReconcilerTask) syncPhaseProgressing() error {
    -	t.cluster.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_PROGRESSING)
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncPhaseFailed() error {
    -	t.cluster.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_FAILED)
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncPhaseReady(ctx context.Context) error {
    -	// Set the status of the cluster:
    -	clusterStatus := t.cluster.GetStatus()
    +func syncClusterOrderPhaseReady(ctx context.Context, hubClient clnt.Client, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +	clusterStatus := remote.GetStatus()
     	clusterStatus.SetState(privatev1.ClusterState_CLUSTER_STATE_READY)
     
    -	// In order to get the API and console URL we need to fetch the hosted cluster:
    -	err := t.fetchHostedCluster(ctx)
    +	if hubClient == nil {
    +		return nil
    +	}
    +
    +	hostedCluster, err := fetchHostedCluster(ctx, hubClient, obj)
     	if err != nil {
     		return err
     	}
    -	apiURL := t.calculateAPIURL()
    +	if hostedCluster == nil {
    +		return nil
    +	}
    +
    +	apiURL := calculateAPIURL(hostedCluster)
     	if apiURL != "" {
     		clusterStatus.SetApiUrl(apiURL)
     	}
    -	consoleURL := t.calculateConsoleURL()
    +	consoleURL := calculateConsoleURL(hostedCluster)
     	if consoleURL != "" {
     		clusterStatus.SetConsoleUrl(consoleURL)
     	}
    -
     	return nil
     }
     
    -func (t *feedbackReconcilerTask) syncNodeRequests() error {
    -	for i := range len(t.object.Status.NodeRequests) {
    -		err := t.syncNodeRequest(&t.object.Status.NodeRequests[i])
    -		if err != nil {
    -			return err
    +func syncClusterOrderNodeRequests(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) {
    +	log := ctrllog.FromContext(ctx)
    +	for i := range len(obj.Status.NodeRequests) {
    +		nodeRequest := &obj.Status.NodeRequests[i]
    +
    +		var nodeSetID string
    +		for candidateNodeSetID, candidateNodeSet := range remote.GetSpec().GetNodeSets() {
    +			if candidateNodeSet.GetHostType() == nodeRequest.ResourceClass {
    +				nodeSetID = candidateNodeSetID
    +				break
    +			}
     		}
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncNodeRequest(nodeRequest *ckv1alpha1.NodeRequest) error {
    -	// Find a matching node set in the spec of the cluster:
    -	var nodeSetID string
    -	for candidateNodeSetID, candidateNodeSet := range t.cluster.GetSpec().GetNodeSets() {
    -		if candidateNodeSet.GetHostType() == nodeRequest.ResourceClass {
    -			nodeSetID = candidateNodeSetID
    -			break
    +		if nodeSetID == "" {
    +			log.Error(nil, "Failed to find a matching node set", "resource_class", nodeRequest.ResourceClass)
    +			continue
     		}
    -	}
    -	if nodeSetID == "" {
    -		t.r.logger.Error(
    -			nil,
    -			"Failed to find a matching node set",
    -			"resource_class", nodeRequest.ResourceClass,
    -		)
    -		return nil
    -	}
     
    -	// Find or create the matching node set in the status of the cluster:
    -	nodeSets := t.cluster.GetStatus().GetNodeSets()
    -	if nodeSets == nil {
    -		nodeSets = map[string]*privatev1.ClusterNodeSet{}
    -		t.cluster.GetStatus().SetNodeSets(nodeSets)
    -	}
    -	nodeSet := nodeSets[nodeSetID]
    -	if nodeSet == nil {
    -		nodeSet = privatev1.ClusterNodeSet_builder{
    -			HostType: nodeRequest.ResourceClass,
    -		}.Build()
    -		nodeSets[nodeSetID] = nodeSet
    -	}
    +		nodeSets := remote.GetStatus().GetNodeSets()
    +		if nodeSets == nil {
    +			nodeSets = map[string]*privatev1.ClusterNodeSet{}
    +			remote.GetStatus().SetNodeSets(nodeSets)
    +		}
    +		nodeSet := nodeSets[nodeSetID]
    +		if nodeSet == nil {
    +			nodeSet = privatev1.ClusterNodeSet_builder{
    +				HostType: nodeRequest.ResourceClass,
    +			}.Build()
    +			nodeSets[nodeSetID] = nodeSet
    +		}
     
    -	// Copy the number of nodes:
    -	oldValue := nodeSet.GetSize()
    -	newValue := int32(nodeRequest.NumberOfNodes)
    -	if newValue != oldValue {
    -		t.r.logger.Info(
    -			"Updating node set size",
    -			"resource_class", nodeRequest.ResourceClass,
    -			"old_value", oldValue,
    -			"new_value", newValue,
    -		)
    -		nodeSet.SetSize(newValue)
    +		oldValue := nodeSet.GetSize()
    +		newValue := int32(nodeRequest.NumberOfNodes)
    +		if newValue != oldValue {
    +			log.Info("Updating node set size",
    +				"resource_class", nodeRequest.ResourceClass,
    +				"old_value", oldValue,
    +				"new_value", newValue,
    +			)
    +			nodeSet.SetSize(newValue)
    +		}

    yes, indeed; however, this limitation was there before this change.

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 30, 2026 03:14 UTC
    Code Review
    internal/controller/feedback_controller.go:1
    @@ -326,177 +171,138 @@ func (t *feedbackReconcilerTask) mapConditionStatus(status metav1.ConditionStatu
     	}
     }
     
    -func (t *feedbackReconcilerTask) syncPhase(ctx context.Context) error {
    -	switch t.object.Status.Phase {
    +func syncClusterOrderPhase(ctx context.Context, hubClient clnt.Client, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +	log := ctrllog.FromContext(ctx)
    +	switch obj.Status.Phase {
     	case ckv1alpha1.ClusterOrderPhaseProgressing:
    -		return t.syncPhaseProgressing()
    +		remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_PROGRESSING)
     	case ckv1alpha1.ClusterOrderPhaseFailed:
    -		return t.syncPhaseFailed()
    +		remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_FAILED)
     	case ckv1alpha1.ClusterOrderPhaseReady:
    -		return t.syncPhaseReady(ctx)
    +		return syncClusterOrderPhaseReady(ctx, hubClient, obj, remote)
     	case ckv1alpha1.ClusterOrderPhaseDeleting:
    -		return t.syncPhaseDeleting()
    +		remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_DELETING)
     	default:
    -		t.r.logger.Info(
    -			"Unknown phase, will ignore it",
    -			"phase", t.object.Status.Phase,
    -		)
    +		log.Info("Unknown phase, will ignore it", "phase", obj.Status.Phase)
     	}
     	return nil
     }
     
    -func (t *feedbackReconcilerTask) syncPhaseProgressing() error {
    -	t.cluster.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_PROGRESSING)
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncPhaseFailed() error {
    -	t.cluster.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_FAILED)
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncPhaseReady(ctx context.Context) error {
    -	// Set the status of the cluster:
    -	clusterStatus := t.cluster.GetStatus()
    +func syncClusterOrderPhaseReady(ctx context.Context, hubClient clnt.Client, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +	clusterStatus := remote.GetStatus()
     	clusterStatus.SetState(privatev1.ClusterState_CLUSTER_STATE_READY)
     
    -	// In order to get the API and console URL we need to fetch the hosted cluster:
    -	err := t.fetchHostedCluster(ctx)
    +	if hubClient == nil {
    +		return nil
    +	}
    +
    +	hostedCluster, err := fetchHostedCluster(ctx, hubClient, obj)
     	if err != nil {
     		return err
     	}
    -	apiURL := t.calculateAPIURL()
    +	if hostedCluster == nil {
    +		return nil
    +	}
    +
    +	apiURL := calculateAPIURL(hostedCluster)
     	if apiURL != "" {
     		clusterStatus.SetApiUrl(apiURL)
     	}
    -	consoleURL := t.calculateConsoleURL()
    +	consoleURL := calculateConsoleURL(hostedCluster)
     	if consoleURL != "" {
     		clusterStatus.SetConsoleUrl(consoleURL)
     	}
    -
     	return nil
     }
     
    -func (t *feedbackReconcilerTask) syncNodeRequests() error {
    -	for i := range len(t.object.Status.NodeRequests) {
    -		err := t.syncNodeRequest(&t.object.Status.NodeRequests[i])
    -		if err != nil {
    -			return err
    +func syncClusterOrderNodeRequests(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) {
    +	log := ctrllog.FromContext(ctx)
    +	for i := range len(obj.Status.NodeRequests) {
    +		nodeRequest := &obj.Status.NodeRequests[i]
    +
    +		var nodeSetID string
    +		for candidateNodeSetID, candidateNodeSet := range remote.GetSpec().GetNodeSets() {
    +			if candidateNodeSet.GetHostType() == nodeRequest.ResourceClass {
    +				nodeSetID = candidateNodeSetID
    +				break
    +			}
     		}
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncNodeRequest(nodeRequest *ckv1alpha1.NodeRequest) error {
    -	// Find a matching node set in the spec of the cluster:
    -	var nodeSetID string
    -	for candidateNodeSetID, candidateNodeSet := range t.cluster.GetSpec().GetNodeSets() {
    -		if candidateNodeSet.GetHostType() == nodeRequest.ResourceClass {
    -			nodeSetID = candidateNodeSetID
    -			break
    +		if nodeSetID == "" {
    +			log.Error(nil, "Failed to find a matching node set", "resource_class", nodeRequest.ResourceClass)
    +			continue
     		}
    -	}
    -	if nodeSetID == "" {
    -		t.r.logger.Error(
    -			nil,
    -			"Failed to find a matching node set",
    -			"resource_class", nodeRequest.ResourceClass,
    -		)
    -		return nil
    -	}
     
    -	// Find or create the matching node set in the status of the cluster:
    -	nodeSets := t.cluster.GetStatus().GetNodeSets()
    -	if nodeSets == nil {
    -		nodeSets = map[string]*privatev1.ClusterNodeSet{}
    -		t.cluster.GetStatus().SetNodeSets(nodeSets)
    -	}
    -	nodeSet := nodeSets[nodeSetID]
    -	if nodeSet == nil {
    -		nodeSet = privatev1.ClusterNodeSet_builder{
    -			HostType: nodeRequest.ResourceClass,
    -		}.Build()
    -		nodeSets[nodeSetID] = nodeSet
    -	}
    +		nodeSets := remote.GetStatus().GetNodeSets()
    +		if nodeSets == nil {
    +			nodeSets = map[string]*privatev1.ClusterNodeSet{}
    +			remote.GetStatus().SetNodeSets(nodeSets)
    +		}
    +		nodeSet := nodeSets[nodeSetID]
    +		if nodeSet == nil {
    +			nodeSet = privatev1.ClusterNodeSet_builder{
    +				HostType: nodeRequest.ResourceClass,
    +			}.Build()
    +			nodeSets[nodeSetID] = nodeSet
    +		}
     
    -	// Copy the number of nodes:
    -	oldValue := nodeSet.GetSize()
    -	newValue := int32(nodeRequest.NumberOfNodes)
    -	if newValue != oldValue {
    -		t.r.logger.Info(
    -			"Updating node set size",
    -			"resource_class", nodeRequest.ResourceClass,
    -			"old_value", oldValue,
    -			"new_value", newValue,
    -		)
    -		nodeSet.SetSize(newValue)
    +		oldValue := nodeSet.GetSize()
    +		newValue := int32(nodeRequest.NumberOfNodes)
    +		if newValue != oldValue {
    +			log.Info("Updating node set size",
    +				"resource_class", nodeRequest.ResourceClass,
    +				"old_value", oldValue,
    +				"new_value", newValue,
    +			)
    +			nodeSet.SetSize(newValue)
    +		}

    @vladikr, agreed—this is pre-existing behavior and not introduced by this bridge migration, so I’m withdrawing the finding for this PR. Would you like me to open a follow-up issue to track the bounds check separately?

    🐇
    <!-- <review_comment_withdrawn> -->

    <sub>You are interacting with an AI system.</sub>

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

    vladikr vladikr commented on code on Jul 30, 2026 03:16 UTC
    Code Review
    internal/controller/feedback_controller.go:1
    @@ -77,245 +62,105 @@ func (r *FeedbackReconciler) SetupWithManager(mgr mcmanager.Manager) error {
     		Complete(r)
     }
     
    -// Reconcile is the implementation of the reconciler interface.
    -func (r *FeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error) {
    -	log := ctrllog.FromContext(ctx)
    -
    -	// Step 1: Fetch the CR from the hub cluster.
    -	object := &ckv1alpha1.ClusterOrder{}
    -	err = r.hubClient.Get(ctx, request.NamespacedName, object)
    -	if err != nil {
    -		if !apierrors.IsNotFound(err) {
    -			return result, err
    -		}
    -		log.Info("CR not found, nothing to do")
    -		return result, nil
    -	}
    +// Reconcile delegates to the shared feedback Bridge.
    +func (r *FeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
    +	return r.bridge.Reconcile(ctx, request)
    +}
     
    -	// Step 2: Get the cluster ID from labels. CRs without this label
    -	// are not linked to a fulfillment-service cluster record, so we
    -	// skip them — except when being deleted with our finalizer still
    -	// present, in which case we remove it to unblock garbage collection.
    -	clusterID, ok := object.Labels[osacClusterOrderIDLabel]
    -	if !ok {
    -		if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -			log.Info("CR without cluster ID label is being deleted, removing feedback finalizer")
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    +// newClusterOrderFeedbackBridge creates a Bridge wired to the given clients. Used by both
    +// the constructor and tests.
    +func newClusterOrderFeedbackBridge(hubClient clnt.Client, clustersClient privatev1.ClustersClient) *feedback.Bridge[*ckv1alpha1.ClusterOrder, *privatev1.Cluster] {
    +	return &feedback.Bridge[*ckv1alpha1.ClusterOrder, *privatev1.Cluster]{
    +		Client:    hubClient,
    +		Finalizer: osacClusterOrderFeedbackFinalizer,
    +		IDLabel:   osacClusterOrderIDLabel,
    +		Kind:      "ClusterOrder",
    +		IDKey:     "clusterID",
    +		NewObject: func() *ckv1alpha1.ClusterOrder { return &ckv1alpha1.ClusterOrder{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.Cluster, error) {
    +			response, err := clustersClient.Get(ctx, privatev1.ClustersGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
     			}
    -			return result, err
    -		}
    -		r.logger.Info(
    -			"There is no label containing the cluster identifier, will ignore it",
    -			"label", osacClusterOrderIDLabel,
    -		)
    -		return result, nil
    -	}
    -
    -	// Step 3: Fetch the cluster record from the fulfillment service.
    -	cluster, err := r.fetchCluster(ctx, clusterID)
    -	if err != nil {
    -		if !object.DeletionTimestamp.IsZero() && status.Code(err) == codes.NotFound {
    -			log.Info("Cluster record not found during deletion, removing feedback finalizer", "clusterID", clusterID)
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				return result, r.hubClient.Update(ctx, object)
    +			cluster := response.GetObject()
    +			if cluster == nil {
    +				return nil, errors.New("cluster response contained nil object")
     			}
    -			return result, nil
    -		}
    -		return result, err
    -	}
    -
    -	// Step 4: Sync CR state to the fulfillment service record.
    -	t := &feedbackReconcilerTask{
    -		r:       r,
    -		object:  object,
    -		cluster: clone(cluster),
    -	}
    -	if object.DeletionTimestamp.IsZero() {
    -		err = t.handleUpdate(ctx)
    -	} else {
    -		err = t.handleDelete(ctx)
    -	}
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 5: Persist synced state to the fulfillment service.
    -	err = r.saveCluster(ctx, cluster, t.cluster)
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 6: Handle finalizer removal and signal for deletions.
    -	if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -		if len(object.GetFinalizers()) == 1 {
    -			log.Info(
    -				"Feedback finalizer is last remaining, removing finalizer and signaling",
    -				"clusterID", clusterID,
    -			)
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    -				if err != nil {
    -					return result, err
    -				}
    +			if !cluster.HasSpec() {
    +				cluster.SetSpec(&privatev1.ClusterSpec{})
     			}
    -			_, signalErr := r.clustersClient.Signal(ctx, privatev1.ClustersSignalRequest_builder{
    -				Id: clusterID,
    -			}.Build())
    -			if signalErr != nil {
    -				log.Error(
    -					signalErr,
    -					"Failed to signal fulfillment service, periodic sync will handle cleanup",
    -					"clusterID", clusterID,
    -				)
    +			if !cluster.HasStatus() {
    +				cluster.SetStatus(&privatev1.ClusterStatus{})
     			}
    -		} else {
    -			log.Info(
    -				"Other finalizers still present, waiting",
    -				"finalizers", object.GetFinalizers(),
    -			)
    -		}
    -	}
    -
    -	return result, err
    -}
    -
    -func (r *FeedbackReconciler) fetchCluster(ctx context.Context, id string) (cluster *privatev1.Cluster, err error) {
    -	response, err := r.clustersClient.Get(ctx, privatev1.ClustersGetRequest_builder{
    -		Id: id,
    -	}.Build())
    -	if err != nil {
    -		return
    -	}
    -	cluster = response.GetObject()
    -	if !cluster.HasSpec() {
    -		cluster.SetSpec(&privatev1.ClusterSpec{})
    -	}
    -	if !cluster.HasStatus() {
    -		cluster.SetStatus(&privatev1.ClusterStatus{})
    -	}
    -	return
    -}
    -
    -func (r *FeedbackReconciler) saveCluster(ctx context.Context, before, after *privatev1.Cluster) error {
    -	if !equal(after, before) {
    -		_, err := r.clustersClient.Update(ctx, privatev1.ClustersUpdateRequest_builder{
    -			Object: after,
    -		}.Build())
    -		if err != nil {
    +			return cluster, nil
    +		},
    +		Save: func(ctx context.Context, remote *privatev1.Cluster) error {
    +			_, err := clustersClient.Update(ctx, privatev1.ClustersUpdateRequest_builder{
    +				Object: remote,
    +			}.Build())
     			return err
    -		}
    +		},
    +		Signal: func(ctx context.Context, id string) error {
    +			_, err := clustersClient.Signal(ctx, privatev1.ClustersSignalRequest_builder{
    +				Id: id,
    +			}.Build())
    +			return err
    +		},
    +		SyncUpdate: newClusterOrderSyncUpdate(hubClient),
    +		SyncDelete: syncClusterOrderDelete,
     	}
    -	return nil
     }
     
    -func (t *feedbackReconcilerTask) handleUpdate(ctx context.Context) error {
    -	if controllerutil.AddFinalizer(t.object, osacClusterOrderFeedbackFinalizer) {
    -		if err := t.r.hubClient.Update(ctx, t.object); err != nil {
    +// newClusterOrderSyncUpdate returns a SyncUpdate function that captures hubClient
    +// for HostedCluster lookups on the Ready phase.
    +func newClusterOrderSyncUpdate(hubClient clnt.Client) func(context.Context, *ckv1alpha1.ClusterOrder, *privatev1.Cluster) error {
    +	return func(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +		syncClusterOrderConditions(ctx, obj, remote)
    +		if err := syncClusterOrderPhase(ctx, hubClient, obj, remote); err != nil {
     			return err
     		}
    +		syncClusterOrderNodeRequests(ctx, obj, remote)
    +		return nil
     	}
    -	return t.syncState(ctx)
    -}
    -
    -func (t *feedbackReconcilerTask) handleDelete(ctx context.Context) error {
    -	if err := t.syncState(ctx); err != nil {
    -		return err
    -	}
    -	return t.syncPhaseDeleting()
     }
     
    -func (t *feedbackReconcilerTask) syncState(ctx context.Context) error {
    -	if err := t.syncConditions(); err != nil {
    -		return err
    -	}
    -	if err := t.syncPhase(ctx); err != nil {
    -		return err
    -	}
    -	if err := t.syncNodeRequests(); err != nil {
    +func syncClusterOrderDelete(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +	syncClusterOrderConditions(ctx, obj, remote)
    +	if err := syncClusterOrderPhase(ctx, nil, obj, remote); err != nil {
     		return err
     	}
    +	syncClusterOrderNodeRequests(ctx, obj, remote)
    +	remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_DELETING)
     	return nil
     }
     
    -func (t *feedbackReconcilerTask) syncConditions() error {
    -	for _, condition := range t.object.Status.Conditions {
    -		err := t.syncCondition(condition)
    -		if err != nil {
    -			return err
    +func syncClusterOrderConditions(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) {
    +	log := ctrllog.FromContext(ctx)
    +	for _, condition := range obj.Status.Conditions {
    +		switch ckv1alpha1.ClusterOrderConditionType(condition.Type) {
    +		case ckv1alpha1.ClusterOrderConditionAccepted,
    +			ckv1alpha1.ClusterOrderConditionProgressing,
    +			ckv1alpha1.ClusterOrderConditionControlPlaneAvailable,
    +			ckv1alpha1.ClusterOrderConditionAvailable:
    +			syncClusterConditionFromCR(remote, privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING, condition)
    +		default:
    +			log.Info("Unknown condition, will ignore it", "condition", condition.Type)
     		}
     	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncCondition(condition metav1.Condition) error {
    -	switch ckv1alpha1.ClusterOrderConditionType(condition.Type) {
    -	case ckv1alpha1.ClusterOrderConditionAccepted:
    -		return t.syncConditionAccepted(condition)
    -	case ckv1alpha1.ClusterOrderConditionProgressing:
    -		return t.syncConditionProgressing(condition)
    -	case ckv1alpha1.ClusterOrderConditionControlPlaneAvailable:
    -		return t.syncConditionControlPlaneAvailable(condition)
    -	case ckv1alpha1.ClusterOrderConditionAvailable:
    -		return t.syncConditionAvailable(condition)
    -	default:
    -		t.r.logger.Info(
    -			"Unknown condition, will ignore it",
    -			"condition", condition.Type,
    -		)
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncConditionAccepted(condition metav1.Condition) error {
    -	orderCondition := t.findClusterCondition(privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING)
    -	oldStatus := orderCondition.GetStatus()
    -	newStatus := t.mapConditionStatus(condition.Status)
    -	orderCondition.SetStatus(newStatus)
    -	orderCondition.SetMessage(condition.Message)
    -	if newStatus != oldStatus {
    -		orderCondition.SetLastTransitionTime(timestamppb.Now())
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncConditionProgressing(condition metav1.Condition) error {
    -	orderCondition := t.findClusterCondition(privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING)
    -	oldStatus := orderCondition.GetStatus()
    -	newStatus := t.mapConditionStatus(condition.Status)
    -	orderCondition.SetStatus(newStatus)
    -	orderCondition.SetMessage(condition.Message)
    -	if newStatus != oldStatus {
    -		orderCondition.SetLastTransitionTime(timestamppb.Now())
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncConditionControlPlaneAvailable(condition metav1.Condition) error {
    -	orderCondition := t.findClusterCondition(privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING)
    -	oldStatus := orderCondition.GetStatus()
    -	newStatus := t.mapConditionStatus(condition.Status)
    -	orderCondition.SetStatus(newStatus)
    -	orderCondition.SetMessage(condition.Message)
    -	if newStatus != oldStatus {
    -		orderCondition.SetLastTransitionTime(timestamppb.Now())
    -	}
    -	return nil
     }

    This behavior was there prior to this change as well. all four original syncCondition* functions mapped to CLUSTER_CONDITION_TYPE_PROGRESSING
    I can follow up but not in this PR.

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 30, 2026 03:16 UTC
    Code Review
    internal/controller/feedback_controller.go:1
    @@ -77,245 +62,105 @@ func (r *FeedbackReconciler) SetupWithManager(mgr mcmanager.Manager) error {
     		Complete(r)
     }
     
    -// Reconcile is the implementation of the reconciler interface.
    -func (r *FeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error) {
    -	log := ctrllog.FromContext(ctx)
    -
    -	// Step 1: Fetch the CR from the hub cluster.
    -	object := &ckv1alpha1.ClusterOrder{}
    -	err = r.hubClient.Get(ctx, request.NamespacedName, object)
    -	if err != nil {
    -		if !apierrors.IsNotFound(err) {
    -			return result, err
    -		}
    -		log.Info("CR not found, nothing to do")
    -		return result, nil
    -	}
    +// Reconcile delegates to the shared feedback Bridge.
    +func (r *FeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
    +	return r.bridge.Reconcile(ctx, request)
    +}
     
    -	// Step 2: Get the cluster ID from labels. CRs without this label
    -	// are not linked to a fulfillment-service cluster record, so we
    -	// skip them — except when being deleted with our finalizer still
    -	// present, in which case we remove it to unblock garbage collection.
    -	clusterID, ok := object.Labels[osacClusterOrderIDLabel]
    -	if !ok {
    -		if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -			log.Info("CR without cluster ID label is being deleted, removing feedback finalizer")
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    +// newClusterOrderFeedbackBridge creates a Bridge wired to the given clients. Used by both
    +// the constructor and tests.
    +func newClusterOrderFeedbackBridge(hubClient clnt.Client, clustersClient privatev1.ClustersClient) *feedback.Bridge[*ckv1alpha1.ClusterOrder, *privatev1.Cluster] {
    +	return &feedback.Bridge[*ckv1alpha1.ClusterOrder, *privatev1.Cluster]{
    +		Client:    hubClient,
    +		Finalizer: osacClusterOrderFeedbackFinalizer,
    +		IDLabel:   osacClusterOrderIDLabel,
    +		Kind:      "ClusterOrder",
    +		IDKey:     "clusterID",
    +		NewObject: func() *ckv1alpha1.ClusterOrder { return &ckv1alpha1.ClusterOrder{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.Cluster, error) {
    +			response, err := clustersClient.Get(ctx, privatev1.ClustersGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
     			}
    -			return result, err
    -		}
    -		r.logger.Info(
    -			"There is no label containing the cluster identifier, will ignore it",
    -			"label", osacClusterOrderIDLabel,
    -		)
    -		return result, nil
    -	}
    -
    -	// Step 3: Fetch the cluster record from the fulfillment service.
    -	cluster, err := r.fetchCluster(ctx, clusterID)
    -	if err != nil {
    -		if !object.DeletionTimestamp.IsZero() && status.Code(err) == codes.NotFound {
    -			log.Info("Cluster record not found during deletion, removing feedback finalizer", "clusterID", clusterID)
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				return result, r.hubClient.Update(ctx, object)
    +			cluster := response.GetObject()
    +			if cluster == nil {
    +				return nil, errors.New("cluster response contained nil object")
     			}
    -			return result, nil
    -		}
    -		return result, err
    -	}
    -
    -	// Step 4: Sync CR state to the fulfillment service record.
    -	t := &feedbackReconcilerTask{
    -		r:       r,
    -		object:  object,
    -		cluster: clone(cluster),
    -	}
    -	if object.DeletionTimestamp.IsZero() {
    -		err = t.handleUpdate(ctx)
    -	} else {
    -		err = t.handleDelete(ctx)
    -	}
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 5: Persist synced state to the fulfillment service.
    -	err = r.saveCluster(ctx, cluster, t.cluster)
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 6: Handle finalizer removal and signal for deletions.
    -	if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -		if len(object.GetFinalizers()) == 1 {
    -			log.Info(
    -				"Feedback finalizer is last remaining, removing finalizer and signaling",
    -				"clusterID", clusterID,
    -			)
    -			if controllerutil.RemoveFinalizer(object, osacClusterOrderFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    -				if err != nil {
    -					return result, err
    -				}
    +			if !cluster.HasSpec() {
    +				cluster.SetSpec(&privatev1.ClusterSpec{})
     			}
    -			_, signalErr := r.clustersClient.Signal(ctx, privatev1.ClustersSignalRequest_builder{
    -				Id: clusterID,
    -			}.Build())
    -			if signalErr != nil {
    -				log.Error(
    -					signalErr,
    -					"Failed to signal fulfillment service, periodic sync will handle cleanup",
    -					"clusterID", clusterID,
    -				)
    +			if !cluster.HasStatus() {
    +				cluster.SetStatus(&privatev1.ClusterStatus{})
     			}
    -		} else {
    -			log.Info(
    -				"Other finalizers still present, waiting",
    -				"finalizers", object.GetFinalizers(),
    -			)
    -		}
    -	}
    -
    -	return result, err
    -}
    -
    -func (r *FeedbackReconciler) fetchCluster(ctx context.Context, id string) (cluster *privatev1.Cluster, err error) {
    -	response, err := r.clustersClient.Get(ctx, privatev1.ClustersGetRequest_builder{
    -		Id: id,
    -	}.Build())
    -	if err != nil {
    -		return
    -	}
    -	cluster = response.GetObject()
    -	if !cluster.HasSpec() {
    -		cluster.SetSpec(&privatev1.ClusterSpec{})
    -	}
    -	if !cluster.HasStatus() {
    -		cluster.SetStatus(&privatev1.ClusterStatus{})
    -	}
    -	return
    -}
    -
    -func (r *FeedbackReconciler) saveCluster(ctx context.Context, before, after *privatev1.Cluster) error {
    -	if !equal(after, before) {
    -		_, err := r.clustersClient.Update(ctx, privatev1.ClustersUpdateRequest_builder{
    -			Object: after,
    -		}.Build())
    -		if err != nil {
    +			return cluster, nil
    +		},
    +		Save: func(ctx context.Context, remote *privatev1.Cluster) error {
    +			_, err := clustersClient.Update(ctx, privatev1.ClustersUpdateRequest_builder{
    +				Object: remote,
    +			}.Build())
     			return err
    -		}
    +		},
    +		Signal: func(ctx context.Context, id string) error {
    +			_, err := clustersClient.Signal(ctx, privatev1.ClustersSignalRequest_builder{
    +				Id: id,
    +			}.Build())
    +			return err
    +		},
    +		SyncUpdate: newClusterOrderSyncUpdate(hubClient),
    +		SyncDelete: syncClusterOrderDelete,
     	}
    -	return nil
     }
     
    -func (t *feedbackReconcilerTask) handleUpdate(ctx context.Context) error {
    -	if controllerutil.AddFinalizer(t.object, osacClusterOrderFeedbackFinalizer) {
    -		if err := t.r.hubClient.Update(ctx, t.object); err != nil {
    +// newClusterOrderSyncUpdate returns a SyncUpdate function that captures hubClient
    +// for HostedCluster lookups on the Ready phase.
    +func newClusterOrderSyncUpdate(hubClient clnt.Client) func(context.Context, *ckv1alpha1.ClusterOrder, *privatev1.Cluster) error {
    +	return func(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +		syncClusterOrderConditions(ctx, obj, remote)
    +		if err := syncClusterOrderPhase(ctx, hubClient, obj, remote); err != nil {
     			return err
     		}
    +		syncClusterOrderNodeRequests(ctx, obj, remote)
    +		return nil
     	}
    -	return t.syncState(ctx)
    -}
    -
    -func (t *feedbackReconcilerTask) handleDelete(ctx context.Context) error {
    -	if err := t.syncState(ctx); err != nil {
    -		return err
    -	}
    -	return t.syncPhaseDeleting()
     }
     
    -func (t *feedbackReconcilerTask) syncState(ctx context.Context) error {
    -	if err := t.syncConditions(); err != nil {
    -		return err
    -	}
    -	if err := t.syncPhase(ctx); err != nil {
    -		return err
    -	}
    -	if err := t.syncNodeRequests(); err != nil {
    +func syncClusterOrderDelete(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) error {
    +	syncClusterOrderConditions(ctx, obj, remote)
    +	if err := syncClusterOrderPhase(ctx, nil, obj, remote); err != nil {
     		return err
     	}
    +	syncClusterOrderNodeRequests(ctx, obj, remote)
    +	remote.GetStatus().SetState(privatev1.ClusterState_CLUSTER_STATE_DELETING)
     	return nil
     }
     
    -func (t *feedbackReconcilerTask) syncConditions() error {
    -	for _, condition := range t.object.Status.Conditions {
    -		err := t.syncCondition(condition)
    -		if err != nil {
    -			return err
    +func syncClusterOrderConditions(ctx context.Context, obj *ckv1alpha1.ClusterOrder, remote *privatev1.Cluster) {
    +	log := ctrllog.FromContext(ctx)
    +	for _, condition := range obj.Status.Conditions {
    +		switch ckv1alpha1.ClusterOrderConditionType(condition.Type) {
    +		case ckv1alpha1.ClusterOrderConditionAccepted,
    +			ckv1alpha1.ClusterOrderConditionProgressing,
    +			ckv1alpha1.ClusterOrderConditionControlPlaneAvailable,
    +			ckv1alpha1.ClusterOrderConditionAvailable:
    +			syncClusterConditionFromCR(remote, privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING, condition)
    +		default:
    +			log.Info("Unknown condition, will ignore it", "condition", condition.Type)
     		}
     	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncCondition(condition metav1.Condition) error {
    -	switch ckv1alpha1.ClusterOrderConditionType(condition.Type) {
    -	case ckv1alpha1.ClusterOrderConditionAccepted:
    -		return t.syncConditionAccepted(condition)
    -	case ckv1alpha1.ClusterOrderConditionProgressing:
    -		return t.syncConditionProgressing(condition)
    -	case ckv1alpha1.ClusterOrderConditionControlPlaneAvailable:
    -		return t.syncConditionControlPlaneAvailable(condition)
    -	case ckv1alpha1.ClusterOrderConditionAvailable:
    -		return t.syncConditionAvailable(condition)
    -	default:
    -		t.r.logger.Info(
    -			"Unknown condition, will ignore it",
    -			"condition", condition.Type,
    -		)
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncConditionAccepted(condition metav1.Condition) error {
    -	orderCondition := t.findClusterCondition(privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING)
    -	oldStatus := orderCondition.GetStatus()
    -	newStatus := t.mapConditionStatus(condition.Status)
    -	orderCondition.SetStatus(newStatus)
    -	orderCondition.SetMessage(condition.Message)
    -	if newStatus != oldStatus {
    -		orderCondition.SetLastTransitionTime(timestamppb.Now())
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncConditionProgressing(condition metav1.Condition) error {
    -	orderCondition := t.findClusterCondition(privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING)
    -	oldStatus := orderCondition.GetStatus()
    -	newStatus := t.mapConditionStatus(condition.Status)
    -	orderCondition.SetStatus(newStatus)
    -	orderCondition.SetMessage(condition.Message)
    -	if newStatus != oldStatus {
    -		orderCondition.SetLastTransitionTime(timestamppb.Now())
    -	}
    -	return nil
    -}
    -
    -func (t *feedbackReconcilerTask) syncConditionControlPlaneAvailable(condition metav1.Condition) error {
    -	orderCondition := t.findClusterCondition(privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING)
    -	oldStatus := orderCondition.GetStatus()
    -	newStatus := t.mapConditionStatus(condition.Status)
    -	orderCondition.SetStatus(newStatus)
    -	orderCondition.SetMessage(condition.Message)
    -	if newStatus != oldStatus {
    -		orderCondition.SetLastTransitionTime(timestamppb.Now())
    -	}
    -	return nil
     }

    @vladikr, confirmed — the refactor preserves the pre-existing mapping of all four conditions to CLUSTER_CONDITION_TYPE_PROGRESSING; it did not introduce that behavior. I’m withdrawing this PR-scoped finding.

    Would you like me to open a GitHub follow-up issue for evaluating distinct condition mappings?

    <!-- <review_comment_withdrawn> -->

    ---

    <details>
    <summary>✏️ Learnings added</summary>

    Learnt from: vladikr
    Repo: osac-project/osac-operator PR: 402
    File: internal/controller/feedback_controller.go:137-150
    Timestamp: 2026-07-30T03:16:45.179Z
    Learning: In `internal/controller/feedback_controller.go`, all four recognized `ClusterOrder` status conditions historically map to the single fulfillment-service condition type `privatev1.ClusterConditionType_CLUSTER_CONDITION_TYPE_PROGRESSING`. This behavior predates PR `#402`’s feedback bridge migration; do not treat it as a regression introduced by that migration.
    

    Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

    </details>

    <sub>You are interacting with an AI system.</sub>

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

    coderabbitai[bot] coderabbitai[bot] approved these changes on Jul 30, 2026 03:30 UTC
    Approved Reviewer

    Approved these changes.

    vladikr vladikr commented on Jul 30, 2026 03:36 UTC
    Author

    @tzvatot I think this is ready. Only two controllers will be left after this, and there are 2 bugs that i found and will follow up.

    tzvatot tzvatot commented on code on Jul 30, 2026 08:19 UTC
    Code Review
    internal/controller/computeinstance_feedback_controller.go:1
    @@ -71,260 +59,95 @@ func (r *ComputeInstanceFeedbackReconciler) SetupWithManager(mgr mcmanager.Manag
     		Complete(r)
     }
     
    -// Reconcile is the implementation of the reconciler interface.
    -func (r *ComputeInstanceFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error) {
    -	log := ctrllog.FromContext(ctx)
    -
    -	// Step 1: Fetch the CR from the hub cluster.
    -	object := &ckv1alpha1.ComputeInstance{}
    -	err = r.hubClient.Get(ctx, request.NamespacedName, object)
    -	if err != nil {
    -		if !apierrors.IsNotFound(err) {
    -			return result, err
    -		}
    -		// CR is gone. With the finalizer this shouldn't normally happen, but
    -		// handle gracefully (e.g. finalizer was removed externally).
    -		log.Info("CR not found, nothing to do")
    -		err = nil
    -		return result, err
    -	}
    -
    -	// Step 2: Get the compute instance ID from labels. CRs without this label
    -	// weren't created by the fulfillment service, so we ignore them.
    -	ciID, ok := object.Labels[osacComputeInstanceIDLabel]
    -	if !ok {
    -		// If being deleted and somehow has our finalizer, remove it to unblock deletion.
    -		if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -			log.Info("CR without CI ID label is being deleted, removing feedback finalizer")
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    +// Reconcile delegates to the shared feedback Bridge.
    +func (r *ComputeInstanceFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
    +	return r.bridge.Reconcile(ctx, request)
    +}
    +
    +// newComputeInstanceFeedbackBridge creates a Bridge wired to the given client. Exported for testing.
    +func newComputeInstanceFeedbackBridge(hubClient clnt.Client, ciClient privatev1.ComputeInstancesClient) *feedback.Bridge[*ckv1alpha1.ComputeInstance, *privatev1.ComputeInstance] {
    +	return &feedback.Bridge[*ckv1alpha1.ComputeInstance, *privatev1.ComputeInstance]{
    +		Client:    hubClient,
    +		Finalizer: osacComputeInstanceFeedbackFinalizer,
    +		IDLabel:   osacComputeInstanceIDLabel,
    +		Kind:      "ComputeInstance",
    +		IDKey:     "ciID",
    +		NewObject: func() *ckv1alpha1.ComputeInstance { return &ckv1alpha1.ComputeInstance{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.ComputeInstance, error) {
    +			response, err := ciClient.Get(ctx, privatev1.ComputeInstancesGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
     			}
    -			return result, err
    -		}
    -		log.Info(
    -			"There is no label containing the compute instance identifier, will ignore it",
    -			"label", osacComputeInstanceIDLabel,
    -		)
    -		return result, err
    -	}
    -
    -	// Step 3: Fetch the compute instance record from the fulfillment service
    -	// so we can compare before/after and only push changes.
    -	ci, err := r.fetchComputeInstance(ctx, ciID)
    -	if err != nil {
    -		if !object.DeletionTimestamp.IsZero() && status.Code(err) == codes.NotFound {
    -			log.Info("Compute instance record not found during deletion, removing feedback finalizer", "ciID", ciID)
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				return result, r.hubClient.Update(ctx, object)
    +			ci := response.GetObject()
    +			if ci == nil {
    +				return nil, errors.New("compute instance response contained nil object")
     			}
    -			return result, nil
    -		}
    -		return result, err
    -	}
    -
    -	t := &computeInstanceFeedbackReconcilerTask{
    -		r:      r,
    -		object: object,
    -		ci:     clone(ci),
    -	}
    -
    -	// Step 4: Sync CR state to the fulfillment service record.
    -	// handleUpdate also adds our finalizer; handleDelete only syncs state
    -	// (e.g. DELETING phase).
    -	if object.DeletionTimestamp.IsZero() {
    -		err = t.handleUpdate(ctx)
    -	} else {
    -		t.handleDelete(ctx)
    -	}
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 5: Persist synced state to the fulfillment service.
    -	err = r.saveComputeInstance(ctx, ci, t.ci)
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 6: Handle finalizer removal and signal for deletions. This must
    -	// happen after step 5 so the DELETING state is persisted before the CR
    -	// is garbage collected.
    -	if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -		if len(object.GetFinalizers()) == 1 {
    -			// We're the last finalizer. Remove it to trigger CR garbage
    -			// collection, then signal the fulfillment service to immediately
    -			// re-reconcile. Finalizer is removed first so the CR is gone
    -			// before the fulfillment controller checks — avoiding a race
    -			// where it sees the CR still exists and skips archival.
    -			log.Info(
    -				"Feedback finalizer is last remaining, removing finalizer and signaling",
    -				"ciID", ciID,
    -			)
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    -				if err != nil {
    -					return result, err
    -				}
    +			if !ci.HasSpec() {
    +				ci.SetSpec(&privatev1.ComputeInstanceSpec{})
     			}
    -			_, signalErr := r.computeInstancesClient.Signal(ctx, privatev1.ComputeInstancesSignalRequest_builder{
    -				Id: ciID,
    -			}.Build())
    -			if signalErr != nil {
    -				log.Error(
    -					signalErr,
    -					"Failed to signal fulfillment service, periodic sync will handle cleanup",
    -					"ciID", ciID,
    -				)
    +			if !ci.HasStatus() {
    +				ci.SetStatus(&privatev1.ComputeInstanceStatus{})
     			}
    -		} else {
    -			// Other finalizers still present — another controller hasn't
    -			// finished cleanup yet. When it removes its finalizer, the
    -			// Update event will trigger a new reconcile.
    -			log.Info(
    -				"Other finalizers still present, waiting",
    -				"finalizers", object.GetFinalizers(),
    -			)
    -		}
    -	}
    -
    -	return result, err
    -}
    -
    -// fetchComputeInstance retrieves a compute instance record from the fulfillment
    -// service by its ID, ensuring spec and status are initialized.
    -func (r *ComputeInstanceFeedbackReconciler) fetchComputeInstance(ctx context.Context, id string) (vm *privatev1.ComputeInstance, err error) {
    -	response, err := r.computeInstancesClient.Get(ctx, privatev1.ComputeInstancesGetRequest_builder{
    -		Id: id,
    -	}.Build())
    -	if err != nil {
    -		return
    -	}
    -	vm = response.GetObject()
    -	if !vm.HasSpec() {
    -		vm.SetSpec(&privatev1.ComputeInstanceSpec{})
    -	}
    -	if !vm.HasStatus() {
    -		vm.SetStatus(&privatev1.ComputeInstanceStatus{})
    -	}
    -	return
    -}
    -
    -// saveComputeInstance sends an update to the fulfillment service if the compute
    -// instance record has changed.
    -func (r *ComputeInstanceFeedbackReconciler) saveComputeInstance(ctx context.Context, before, after *privatev1.ComputeInstance) error {
    -	log := ctrllog.FromContext(ctx)
    -
    -	if !equal(after, before) {
    -		log.Info(
    -			"Updating compute instance",
    -			"before", before,
    -			"after", after,
    -		)
    -		_, err := r.computeInstancesClient.Update(ctx, privatev1.ComputeInstancesUpdateRequest_builder{
    -			Object: after,
    -		}.Build())
    -		if err != nil {
    +			return ci, nil
    +		},
    +		Save: func(ctx context.Context, remote *privatev1.ComputeInstance) error {
    +			_, err := ciClient.Update(ctx, privatev1.ComputeInstancesUpdateRequest_builder{
    +				Object: remote,
    +			}.Build())
     			return err
    -		}
    -	}
    -	return nil
    -}
    -
    -// handleUpdate ensures our finalizer is present and syncs the CR state to the
    -// fulfillment service. Called when the CR is not being deleted.
    -func (t *computeInstanceFeedbackReconcilerTask) handleUpdate(ctx context.Context) error {
    -	if controllerutil.AddFinalizer(t.object, osacComputeInstanceFeedbackFinalizer) {
    -		if err := t.r.hubClient.Update(ctx, t.object); err != nil {
    +		},
    +		Signal: func(ctx context.Context, id string) error {
    +			_, err := ciClient.Signal(ctx, privatev1.ComputeInstancesSignalRequest_builder{
    +				Id: id,
    +			}.Build())
     			return err
    -		}
    +		},
    +		SyncUpdate: syncComputeInstanceUpdate,
    +		SyncDelete: syncComputeInstanceDelete,
     	}
    -	t.syncState(ctx)
    -	return nil
    -}
    -
    -// handleDelete syncs the CR state (including the DELETING phase) to the
    -// fulfillment service. Called when the CR is being deleted.
    -func (t *computeInstanceFeedbackReconcilerTask) handleDelete(ctx context.Context) {
    -	t.syncState(ctx)
    -}
    -
    -// syncState synchronizes the CR's conditions, phase, IP addresses, and last
    -// restarted time to the fulfillment service's compute instance record.
    -func (t *computeInstanceFeedbackReconcilerTask) syncState(ctx context.Context) {
    -	t.syncConditions(ctx)
    -	t.syncPhase(ctx)
    -	t.syncIPAddresses()
    -	t.syncLastRestartedAt()
    -}
    -
    -func (t *computeInstanceFeedbackReconcilerTask) syncConditions(ctx context.Context) {
    -	t.syncConfigurationApplied(ctx)
    -	t.syncReady(ctx)
    -	t.syncRestartInProgress(ctx)
    -	t.syncRestartFailed(ctx)
    -	t.syncProvisioned(ctx)
    -	t.syncRestartRequired(ctx)
     }
     
    -// syncConfigurationApplied synchronizes the CONFIGURATION_APPLIED VM condition from the ConfigurationApplied CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncConfigurationApplied(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionConfigurationApplied)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_CONFIGURATION_APPLIED, crCondition)
    -}
    -
    -// syncReady synchronizes the READY VM condition from the Ready CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncReady(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionReady)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_READY, crCondition)
    -}
    -
    -// syncRestartInProgress synchronizes the RESTART_IN_PROGRESS VM condition from the RestartInProgress CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncRestartInProgress(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionRestartInProgress)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_RESTART_IN_PROGRESS, crCondition)
    -}
    -
    -// syncRestartFailed synchronizes the RESTART_FAILED VM condition from the RestartFailed CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncRestartFailed(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionRestartFailed)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_RESTART_FAILED, crCondition)
    +func syncComputeInstanceUpdate(ctx context.Context, obj *ckv1alpha1.ComputeInstance, remote *privatev1.ComputeInstance) error {
    +	syncCIConditions(obj, remote)
    +	syncCIPhase(ctx, obj, remote)
    +	syncCIIPAddresses(obj, remote)
    +	syncCILastRestartedAt(obj, remote)
    +	return nil
     }
     
    -// syncProvisioned synchronizes the PROVISIONED VM condition from the Provisioned CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncProvisioned(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionProvisioned)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_PROVISIONED, crCondition)
    +func syncComputeInstanceDelete(ctx context.Context, obj *ckv1alpha1.ComputeInstance, remote *privatev1.ComputeInstance) error {
    +	syncCIConditions(obj, remote)
    +	syncCIPhase(ctx, obj, remote)
    +	syncCIIPAddresses(obj, remote)
    +	syncCILastRestartedAt(obj, remote)
    +	return nil
     }

    syncComputeInstanceUpdate and syncComputeInstanceDelete have identical bodies. Unlike the ClusterOrder controller (where delete forces DELETING and skips URL sync), these two genuinely do the same thing.

    Use a single function for both:

    SyncUpdate: syncComputeInstanceSync,
    SyncDelete: syncComputeInstanceSync,
    

    If the delete path needs to diverge later (e.g., to force DELETING like ClusterOrder does), add a separate function at that point.

    tzvatot tzvatot requested changes on Jul 30, 2026 08:19 UTC
    Changes Requested Reviewer

    Requested changes.

    vladikr vladikr commented on code on Jul 30, 2026 10:33 UTC
    Code Review
    internal/controller/computeinstance_feedback_controller.go:1
    @@ -71,260 +59,95 @@ func (r *ComputeInstanceFeedbackReconciler) SetupWithManager(mgr mcmanager.Manag
     		Complete(r)
     }
     
    -// Reconcile is the implementation of the reconciler interface.
    -func (r *ComputeInstanceFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (result ctrl.Result, err error) {
    -	log := ctrllog.FromContext(ctx)
    -
    -	// Step 1: Fetch the CR from the hub cluster.
    -	object := &ckv1alpha1.ComputeInstance{}
    -	err = r.hubClient.Get(ctx, request.NamespacedName, object)
    -	if err != nil {
    -		if !apierrors.IsNotFound(err) {
    -			return result, err
    -		}
    -		// CR is gone. With the finalizer this shouldn't normally happen, but
    -		// handle gracefully (e.g. finalizer was removed externally).
    -		log.Info("CR not found, nothing to do")
    -		err = nil
    -		return result, err
    -	}
    -
    -	// Step 2: Get the compute instance ID from labels. CRs without this label
    -	// weren't created by the fulfillment service, so we ignore them.
    -	ciID, ok := object.Labels[osacComputeInstanceIDLabel]
    -	if !ok {
    -		// If being deleted and somehow has our finalizer, remove it to unblock deletion.
    -		if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -			log.Info("CR without CI ID label is being deleted, removing feedback finalizer")
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    +// Reconcile delegates to the shared feedback Bridge.
    +func (r *ComputeInstanceFeedbackReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
    +	return r.bridge.Reconcile(ctx, request)
    +}
    +
    +// newComputeInstanceFeedbackBridge creates a Bridge wired to the given client. Exported for testing.
    +func newComputeInstanceFeedbackBridge(hubClient clnt.Client, ciClient privatev1.ComputeInstancesClient) *feedback.Bridge[*ckv1alpha1.ComputeInstance, *privatev1.ComputeInstance] {
    +	return &feedback.Bridge[*ckv1alpha1.ComputeInstance, *privatev1.ComputeInstance]{
    +		Client:    hubClient,
    +		Finalizer: osacComputeInstanceFeedbackFinalizer,
    +		IDLabel:   osacComputeInstanceIDLabel,
    +		Kind:      "ComputeInstance",
    +		IDKey:     "ciID",
    +		NewObject: func() *ckv1alpha1.ComputeInstance { return &ckv1alpha1.ComputeInstance{} },
    +		Fetch: func(ctx context.Context, id string) (*privatev1.ComputeInstance, error) {
    +			response, err := ciClient.Get(ctx, privatev1.ComputeInstancesGetRequest_builder{Id: id}.Build())
    +			if err != nil {
    +				return nil, err
     			}
    -			return result, err
    -		}
    -		log.Info(
    -			"There is no label containing the compute instance identifier, will ignore it",
    -			"label", osacComputeInstanceIDLabel,
    -		)
    -		return result, err
    -	}
    -
    -	// Step 3: Fetch the compute instance record from the fulfillment service
    -	// so we can compare before/after and only push changes.
    -	ci, err := r.fetchComputeInstance(ctx, ciID)
    -	if err != nil {
    -		if !object.DeletionTimestamp.IsZero() && status.Code(err) == codes.NotFound {
    -			log.Info("Compute instance record not found during deletion, removing feedback finalizer", "ciID", ciID)
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				return result, r.hubClient.Update(ctx, object)
    +			ci := response.GetObject()
    +			if ci == nil {
    +				return nil, errors.New("compute instance response contained nil object")
     			}
    -			return result, nil
    -		}
    -		return result, err
    -	}
    -
    -	t := &computeInstanceFeedbackReconcilerTask{
    -		r:      r,
    -		object: object,
    -		ci:     clone(ci),
    -	}
    -
    -	// Step 4: Sync CR state to the fulfillment service record.
    -	// handleUpdate also adds our finalizer; handleDelete only syncs state
    -	// (e.g. DELETING phase).
    -	if object.DeletionTimestamp.IsZero() {
    -		err = t.handleUpdate(ctx)
    -	} else {
    -		t.handleDelete(ctx)
    -	}
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 5: Persist synced state to the fulfillment service.
    -	err = r.saveComputeInstance(ctx, ci, t.ci)
    -	if err != nil {
    -		return result, err
    -	}
    -
    -	// Step 6: Handle finalizer removal and signal for deletions. This must
    -	// happen after step 5 so the DELETING state is persisted before the CR
    -	// is garbage collected.
    -	if !object.DeletionTimestamp.IsZero() && controllerutil.ContainsFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -		if len(object.GetFinalizers()) == 1 {
    -			// We're the last finalizer. Remove it to trigger CR garbage
    -			// collection, then signal the fulfillment service to immediately
    -			// re-reconcile. Finalizer is removed first so the CR is gone
    -			// before the fulfillment controller checks — avoiding a race
    -			// where it sees the CR still exists and skips archival.
    -			log.Info(
    -				"Feedback finalizer is last remaining, removing finalizer and signaling",
    -				"ciID", ciID,
    -			)
    -			if controllerutil.RemoveFinalizer(object, osacComputeInstanceFeedbackFinalizer) {
    -				err = r.hubClient.Update(ctx, object)
    -				if err != nil {
    -					return result, err
    -				}
    +			if !ci.HasSpec() {
    +				ci.SetSpec(&privatev1.ComputeInstanceSpec{})
     			}
    -			_, signalErr := r.computeInstancesClient.Signal(ctx, privatev1.ComputeInstancesSignalRequest_builder{
    -				Id: ciID,
    -			}.Build())
    -			if signalErr != nil {
    -				log.Error(
    -					signalErr,
    -					"Failed to signal fulfillment service, periodic sync will handle cleanup",
    -					"ciID", ciID,
    -				)
    +			if !ci.HasStatus() {
    +				ci.SetStatus(&privatev1.ComputeInstanceStatus{})
     			}
    -		} else {
    -			// Other finalizers still present — another controller hasn't
    -			// finished cleanup yet. When it removes its finalizer, the
    -			// Update event will trigger a new reconcile.
    -			log.Info(
    -				"Other finalizers still present, waiting",
    -				"finalizers", object.GetFinalizers(),
    -			)
    -		}
    -	}
    -
    -	return result, err
    -}
    -
    -// fetchComputeInstance retrieves a compute instance record from the fulfillment
    -// service by its ID, ensuring spec and status are initialized.
    -func (r *ComputeInstanceFeedbackReconciler) fetchComputeInstance(ctx context.Context, id string) (vm *privatev1.ComputeInstance, err error) {
    -	response, err := r.computeInstancesClient.Get(ctx, privatev1.ComputeInstancesGetRequest_builder{
    -		Id: id,
    -	}.Build())
    -	if err != nil {
    -		return
    -	}
    -	vm = response.GetObject()
    -	if !vm.HasSpec() {
    -		vm.SetSpec(&privatev1.ComputeInstanceSpec{})
    -	}
    -	if !vm.HasStatus() {
    -		vm.SetStatus(&privatev1.ComputeInstanceStatus{})
    -	}
    -	return
    -}
    -
    -// saveComputeInstance sends an update to the fulfillment service if the compute
    -// instance record has changed.
    -func (r *ComputeInstanceFeedbackReconciler) saveComputeInstance(ctx context.Context, before, after *privatev1.ComputeInstance) error {
    -	log := ctrllog.FromContext(ctx)
    -
    -	if !equal(after, before) {
    -		log.Info(
    -			"Updating compute instance",
    -			"before", before,
    -			"after", after,
    -		)
    -		_, err := r.computeInstancesClient.Update(ctx, privatev1.ComputeInstancesUpdateRequest_builder{
    -			Object: after,
    -		}.Build())
    -		if err != nil {
    +			return ci, nil
    +		},
    +		Save: func(ctx context.Context, remote *privatev1.ComputeInstance) error {
    +			_, err := ciClient.Update(ctx, privatev1.ComputeInstancesUpdateRequest_builder{
    +				Object: remote,
    +			}.Build())
     			return err
    -		}
    -	}
    -	return nil
    -}
    -
    -// handleUpdate ensures our finalizer is present and syncs the CR state to the
    -// fulfillment service. Called when the CR is not being deleted.
    -func (t *computeInstanceFeedbackReconcilerTask) handleUpdate(ctx context.Context) error {
    -	if controllerutil.AddFinalizer(t.object, osacComputeInstanceFeedbackFinalizer) {
    -		if err := t.r.hubClient.Update(ctx, t.object); err != nil {
    +		},
    +		Signal: func(ctx context.Context, id string) error {
    +			_, err := ciClient.Signal(ctx, privatev1.ComputeInstancesSignalRequest_builder{
    +				Id: id,
    +			}.Build())
     			return err
    -		}
    +		},
    +		SyncUpdate: syncComputeInstanceUpdate,
    +		SyncDelete: syncComputeInstanceDelete,
     	}
    -	t.syncState(ctx)
    -	return nil
    -}
    -
    -// handleDelete syncs the CR state (including the DELETING phase) to the
    -// fulfillment service. Called when the CR is being deleted.
    -func (t *computeInstanceFeedbackReconcilerTask) handleDelete(ctx context.Context) {
    -	t.syncState(ctx)
    -}
    -
    -// syncState synchronizes the CR's conditions, phase, IP addresses, and last
    -// restarted time to the fulfillment service's compute instance record.
    -func (t *computeInstanceFeedbackReconcilerTask) syncState(ctx context.Context) {
    -	t.syncConditions(ctx)
    -	t.syncPhase(ctx)
    -	t.syncIPAddresses()
    -	t.syncLastRestartedAt()
    -}
    -
    -func (t *computeInstanceFeedbackReconcilerTask) syncConditions(ctx context.Context) {
    -	t.syncConfigurationApplied(ctx)
    -	t.syncReady(ctx)
    -	t.syncRestartInProgress(ctx)
    -	t.syncRestartFailed(ctx)
    -	t.syncProvisioned(ctx)
    -	t.syncRestartRequired(ctx)
     }
     
    -// syncConfigurationApplied synchronizes the CONFIGURATION_APPLIED VM condition from the ConfigurationApplied CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncConfigurationApplied(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionConfigurationApplied)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_CONFIGURATION_APPLIED, crCondition)
    -}
    -
    -// syncReady synchronizes the READY VM condition from the Ready CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncReady(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionReady)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_READY, crCondition)
    -}
    -
    -// syncRestartInProgress synchronizes the RESTART_IN_PROGRESS VM condition from the RestartInProgress CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncRestartInProgress(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionRestartInProgress)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_RESTART_IN_PROGRESS, crCondition)
    -}
    -
    -// syncRestartFailed synchronizes the RESTART_FAILED VM condition from the RestartFailed CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncRestartFailed(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionRestartFailed)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_RESTART_FAILED, crCondition)
    +func syncComputeInstanceUpdate(ctx context.Context, obj *ckv1alpha1.ComputeInstance, remote *privatev1.ComputeInstance) error {
    +	syncCIConditions(obj, remote)
    +	syncCIPhase(ctx, obj, remote)
    +	syncCIIPAddresses(obj, remote)
    +	syncCILastRestartedAt(obj, remote)
    +	return nil
     }
     
    -// syncProvisioned synchronizes the PROVISIONED VM condition from the Provisioned CR condition.
    -func (t *computeInstanceFeedbackReconcilerTask) syncProvisioned(ctx context.Context) {
    -	crCondition := t.object.GetStatusCondition(ckv1alpha1.ComputeInstanceConditionProvisioned)
    -	if crCondition == nil {
    -		return
    -	}
    -	t.syncVMConditionFromCR(privatev1.ComputeInstanceConditionType_COMPUTE_INSTANCE_CONDITION_TYPE_PROVISIONED, crCondition)
    +func syncComputeInstanceDelete(ctx context.Context, obj *ckv1alpha1.ComputeInstance, remote *privatev1.ComputeInstance) error {
    +	syncCIConditions(obj, remote)
    +	syncCIPhase(ctx, obj, remote)
    +	syncCIIPAddresses(obj, remote)
    +	syncCILastRestartedAt(obj, remote)
    +	return nil
     }

    yes, good point. I thought to preserve the structure.
    ok, I'll upidate :)

    vladikr vladikr commented on Jul 30, 2026 13:19 UTC
    Author

    @tzvatot done, can you please take a look again? :)

    tzvatot tzvatot approved these changes on Jul 30, 2026 13:29 UTC
    Approved Reviewer

    Previous finding (identical syncComputeInstanceUpdate/syncComputeInstanceDelete) is fixed.

    /lgtm
    /approve

    openshift-ci[bot] openshift-ci[bot] commented on Jul 30, 2026 13:29 UTC
    Bot

    [APPROVALNOTIFIER] This PR is APPROVED

    This pull-request has been approved by: <a href="https://github.com/osac-project/osac-operator/pull/402#pullrequestreview-4819260841" title="Approved">tzvatot</a>, <a href="https://github.com/osac-project/osac-operator/pull/402#" 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: 76.3% 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: 77% (HIGH) · Higher = larger blast radius
    77%
    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: 76.3% · Lower = rushed or shallow review
    76.3%
    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: 18.2% · Safe to merge
    18.2%