8000 refactor(bridge): move actuation state tracking out of helm_manager.go by VLukiantsev · Pull Request #1070 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

refactor(bridge): move actuation state tracking out of helm_manager.go - #1070

Merged
VLukiantsev merged 3 commits into
refactor/helm-split-health-repairfrom
refactor/helm-split-actuation
Oct 6, 2026
Merged

VLukiantsev merged 3 commits into
refactor/helm-split-health-repairfrom
refactor/helm-split-actuation

Conversation

@VLukiantsev
@VLukiantsev VLukiantsev commented Oct 5, 2026 •
Copy link
Copy Markdown
Collaborator

Summary

Fourth slice of the helm_manager.go split. Moves actuation state tracking and cold-start hydration into actuation_state.go. It then gives Delete, Purge and Orphan one shared state-clearing path, and one shared uninstall flow for Delete and Purge.

Motivation & Context

Tracking which components are active and at which generation they were actuated, and rebuilding that state from the cluster at startup, is its own job, separate from running Helm commands.

Part 4 of 6 of the helm_manager.go split stack.

Key Changes

  • Commit 1 (pure move):
    • actuation_state.go: IsComponentActuated, RecordActuation, IsComponentActive, HydrateFromCluster, HydrateComponentState and their helpers, with tests in actuation_state_test.go.
    • The Helm chart RBAC template test doesn't exercise K8sHelmManager, so it moves to components_rbac_test.go.
    • The bridge README now maps each K8sHelmManager file to its job.
  • Commit 2 (DRY):
    • forgetComponentLocked gives the three teardowns one state-clearing path. Delete keeps the component recorded as inactive, with its chart override. Purge and Orphan forget it entirely.
    • Delete and Purge then differed only in how they change the stored values, and the dupl linter flagged them. So both now call uninstallComponent, configured by a componentTeardown. This was planned for PR 5 but had to come in here to pass the linter.
    • Removes lazy map initialisation and nil checks that can never trigger.
    • Adds TestK8sHelmManager_TeardownForgetsState to pin down what each teardown keeps.

Assumptions

  • Behaviour doesn't change, except that the Delete and Purge success logs merge into one message, Uninstalled 1P component Helm release, with an action field. Log-based alerts on the old messages would need updating; I found none in the repo.

Verification & Testing

  • bazel test //pkg/components/bridge:bridge_test --test_output=errors --runs_per_test=3: passes.
  • bazel build //pkg/components/... //cmd/xmc_bridge/...: passes.
  • Pre-commit: passes.
  • Review commit 1 with git diff --color-moved=dimmed-zebra.

Related Issues / Bugs

N/A

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

@VLukiantsev
VLukiantsev added this pull request to stack #1073 October 5, 2026 10:48
@VLukiantsev VLukiantsev changed the title refactor/helm split actuation refactor(bridge): move actuation state tracking out of helm_manager.go Oct 5, 2026
@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 K8sHelmManager by extracting actuation state tracking and cold-start hydration logic into a new file actuation_state.go, along with moving corresponding tests and RBAC template rendering tests into separate files. It also simplifies the component uninstallation process. The review feedback highlights several critical issues where refactoring removed defensive nil checks, introducing potential runtime panics. Specifically, evaluating method values on a nil receiver in Delete1PComponent and Purge1PComponent will trigger immediate panics, and several map writes in the newly created actuation_state.go lack lazy initialization guards for activeState and actuatedGenerations.

Comment thread pkg/components/bridge/helm_manager.go Resolved
Comment thread pkg/components/bridge/helm_manager.go Resolved
@VLukiantsev
VLukiantsev marked this pull request as ready for review October 6, 2026 09:43
@github-actions
github-actions Bot requested a review from pachopepe October 6, 2026 09:43
@VLukiantsev VLukiantsev added the priority::3-medium needs review. label Oct 6, 2026
pachopepe
pachopepe previously approved these changes Oct 6, 2026
@github-actions github-actions 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.

🤖 Incremental PR Approval

Clean rebase detected with zero semantic patch lines changed.

Preserving prior approval by @pachopepe on commit ebcaf3a.

@VLukiantsev
VLukiantsev force-pushed the refactor/helm-split-actuation branch from b147440 to e32018c Compare October 6, 2026 14:52
github-actions[bot]
github-actions Bot previously approved these changes Oct 6, 2026
@github-actions github-actions Bot left a comment
8000 Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Incremental PR Approval

Clean rebase detected with zero semantic patch lines changed.

Preserving prior approval by @pachopepe on commit ebcaf3a.

github-actions[bot]
github-actions Bot previously approved these changes Oct 6, 2026
@github-actions github-actions 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.

🤖 Incremental PR Approval

PR author is a code owner and changes since last approval (2 lines) are within the 10-line grace delta.

Preserving prior approval by @pachopepe on commit ebcaf3a.

Pure move, no behavior change. Active/actuated generation tracking and
cold-start hydration (IsComponentActuated, RecordActuation,
IsComponentActive, HydrateFromCluster, HydrateComponentState and helpers)
move to actuation_state.go, with their tests in actuation_state_test.go.
The Helm chart RBAC template test, which does not exercise K8sHelmManager,
moves to components_rbac_test.go. The bridge README now maps each
K8sHelmManager file to its responsibility.

Review with `git diff --color-moved=dimmed-zebra`.

TAG=agy
CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399
- Add forgetComponentLocked so Delete1PComponent, Purge1PComponent and
  Orphan1PComponent share one state-clearing path. Delete keeps the
  component recorded as inactive with its chart override; Purge and Orphan
  forget it entirely.
- Delete1PComponent and Purge1PComponent were then identical apart from the
  values mutation (flagged by the dupl linter), so they now share
  uninstallComponent, parameterised by a componentTeardown.
- Drop lazy map initialisation and nil checks in the actuation and
  hydration code: NewK8sHelmManager always initialises these maps, and the
  hydration callers already guarantee a non-nil manager and namespace.
- Add TestK8sHelmManager_TeardownForgetsState to pin the per-teardown
  state semantics.

TAG=agy
CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399
…t in actuation_state

Replace the legacy xmanager_cloud/logging/logging alias with the
canonical xmanager_cloud/internal/logging import path to satisfy the
google3 legacy import ratchet check.

TAG=agy
CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399
@github-actions github-actions 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.

🤖 Incremental PR Approval

PR author is a code owner and changes since last approval (2 lines) are within the 10-line grace delta.

Preserving prior approval by @pachopepe on commit ebcaf3a.

@github-actions github-actions 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.

🤖 Incremental PR Approval

PR author is a code owner and changes since last approval (2 lines) are within the 10-line grace delta.

Preserving prior approval by @pachopepe on commit ebcaf3a.

@VLukiantsev
VLukiantsev added this pull request to the merge queue Oct 6, 2026
Merged via the queue into main with commit ede4c6c Oct 6, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority::3-medium needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0