Repository navigation
feat(components): kubernetes helm sdk action runner and synchronous release actuation - #806
Conversation
There was a problem hiding this comment.
Code Review
This pull request integrates the Helm Go SDK into the XMC bridge to enable in-process Helm release upgrades, replacing CLI child processes. It introduces a new HelmActionRunner interface, an SDKHelmActionRunner implementation, and updates K8sHelmManager to trigger synchronous release upgrades serialized by a mutex during component lifecycle operations. Additionally, configuration flags, RBAC permissions, and dependencies are updated to support this integration. The review feedback highlights a documentation mismatch in the README regarding an asynchronous queue versus the synchronous mutex implementation, and points out fragile initialization logic in the functional options pattern of NewK8sHelmManager due to option ordering dependencies.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request integrates the Helm Go SDK into the XMC bridge component manager to enable in-process Helm release upgrades without relying on external CLI child processes. It introduces the SDKHelmActionRunner and updates K8sHelmManager to trigger synchronous upgrades during component lifecycle operations. The review feedback highlights two critical issues: a race condition in triggerUpgrade due to loading component values outside of the upgradeMu lock, and a declarative state violation caused by setting upgrade.ReuseValues = true in the Helm action runner, which prevents deleted component values from being removed in live deployments.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request integrates the Helm Go SDK directly into the component controller to perform in-process Helm release upgrades. It introduces the HelmActionRunner interface and its concrete implementation SDKHelmActionRunner, updates K8sHelmManager to trigger synchronous upgrades during component lifecycle operations, and adds comprehensive unit tests. The review feedback highlights two key areas for improvement: first, logging a warning when the HelmActionRunner is uninitialized to prevent silent actuation failures, and second, utilizing a context-aware lock (such as semaphore.Weighted) instead of sync.Mutex to ensure immediate responsiveness to context cancellation during concurrent upgrades.
e3d37cd to
1e8454e
Compare
andrzejfudro
left a comment
There was a problem hiding this comment.
I feel like there is a gap with the approach we take with the helm upgrade and chart path. Feel free to push back on my comment if I got something wrong, I lack deep understanding in that area and I only briefly checked the design doc.
…elease actuation Implement SDKHelmActionRunner using the Helm Go SDK action engine to actuate 1P component releases synchronously directly from K8sHelmManager. - Abstract Helm release upgrades behind HelmActionRunner interface. - Implement SDKHelmActionRunner with action.NewUpgrade, dynamic values loading, and chart resolution caching. - Wire release actuation flags (--release-name, --chart-path) into cmd/xmc_bridge. - Provide comprehensive unit tests with test doubles for synchronous upgrade flows. TAG=agy CONV=fa5e1d3a-e399-45eb-a73c-ef8413122857
Extract SDKHelmActionRunner and its options into dedicated sdk_helm_action_runner.go and sdk_helm_action_runner_test.go files to improve SRP, modularity, and review diff discoverability. TAG=agy CONV=fa5e1d3a-e399-45eb-a73c-ef8413122857
- Clarify README documentation to specify synchronous upgrade serialization via mutex rather than asynchronous queue in Layer 3A. - Refactor NewK8sHelmManager functional options to decouple configuration from runner instantiation, guaranteeing option order independence and eliminating post-hoc chartPath mutation. - Add unit tests verifying option order independence, precedence, and chart path propagation. Comments: - #806 (comment) - #806 (comment) TAG=agy CONV=fa5e1d3a-e399-45eb-a73c-ef8413122857
…reuseValues - Acquire upgradeMu before reading ConfigMap in triggerUpgrade to prevent lost-update race conditions under concurrent reconciliation. - Omit upgrade.ReuseValues = true in SDKHelmActionRunner to enforce declarative state synchronization on component deletion/purging. Comments: - #806 (comment) - #806 (comment) TAG=agy CONV=fa5e1d3a-e399-45eb-a73c-ef8413122857
…aware upgrade lock - Emit warning log in triggerUpgrade when HelmActionRunner is uninitialized rather than silently skipping actuation. - Implement context-aware lock acquisition on K8sHelmManager (upgradeSem) to abort immediately upon context cancellation or timeout. - Add companion unit tests verifying defensive uninitialized runner logging and context-aware lock acquisition behavior. TAG=agy CONV=fa5e1d3a-e399-45eb-a73c-ef8413122857
… namespace, releaseName, and runner - Enforce non-empty ref.Namespace in validateAndResolve and IsComponentActive, eliminating silent resolveNamespace fallback to "xmc". - Require non-empty releaseName in triggerUpgrade, preventing unconfigured release collisions with cluster-level Helm deployments. - Return explicit error in triggerUpgrade when HelmActionRunner is uninitialized rather than silently skipping execution. - Require cms-address, namespace, and release-name flags or environment variables in ParseConfig, preventing unconfigured pod startup loops. TAG=agy CONV=fa5e1d3a-e399-45eb-a73c-ef8413122857
… to sdk runner base Add Uninstall method to HelmActionRunner and SDKHelmActionRunner using action.NewUninstall. Define ComponentReleaseName (xmc-cmp-<name>) and decouple 1P component releases at the base layer. Update Delete1PComponent and Purge1PComponent to execute runner.Uninstall with acquireUpgradeLock. Delete obsolete monolithic loadAllComponentValues logic. TAG=agy CONV=fa5e1d3a-e399-45eb-a73c-ef8413122857
1e8454e to
78e5078
Compare
…efer and pass chart path - Extract uninstallRelease helper in K8sHelmManager to deduplicate release uninstallation logic across Delete1PComponent and Purge1PComponent. - Guard uninstallRelease with deferred upgrade lock release, preventing deadlocks if Helm runner uninstallation panics. - Log warning and gracefully return nil when runner is uninitialized during release uninstallation. - Remove dead-code upgradeErrs map and GetUpgradeError from PR #806, shifting error query tracking down to PR #579 where actuation status is queried. - Inject HELM_CHART_PATH into deploy/helm/templates/components/configmap.yaml from values.componentsDeployment.chartPath. - Add unit tests verifying uninitialized runner warning behavior and panic-safe lock deferral. TAG=agy CONV=fa5e1d3a-e399-45eb-a73c-ef8413122857
andrzejfudro
left a comment
There was a problem hiding this comment.
Answered in the threads.
… TODO, and declare chartPath in values Address reviewer feedback on PR #806: - Remove unused upgradeMu mutex from K8sHelmManager (superseded by upgradeSem channel semaphore). - Document dynamic per-component chart path resolution TODO comment in cmd/xmc_bridge/main.go and pkg/components/bridge/helm_manager.go. - Explicitly declare chartPath in deploy/helm/values.yaml and update README documentation. TAG=agy CONV=fa5e1d3a-e399-45eb-a73c-ef8413122857
Summary
Layer 3A of the XMC Components Reconciler stack (base:
main).Implements
HelmActionRunnerandSDKHelmActionRunnervia the Helm Go SDK, enablingxmc_bridgeto execute Helm release upgrades directly using in-cluster Kubernetes client credentials. This PR extracts the lower foundational runner layer from the live actuation subsystem to establish a minimal, fully-tested actuation driver.Motivation & Context
Layer 2 (PR #735) introduced declarative ConfigMap persistence for component values. To translate persisted component configurations into live Kubernetes workloads, the bridge controller requires an execution engine that interfaces with Helm release storage. This PR introduces the Helm Go SDK action runner abstraction, dynamic chart resolution, and synchronous release upgrade execution wired to
K8sHelmManager.Key Changes
pkg/components/bridge/sdk_helm_action_runner.go):SDKHelmActionRunnerwrappinghelm.sh/helm/v3/pkg/action.Configuration.UpgradeandresolveChartwith dynamic filesystem loading and fallback support.WithKubeconfig,WithChartPath, andWithActionRunnerconfiguration options.pkg/components/bridge/helm_manager.go):K8sHelmManagerto execute synchronous release upgrades viaHelmActionRunneronEnsure1PComponent.cmd/xmc_bridge/main.go):-chart-pathflag andHELM_CHART_PATHenvironment variable support.K8sHelmManagerwith the configured action runner and release parameters.deploy/helm/templates/components/rbac.yaml):pkg/components/bridge/sdk_helm_action_runner_test.go,cmd/xmc_bridge/main_test.go):Assumptions
Sizing Exception Justification
go.mod(external dependency declarations forhelm.sh/helm/v3and transitive dependencies). Pure Go production logic is ~357 lines, well within the 400-line limit.Verification & Testing
Pre-commit hooks (
buildifier,gofmt,golangci-lint,addlicense) passed cleanly.Related Issues / Bugs
Part of b/548435797 / b/548435649
TAG=agy
CONV=fa5e1d3a-e399-45eb-a73c-ef8413122857