Documentation
¶
Overview ¶
Package poolmigration owns the steady-state sync that keeps legacy (same-name) SandboxPool ↔ SandboxEnv pairs aligned.
Two populations of SandboxPool coexist in the cluster:
Legacy / orphan Pools: created directly as a SandboxPool CR (no owning SandboxEnv). This reconciler wraps each one in a same-name SandboxEnv and keeps the Env's local-cluster member entry consistent with the live Pool on every reconcile.
Env-managed Pools: created by the SandboxEnv reconciler from a member entry. Their owning Env has a *different* name than the Pool (Phase-2 onwards). This reconciler intentionally leaves them alone — their Member.Spec is the post-PreCreatePool frozen snapshot and must not be re-derived here.
The legacy population is identified by the absence of any OwnerReference to a different-named SandboxEnv. For each such Pool the reconciler:
- Looks up — or creates — the same-name SandboxEnv.
- Builds a desired EnvClusterMember from the live Pool (and, when the Pool only carries TemplateName, by resolving that SandboxTemplate).
- Patches Member.Spec / Member.Config drift into the Env. Once a Member.Spec field is non-empty it is treated as frozen ("fill once") so SandboxTemplate upgrades do not auto-propagate to legacy Pools; adopter-owned Config fields (ScalingGroup / InstanceType / Multiplier / InlineResources) are re-derived on every pass.
- Stamps a non-controlling OwnerReference from the Pool to the Env.
Removal path: once every legacy Pool has been migrated to a Phase-2 member, the reconciler becomes a no-op and this package can be deleted.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PoolAdoptionReconciler ¶
type PoolAdoptionReconciler struct {
client.Client
Scheme *runtime.Scheme
// LocalClusterID identifies the cluster the Pool's member entry belongs to.
// Defaults to "local" in SetupWithManager when empty.
LocalClusterID string
// InstanceTypes is the catalog used to round-trip a Pool's PodSpec
// resources back to (InstanceType, Multiplier). A nil or Disabled provider
// causes adoption to fall back to member.InlineResources.
InstanceTypes instancetype.Provider
}
PoolAdoptionReconciler keeps every legacy same-name SandboxPool ↔ SandboxEnv pair in sync. It watches SandboxPool only — Env updates do not enqueue work here because the desired Member is derived from the Pool, not the Env.
func (*PoolAdoptionReconciler) Reconcile ¶
func (r *PoolAdoptionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile owns one Pool at a time.
Steps:
Early-exit when the Pool is Env-managed (an OwnerReference points at a SandboxEnv whose name differs from the Pool's name). Phase-2 Pools do not participate in legacy adoption.
Look up the same-name SandboxEnv; create it when missing.
Compose the desired Member from the live Pool (resolving the SandboxTemplate the first time the Member's Spec.Template is empty) and patch any drift back onto the Env.
Stamp the OwnerReference from Pool → Env.
Steps (2)–(4) are independently idempotent so a Reconcile that crashes mid-way heals on the next pass.
func (*PoolAdoptionReconciler) SetupWithManager ¶
func (r *PoolAdoptionReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager wires the reconciler with a SandboxPool primary watch. No secondary watches: an Env edit (e.g. an admin tweaking the Env's autoscaling group) is not adoption-relevant.