Skip to content

alloydb: fix labels and initial_user takeover diffs in AlloyDBCluster direct controller - #13963

Merged
anhdle-sso merged 5 commits into
GoogleCloudPlatform:masterfrom
anhdle-sso:alloydbcluster-fix
Oct 16, 2026
Merged

anhdle-sso merged 5 commits into
GoogleCloudPlatform:masterfrom
anhdle-sso:alloydbcluster-fix

Conversation

@anhdle-sso

Copy link
Copy Markdown
Collaborator

Description

This PR addresses false-positive diffs (labels, initialUser, and network) observed during takeover and re-reconciliation in the AlloyDBCluster direct controller.

This replaces and supersedes #13619, rebased onto current master with review feedback addressed.

Changes

  • Controller Logic:
    • Differentiated buildDesiredForCreate (applies defaults to pure copy) vs buildDesiredForUpdate (uses common.MergeUnsetFields to adopt live GCP state for unset fields instead of overwriting with defaults).
    • Eliminated resolveGCPDefaults to send minimal AIP-134 field masks.
    • Used common.CompareBrownfieldSpecAndLabels and label.GCPLabels(u) for brownfield label comparison, preventing system label drift.
    • Handled write-only initialUser via mutable-but-unreadable annotation pattern (pkg/k8s/mutableunreadable.go).
    • Used computerefs.CanonicalizeNetworkValue during normalization to avoid false diffs between project ID and project number formats for network / networkConfig.network.
  • References:
    • Exported computerefs.CanonicalizeNetworkValue for use in controller normalization callbacks.
  • Normalizers & Golden Files:
    • Added URL filter guard and normalized serviceAccountEmail, dataplexConfig, and database version formatting.
    • Added label test coverage to basicalloydbcluster (create.yaml & update.yaml) and updated golden logs.

Testing

  • ./dev/ci/presubmits/tests-e2e-fixtures-suite alloydb (22/22 PASS)
  • ./dev/ci/presubmits/tests-e2e-fixtures-suite networkconnectivity (12/12 PASS)
  • Unit tests: pkg/controller/direct/alloydb, apis/compute/refs, golden_alignment_test.go all pass.

Fixes #13579

Fix false-positive diffs on labels, initialUser, and network for AlloyDBCluster.

@anhdle-sso
anhdle-sso requested a review from gemmahou October 13, 2026 22:07
… direct controller

- Differentiate Create vs Update in buildDesired, adopting live GCP state for unset fields on update
- Handle write-only initialUser using mutable-but-unreadable annotation pattern
- Canonicalize network reference in normalize callback to prevent project number vs ID diffs
- Eliminate resolveGCPDefaults to send minimal AIP-134 field masks
- Add label coverage in basicalloydbcluster test fixture and align golden logs

Fixes GoogleCloudPlatform#13579
Normalize .ipAddress and .response.ipAddress to 10.1.2.3 for networkconnectivity
services, resolving diff failures in regionalendpoint tests caused by scoping
mockalloydb normalizers.

```release-note
NONE
```
@google-oss-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gemmahou
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

@anhdle-sso
anhdle-sso added this pull request to the merge queue Oct 15, 2026
Merged via the queue into GoogleCloudPlatform:master with commit 9aeb98b Oct 16, 2026
254 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AlloyDBCluster: Fix labels and initial_user diff discrepancies between tf and direct controllers

2 participants

⌂ 换网址