Skip to content

ComputeRoute: Fix network and next_hop_gateway diff discrepancies between tf and direct controllers - #13631

Open
ada-coder-bot wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
ada-coder-bot:issue-13581-1790891692
Open

ada-coder-bot wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
ada-coder-bot:issue-13581-1790891692

Conversation

@ada-coder-bot

Copy link
Copy Markdown
Collaborator

Description

This PR fixes diff discrepancies between the tf (Terraform) and direct controllers for ComputeRoute (compute.cnrm.cloud.google.com/v1beta1).

Root Cause

During reconciliation and direct takeover, compareComputeRoute directly compared proto fields without normalizing URL prefixes or canonicalizing relative vs. short-name gateway and network references:

  1. network: GCP API returns a full URL (https://www.googleapis.com/compute/v1/projects/...), whereas normalized KRM references use relative resource paths (projects/...).
  2. next_hop_gateway: GCP API returns a full URL (https://.../global/gateways/default-internet-gateway), whereas KRM spec may specify default-internet-gateway or global/gateways/default-internet-gateway.
    Because ComputeRoute is immutable in GCP, these field diffs caused false updates that failed reconciliation.

Summary of Changes

  • Controller Normalization:
    • Implemented canonicalizeComputeNetwork and canonicalizeNextHopGateway helpers in pkg/controller/direct/compute/computeroute_controller.go to normalize URL prefixes and short names to canonical relative paths before comparison.
    • Applied canonicalizeComputeURL to NextHopIlb, NextHopInstance, and NextHopVpnTunnel.
    • Passed ComputeRouteIdentity into compareComputeRoute to resolve project ID context for short-name expansion.
  • MockGCP Alignment:
    • Updated mockgcp/mockcompute/routesv1.go to normalize NextHopGateway to full selfLink on insert, matching real GCP API behavior.
  • Unit & E2E Testing:
    • Added unit test suite TestCompareComputeRoute in pkg/controller/direct/compute/computeroute_controller_test.go covering full URLs, relative paths, short names, priority defaults, and true diff detection.
    • Added computeroutegateway E2E test fixture and recorded clean migration golden outputs with zero diffs in _migration_diffs.json.

Fixes #13581

NONE

This PR was generated by the overseer,priority/high agent (powered by the gemini-3.7-flash model).

@google-oss-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign maqiuyujoyce for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@argus-watcher-bot

Copy link
Copy Markdown
Collaborator

🤖 AI Factory started investigating CI check failures for this pull request.

Note: We recommend waiting for the 'ready-for-human' label before leaving review comments. Comments added while the system is actively working may be associated with outdated commits once a new commit is pushed, causing them to be ignored.

Canonicalize network and next_hop_gateway URL prefixes, schemes, and
short-name representations in compareComputeRoute to eliminate diff
discrepancies between the Terraform and direct controllers.

Issue: 13581
@ada-coder-bot
ada-coder-bot force-pushed the issue-13581-1790891692 branch from 73ef20b to e22a914 Compare October 2, 2026 02:53
@ada-coder-bot

Copy link
Copy Markdown
Collaborator Author

Investigating unit-tests-2-of-4 failure

Run: 36949117538
Name: unit-tests-2-of-4
Cause: Test Failure
Details: TestCRDFieldPresenceInTests in tests/apichecks failed because the newly added computeroutegateway test fixture covers .spec.nextHopGateway, rendering the entry in tests/apichecks/testdata/exceptions/missingfields.txt obsolete.
Action Taken: Removed the obsolete .spec.nextHopGateway exception entry in tests/apichecks/testdata/exceptions/missingfields.txt and verified that tests/apichecks passes.

Investigating tests-e2e-fixtures-compute failure

Run: 36949117538
Name: tests-e2e-fixtures-compute-1-of-4, tests-e2e-fixtures-compute-2-of-4, tests-e2e-fixtures-compute-3-of-4, tests-e2e-fixtures-compute-4-of-4
Cause: Test Failure
Details: The catch-all validation in the compute fixture test suite failed across all shards because the newly added fixture pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeroute/computeroutegateway was not listed in tests/e2e/testdata/fixtures-compute-list.txt.
Action Taken: Added pkg/test/resourcefixture/testdata/basic/compute/v1beta1/computeroute/computeroutegateway to tests/e2e/testdata/fixtures-compute-list.txt, amended the commit, and pushed the updated branch.

(This report was generated by overseer)

@argus-watcher-bot

Copy link
Copy Markdown
Collaborator

🤖 AI Factory started investigating CI check failures for this pull request.

Note: We recommend waiting for the 'ready-for-human' label before leaving review comments. Comments added while the system is actively working may be associated with outdated commits once a new commit is pushed, causing them to be ignored.

2 similar comments
@argus-watcher-bot

Copy link
Copy Markdown
Collaborator

🤖 AI Factory started investigating CI check failures for this pull request.

Note: We recommend waiting for the 'ready-for-human' label before leaving review comments. Comments added while the system is actively working may be associated with outdated commits once a new commit is pushed, causing them to be ignored.

@argus-watcher-bot

Copy link
Copy Markdown
Collaborator

🤖 AI Factory started investigating CI check failures for this pull request.

Note: We recommend waiting for the 'ready-for-human' label before leaving review comments. Comments added while the system is actively working may be associated with outdated commits once a new commit is pushed, causing them to be ignored.

@argus-watcher-bot

Copy link
Copy Markdown
Collaborator

🤖 AI Factory has attempted to investigate/fix CI check failures for this pull request 3 times since the last commit or update without success. To prevent infinite loops, I am pausing automated investigation and attaching the overseer/stop label.

To request another attempt or resume automated processing, please remove the overseer/stop label from this pull request (and/or push a new commit or leave a comment).

This branch has not been deployed

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