8000 refactor(bridge): move conditions and spec parsing out of reconciler.go by VLukiantsev · Pull Request #1009 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

refactor(bridge): move conditions and spec parsing out of reconciler.go - #1009

Merged
VLukiantsev merged 1 commit into
mainfrom
refactor/bridge-split-conditions-parser
Oct 2, 2026
Merged

VLukiantsev merged 1 commit into
mainfrom
refactor/bridge-split-conditions-parser

Conversation

@VLukiantsev
@VLukiantsev VLukiantsev commented Sep 28, 2026 •
Copy link
Copy Markdown
Collaborator

Summary

Part 1/4 of a pure-move stack splitting pkg/components/bridge/reconciler.go (1492 lines) by responsibility. This PR moves Kubernetes status-condition helpers into conditions.go and CR spec parsing into spec_parser.go, along with their tests. There are no behaviour, API or naming changes.

Motivation & Context

reconciler.go mixes condition bookkeeping, spec parsing, the CMS transport, probing, 3P wrapper reconciliation and deletion/deactivation lifecycle. The #992 review agreed on a file layout and left a TODO at the top of the file. This stack applies that layout, plus cms_client.go and bridge_prober.go so that each file holds one type or concern. Each PR is a mechanical move so it can be reviewed with --color-moved.

Review with: git diff --color-moved=dimmed-zebra origin/main...origin/refactor/bridge-split-conditions-parser

Key Changes

  • conditions.go: ConditionType*/ConditionStatus*/health Reason* constants, Condition, findCondition (moved from dependency_readiness.go), setCondition, upsertCondition, healthConditionStatuses, defaultCMSHeartbeatInterval, shouldSyncToCMS, resetReadyTransitionTime.
  • spec_parser.go: ParseSpecFromUnstructured, ParseConditionsFromUnstructured, ParseWrapperRef, and the parse*/extract* helpers.
  • Tests moved 1:1 into conditions_test.go and spec_parser_test.go. BUILD.bazel srcs updated.

Assumptions

  • findCondition moved from dependency_readiness.go to conditions.go because it's a condition helper. It's the only symbol moved from outside reconciler.go — impact if wrong: a one-line move back.
  • gofmt re-aligned 3 constants after their neighbours moved. These are whitespace-only diffs.
  • This layer is slightly over the size gate (444 prod / 1014 total lines, all moved code) — see the note on the stack.

Verification & Testing

  • Commands Executed: bazel test //pkg/components/bridge:bridge_test, bazel build //pkg/components/... //cmd/xmc_bridge/..., ./.githooks/pre-commit
  • Coverage & Test Status: all tests pass. The top-level test count is unchanged (106) and the test bodies are unchanged, so coverage is the same. A sorted line diff of added vs. deleted lines shows only license/package/import boilerplate and gofmt alignment.

Related Issues / Bugs

Follow-up to the #992 review.

TAG=agy
CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399

reconciler.go had grown to ~1,500 lines and mixed several responsibilities
(see the #992 review). This is the first layer of a pure-move
split with no behavior or public API changes:

- conditions.go: condition types/statuses, health reasons, Condition,
  findCondition (from dependency_readiness.go), setCondition,
  upsertCondition, healthConditionStatuses, and the CMS heartbeat
  throttling (shouldSyncToCMS, resetReadyTransitionTime).
- spec_parser.go: unstructured spec/status decoding
  (ParseSpecFromUnstructured, ParseConditionsFromUnstructured,
  ParseWrapperRef, parameter/manifest/enum parsers, extract* accessors).
- Matching unit tests moved 1:1 into conditions_test.go and
  spec_parser_test.go; top-level test count is unchanged (106).

Review with: git diff --color-moved=dimmed-zebra

TAG=agy
CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399
@VLukiantsev
VLukiantsev added this pull request to stack #1013 September 28, 2026 16:01
@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the bridge package by extracting condition-related logic and spec parsing helpers from reconciler.go and dependency_readiness.go into dedicated files: conditions.go and spec_parser.go, along with their respective unit tests. Feedback is provided regarding the parsing of Kubernetes condition timestamps in spec_parser.go, where using time.RFC3339 instead of time.RFC3339Nano can lead to silent parsing failures when fractional seconds are present, potentially causing write amplification to CMS and Cloud Spanner.

Comment thread pkg/components/bridge/spec_parser.go Resolved
@VLukiantsev
VLukiantsev added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit a3db02a Oct 2, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority::2-high top of mind. should not wait.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0