Skip to content

Drop presence labels for matching all resources of a kind#51

Merged
negz merged 1 commit into
mainfrom
freedom
Jun 11, 2026
Merged

Drop presence labels for matching all resources of a kind#51
negz merged 1 commit into
mainfrom
freedom

Conversation

@negz

@negz negz commented May 1, 2026

Copy link
Copy Markdown
Collaborator

Description of your changes

Fixes #11.

compose-model-deployment and compose-model-cache need to ask Crossplane for "all InferenceClusters" and "all ModelReplicas". Crossplane's required resources API used to reject a ResourceSelector with neither match_name nor match_labels, so both functions required a presence label on every resource — modelplane.ai/cluster=true on InferenceClusters and modelplane.ai/replica=true on ModelReplicas — and matched on it. The cluster label was the worse of the two: a mandatory label with no semantic meaning that the platform team had to remember on every InferenceCluster, with no signal in the schema that it was required.

crossplane/crossplane#7241 fixed the underlying issue in v2.2.1: a ResourceSelector with only apiVersion and kind set now matches all resources of that kind. function-sdk-python v0.14.0 then let require_resources build such a selector when called with neither match field.

This bumps the SDK to v0.14.0, drops both presence labels, and matches all InferenceClusters (when no clusterSelector is set) and all ModelReplicas by calling require_resources with no match field. The package declares spec.crossplane.version: '>=v2.2.1' so it won't install on a Crossplane without the fix, and the CRD apiDependency moves from the release-2.2 branch to the v2.3.2 tag.

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.

@negz

negz commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author

This'll be unlocked once #83 merges.

@negz negz marked this pull request as ready for review June 10, 2026 23:42
Copilot AI review requested due to automatic review settings June 10, 2026 23:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the “presence label” workaround previously required to match all resources of a kind via Crossplane required-resources, now relying on Crossplane >= v2.2.1 and crossplane-function-sdk-python v0.14.0 to support bare ResourceSelectors.

Changes:

  • Bump crossplane-function-sdk-python to >=0.14.0 across the workspace and lockfile.
  • Update compose-model-deployment and compose-model-cache to require all InferenceCluster / ModelReplica resources using bare selectors (no presence labels), and update tests accordingly.
  • Remove modelplane.ai/cluster: "true" from example InferenceCluster manifests and declare Crossplane >=v2.2.1 in crossplane-project.yaml.

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
uv.lock Locks crossplane-function-sdk-python at 0.14.0 and updates dependency constraints.
pyproject.toml Bumps dev dependency on crossplane-function-sdk-python>=0.14.0.
functions/compose-serving-stack/pyproject.toml Bumps function dependency on crossplane-function-sdk-python>=0.14.0.
functions/compose-model-service/pyproject.toml Bumps function dependency on crossplane-function-sdk-python>=0.14.0.
functions/compose-model-replica/pyproject.toml Bumps function dependency on crossplane-function-sdk-python>=0.14.0.
functions/compose-model-endpoint/pyproject.toml Bumps function dependency on crossplane-function-sdk-python>=0.14.0.
functions/compose-model-deployment/tests/test_scheduling.py Removes modelplane.ai/replica presence label from test fixtures.
functions/compose-model-deployment/tests/test_fn.py Updates required-resource selector expectations and removes presence label from expected replicas.
functions/compose-model-deployment/pyproject.toml Bumps function dependency on crossplane-function-sdk-python>=0.14.0.
functions/compose-model-deployment/function/fn.py Drops presence label usage; uses bare selectors to match all clusters/replicas.
functions/compose-model-cache/tests/test_fn.py Updates cluster fixtures and selector expectations to no longer require presence labels.
functions/compose-model-cache/pyproject.toml Bumps function dependency on crossplane-function-sdk-python>=0.14.0.
functions/compose-model-cache/function/fn.py Drops cluster presence-label selector; uses bare selector unless user narrows with clusterSelector.
functions/compose-inference-gateway/pyproject.toml Bumps function dependency on crossplane-function-sdk-python>=0.14.0.
functions/compose-inference-cluster/pyproject.toml Bumps function dependency on crossplane-function-sdk-python>=0.14.0.
functions/compose-inference-class/pyproject.toml Bumps function dependency on crossplane-function-sdk-python>=0.14.0.
functions/compose-gke-cluster/pyproject.toml Bumps function dependency on crossplane-function-sdk-python>=0.14.0.
functions/compose-eks-cluster/pyproject.toml Bumps function dependency on crossplane-function-sdk-python>=0.14.0.
examples/qwen-demo/03-cluster.yaml Removes the now-unnecessary modelplane.ai/cluster: "true" label from demo clusters.
examples/platform/inference-cluster-gke.yaml Updates guidance comment and removes modelplane.ai/cluster: "true" label.
examples/platform/inference-cluster-existing.yaml Removes modelplane.ai/cluster: "true" label.
examples/platform/inference-cluster-eks.yaml Removes outdated guidance about required presence label and removes the label itself.
crossplane-project.yaml Declares Crossplane >=v2.2.1 and pins CRD dependency ref to v2.3.2.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread functions/compose-model-deployment/function/fn.py
Comment thread functions/compose-model-deployment/tests/test_fn.py
compose-model-deployment and compose-model-cache need to ask Crossplane
for "all InferenceClusters" and "all ModelReplicas". Crossplane's
required resources API used to reject a ResourceSelector with neither
match_name nor match_labels, so both functions required a presence label
on every resource — modelplane.ai/cluster=true on InferenceClusters and
modelplane.ai/replica=true on ModelReplicas — and matched on it. The
cluster label was the worse of the two: a mandatory label with no
semantic meaning that the platform team had to remember on every
InferenceCluster, with no signal in the schema that it was required.

crossplane/crossplane#7241 fixed the underlying issue in v2.2.1: a
ResourceSelector with only apiVersion and kind set now matches all
resources of that kind. function-sdk-python v0.14.0 then let
require_resources build such a selector when called with neither match
field.

This bumps the SDK to v0.14.0, drops both presence labels, and matches
all InferenceClusters (when no clusterSelector is set) and all
ModelReplicas by calling require_resources with no match field. The
package declares spec.crossplane.version '>=v2.2.1' so it won't install
on a Crossplane without the fix, and the CRD apiDependency moves from
the release-2.2 branch to the v2.3.2 tag.

The ModelDeployment, ModelCache, and ModelService XRDs declared their
matchLabels selectors as bare objects with
x-kubernetes-preserve-unknown-fields, which let non-string label values
through to the functions as dict[str, Any]. A label selector's values
are always strings, so this types them as additionalProperties of type
string — matching how the XRDs already declare labels and annotations —
and drops the now-redundant str() coercion in compose-model-cache.

Fixes #11.

Signed-off-by: Nic Cope <nicc@rk0n.org>
@negz negz merged commit 06013a4 into main Jun 11, 2026
3 checks passed
@negz negz deleted the freedom branch June 16, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop workaround labels for matching all resources of a kind

3 participants