Skip to content

Activate cloud managed resources on demand from InferenceCluster - #429

Draft
negz wants to merge 2 commits into
modelplaneai:mainfrom
negz:activation-energy
Draft

Activate cloud managed resources on demand from InferenceCluster#429
negz wants to merge 2 commits into
modelplaneai:mainfrom
negz:activation-energy

Conversation

@negz

@negz negz commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Description of your changes

Fixes #427

The Configuration installs one ManagedResourceActivationPolicy that activates every cloud's managed resource kinds. Crossplane v2.4 scales a safe-start provider's runtime to zero until one of its managed resource definitions is active, but activating every kind up front keeps all cloud providers running on every control plane, even one that only ever provisions one cloud.

compose-inference-cluster now composes a policy activating just the kinds the cloud it provisions needs, so a control plane runs a cloud's providers only once it has an InferenceCluster on that cloud. The policy is cluster scoped. A namespaced XR can't compose a cluster-scoped resource, and the cloud cluster XRs (EKSCluster and the rest) are all namespaced, so this cluster-scoped function composes it instead. The base policy drops to provider-helm and provider-kubernetes, which serve every control plane.

A managed resource composed before its definition's CRD exists fails the whole reconcile, because the API server rejects a custom resource whose CRD doesn't exist. So the function holds off composing the cloud cluster XR until the policy it composed reports Healthy, which it reads back from the observed policy rather than pulling in the definitions themselves. Each definition embeds a full CRD schema, so requiring all of them risks a large request. Healthy means the policy set its definitions Active, not that their CRDs exist yet, so a managed resource composed just before the API server serves its CRD fails its apply and retries. A TODO tracks tightening this to an Established condition once the policy reports one. Once it has observed the cluster the function keeps composing it regardless, so a later activation blip never drops a provisioned cluster from desired state and deletes it.

Activation is one-way, so dropping the cloud kinds from the base policy doesn't deactivate them on a running control plane. Existing control planes keep their providers running after an upgrade. Only new ones get the lazy start.

I have:

  • Read and followed Modelplane's contribution process.
  • Run nix flake check (or ./nix.sh flake check) and made sure it passes.
  • Added or updated tests covering any composition function changes.
  • Signed off every commit with git commit -s.

The Configuration ships one ManagedResourceActivationPolicy that activates every
cloud's managed resource kinds. Crossplane v2.4 scales a safe-start provider's
runtime to zero until one of its managed resource definitions is active, but
activating every kind up front keeps all cloud providers running on every
control plane, even one that only ever provisions a single cloud.

compose-inference-cluster now composes a policy activating just the kinds the
cloud it provisions needs, so a control plane runs a cloud's providers only once
it has an InferenceCluster on that cloud. The policy is cluster scoped, so it has
to be composed here: a namespaced XR can't compose a cluster-scoped resource, and
the cloud cluster XRs (EKSCluster and the rest) are all namespaced.

A managed resource composed before its definition's CRD exists fails the whole
reconcile, because the API server rejects a custom resource whose CRD doesn't
exist. So the function holds off composing the cloud cluster XR until the policy
it composed reports Healthy, read back from the observed policy so no definition
(each of which carries a full CRD schema) has to be pulled into the request.
Healthy means the policy set its definitions Active rather than that their CRDs
exist, so a managed resource composed in the brief window before a CRD is served
fails its apply and succeeds on the next reconcile; a TODO tracks tightening this
to an Established condition once the policy reports one. Once the cluster is
observed the function keeps composing it regardless, so a later activation blip
never drops a provisioned cluster from desired state and deletes it.

Activation is one-way, so dropping the cloud kinds from the shipped policy
doesn't deactivate them on a running control plane; existing control planes keep
their providers running after an upgrade. The shipped policy is now down to
provider-helm and provider-kubernetes, which serve every control plane.

Fixes modelplaneai#427.

Signed-off-by: Nic Cope <nicc@rk0n.org>
@haarchri

haarchri commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

an other option is an WatchOperation? or something we called LazyLoading backed in feature in crossplane/uxp

@haarchri

haarchri commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

can we update e2e test setup too ?

remove this workaround: https://github.com/modelplaneai/modelplane/blob/main/e2e/lean-control-plane.yaml#L21-L52 and bump to v2.4.0 crossplane release for project local setup: https://github.com/search?q=repo%3Amodelplaneai%2Fmodelplane+%3D2.3.4&type=code

The project pinned Crossplane 2.3.4, which activates every managed resource
kind and runs every provider. Safe-start providers only scale their runtime to
zero once their definitions are inactive from v2.4.0, so the e2e faked that
behaviour: a scale-to-zero DeploymentRuntimeConfig and an ImageConfig that
forced every cloud provider Deployment to zero replicas, since otherwise the
BYO scenario would run a dozen idle cloud controllers in kind.

Pinning both the local dev control plane and the e2e to v2.4.0 makes that
native. The lean control plane's narrowed MRAP already activates only the
provider-helm and provider-kubernetes kinds the BYO compositions use, so the
cloud providers' definitions stay inactive and Crossplane scales their
controllers to zero on its own. The DeploymentRuntimeConfig and ImageConfig go.

Towards modelplaneai#427.

Signed-off-by: Nic Cope <nicc@rk0n.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't run a cloud's providers unless needed

2 participants