← Back to Pull requests

Fix BigQueryDataTransferConfig resource duplication loop #7228

Closed
unknown closed this pull request without merging on Apr 30, 2026 22:28 UTC
View on GitHub
unknown unknown commented on Mar 27, 2026 12:21 UTC
Author

Ensures externalRef is preserved in BigQueryDataTransferConfig status updates, preventing a "permanent amnesia" loop that leads to multiple duplicate scheduled queries in GCP.

BRIEF Change description

This PR fixes a bug where BigQueryDataTransferConfig reconciliation fails to persist the link to the underlying GCP resource, leading to the creation of multiple duplicate scheduled queries.

The issue occurs because the setStatus helper function unconditionally overwrites the newly generated externalRef (from a successful Create call) with the potentially empty externalRef from the old Kubernetes object status. Since BigQueryDataTransferConfig uses service-generated IDs, the loss of this reference causes KCC to lose track of the resource, leading it to create a new instance on every subsequent reconciliation loop.

Fixes # (Internal Bug b/493812753)

WHY do we need this change?

1. Identity Loss: BigQueryDataTransferConfig relies entirely on status.externalRef to identify the existing resource in GCP. If this field is lost, KCC's Find() method returns false, and the controller concludes the resource does not exist.
2. Duplication Loop: When a resource is successfully created but the externalRef is immediately wiped from the status, KCC enters a state of "permanent amnesia." On the next sync (which is triggered immediately by the status update), KCC calls Create() again, resulting in an infinite loop of duplicate resources in GCP.
3. Dependency Sensitivity: This behavior is particularly triggered when dependencies (like Service Accounts or Datasets) are temporarily unhealthy, as the error-reporting path for those failures initializes an empty status that then "infects" the successful creation path via unconditional inheritance.
4. Orphaned objects: On the parent CR deletion, the corresponding GCP objects won't be deleted due to the lost link between the CR and the GCP resource.

Special notes for your reviewer:

The fix is surgical and targeted at the setStatus function in the BigQueryDataTransferConfig direct reconciler.

Does this PR add something which needs to be 'release noted'?

``release-note
Fixed a bug in BigQueryDataTransferConfig where the link to the GCP resource (externalRef) could be lost during status updates, causing KCC to create multiple duplicate scheduled queries in GCP.


- [ ] Reviewer reviewed release note.

#### Additional documentation e.g., references, usage docs, etc.:

docs
NONE
`

Intended Milestone

  • Reviewer tagged PR with the actual milestone.
  • Tests you have done

  • Verified the fix in a live cluster using custom container images (with the fix).

  • Confirmed that externalRef` is correctly persisted and duplication stops after the first successful reconciliation.

  • Verified that unhealthy dependency states (missing SA/Dataset) no longer trigger a duplication loop once the dependencies become healthy.
  • Diff: 378 lines (+283 / -95) across 4 files Reviewer: himanigulati01 Review duration: 49567m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.66) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 378 lines diff across 4 files
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.355
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #7228"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 66.1% (HIGH) · Higher = larger blast radius
    66.1%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 26.1% · Safe to merge
    26.1%