feat: support multiple InitTargets for the same WorkspaceType#20
feat: support multiple InitTargets for the same WorkspaceType#20ifdotpy wants to merge 1 commit intokcp-dev:mainfrom
Conversation
|
[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. |
|
As per documentation
So if anything, I'd call this a feature, not a bugfix ;-) |
Haha, I do not mind at all :) I will rename it soon |
| target := &initializationv1alpha1.InitTarget{} | ||
| if err := r.localClient.Get(ctx, types.NamespacedName{Name: name}, target); err != nil { | ||
| return nil, err | ||
| func (r *Reconciler) newInitTargetProvider(wstKey string) initcontroller.InitTargetProvider { |
There was a problem hiding this comment.
let's rename this to newInitTargetsProvider (plural) (including the func type InitTargetProvider and all other refs
Previously, init-agent documentation stated that only a single InitTarget per WorkspaceType was supported — a second InitTarget referencing the same WorkspaceType would race the first and one set of templates could be silently skipped. This change makes multiple InitTargets per WorkspaceType a first-class feature. The targetcontroller now keys controllers by WorkspaceType reference (path:name) instead of InitTarget UID. Sources from all matching InitTargets are aggregated into a single initialization pass, and the initializer is only removed after every source from every target is applied. - internal/controller/targetcontroller: key by WSType ref, track InitTarget names per key, aggregate provider returns all matching targets, cancel manager only when the last target is deleted. - internal/controller/initcontroller: InitTargetsProvider returns []*InitTarget; reconcile iterates sources from all of them. - Rename InitTargetProvider -> InitTargetsProvider (plural) per review feedback from @xrstf. Fixes kcp-dev#17 Signed-off-by: Igor Fominykh <ifdotpy@gmail.com>
8fa3a12 to
07ed564
Compare
|
Thanks for the review @xrstf! Addressed:
Force-pushed the amended commit with DCO signoff intact. |
Summary
Makes multiple
InitTargetresources for the sameWorkspaceTypea first-class feature. The targetcontroller now keys controllers by WorkspaceType reference (path:name) instead of InitTarget UID. Sources from all matching InitTargets are aggregated into a single initialization pass, and the initializer is only removed after every source from every target is applied.Why
Previously, the docs stated that only a single InitTarget per WorkspaceType was supported — a second InitTarget referencing the same WorkspaceType would race the first and one set of templates could be silently skipped. This change lets users compose bootstrapping behavior from independently authored InitTargets (e.g. RBAC, quotas, networking) without racing on the initializer.
Changes
internal/controller/targetcontroller: key controllers by WSType ref (path:name), track InitTarget names per WorkspaceType, aggregate provider returns all matching targets, only cancel the manager when the last target for a WorkspaceType is deleted.internal/controller/initcontroller:InitTargetsProviderreturns[]*InitTargetinstead of a single target;reconcileiterates sources from all of them.InitTargetProvider→InitTargetsProvider(plural) per review feedback.docs/content/setup/development.md: update warning to reflect new behavior.Backward compatibility
Fully backward compatible. A single InitTarget per WorkspaceType continues to work unchanged.
Fixes #17