fix: aggregate sources from multiple InitTargets for the same WorkspaceType#20
fix: aggregate sources from multiple InitTargets for the same WorkspaceType#20ifdotpy wants to merge 1 commit intokcp-dev:mainfrom
Conversation
…ceType When multiple InitTargets reference the same WorkspaceType, the targetcontroller now creates a single controller per WorkspaceType instead of one per InitTarget. Sources from all matching InitTargets are aggregated into a single initialization pass, and the initializer is only removed after all sources from all targets are applied. Previously, each InitTarget spawned its own controller with the same initializer name (derived from WorkspaceType). The first controller to finish would remove the initializer, causing subsequent controllers to skip their sources entirely. Fixes kcp-dev#17 Signed-off-by: Igor Fominykh <ifdotpy@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @ifdotpy. Thanks for your PR. I'm waiting for a kcp-dev member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary
When multiple InitTargets reference the same WorkspaceType, the targetcontroller now creates a single controller per WorkspaceType instead of one per InitTarget. Sources from all matching InitTargets are aggregated into a single initialization pass, and the initializer is only removed after all sources from all targets are applied.
Problem
Each InitTarget spawned its own controller with the same initializer name (derived from WorkspaceType via
InitializerForType). The first controller to finish would remove the initializer, causing subsequent controllers to skip their sources entirely (reconciler.go line 64).Changes
internal/controller/targetcontroller/controller.go: Key controllers by WorkspaceType reference instead of InitTarget UID. Track which InitTarget names belong to each WorkspaceType. Only stop a controller when the last InitTarget for that WorkspaceType is deleted.internal/controller/initcontroller/controller.go:InitTargetProviderreturns[]*InitTargetinstead of a single target.internal/controller/initcontroller/reconciler.go: Iterate sources from all returned InitTargets before removing the initializer.Backward compatibility
Fully backward compatible. A single InitTarget per WorkspaceType continues to work unchanged.
Fixes #17