You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spike #221 confirmed that Crossplane's built-in Usage mechanism works for CloudFoundry managed resource deletion ordering without any provider code changes. The team decided to use existing tools (Crossplane Usage resources with Compositions) rather than implementing provider-managed deletion protection.
However, users currently have no reference examples showing how to compose CF managed resources with correct deletion ordering. Without guidance, users must independently discover how to combine Compositions, Usage resources, and composition functions — a non-trivial effort that slows adoption of the recommended approach.
Scope
Provide runnable Composition examples in the provider repository (docs/ or examples/) that demonstrate how to:
Compose multiple CF managed resources into a single Composite Resource with correct creation and deletion ordering
Use Crossplane Usage resources (or ClusterUsage) to enforce deletion protection between dependent CF resources
Use composition functions (function-sequencer, function-deletion-protection) as the recommended approach for automating Usage creation within the composition pipeline
Proposed examples:
Minimal — Org + Space with manual Usage: An XRD + Composition + Claim that provisions an Organization and a Space, with a manual Usage resource ensuring the Space is deleted before the Organization. Uses function-patch-and-transform only, no function-sequencer. Target audience: users who want the simplest possible example.
Typical Stack — Org + Space + ServiceInstance + ServiceCredentialBinding: An XRD + Composition + Claim that provisions a full CF application stack (Org → Space → ServiceInstance → ServiceCredentialBinding) with automated deletion ordering via function-sequencer. Deletion order: bindings → instances → spaces → orgs. Demonstrates function-sequencer with enableDeletionSequencing: true and replayDeletion: true. This is the "typical stack" requested in [SPIKE] Investigate Crossplane ResourceUsage Viability for Cross-Resource Deletion Protection #221 (see comment by @sdischer-sap).
Crossplane v2 Migration Note: A short guide showing the API differences for v1 (apiextensions.crossplane.io/v1alpha1Usage) vs v2 (protection.crossplane.io/v1beta1Usage / ClusterUsage), so users can adapt the examples when upgrading.
Each example must include complete, runnable YAML (XRD, Composition, Claim, required Function + Provider references), prerequisites (Crossplane with --enable-usages for v1, or v2 where it is enabled by default; required composition functions installed), and a "Test deletion ordering" section with kubectl delete commands proving that deletion of a "used" resource is blocked. Crossplane v1 vs v2 differences (API group, namespaced vs cluster-scoped, feature flag) must be documented.
All Composition examples must be covered by e2e tests that verify both creation succeeds and deletion ordering is enforced (i.e., deleting a "used" resource is blocked, and proceeds only after dependents are removed).
Custom ResourceUsage CRD (BTP-provider approach) — not in scope for CF provider
Technical Steps
Create examples/compositions/ directory (or docs/ end-user guide section) in the provider repository
Implement Example 1 (Org + Space + manual Usage) — start with function-patch-and-transform, add a Usage resource in the Composition
Implement Example 2 (full stack + function-sequencer) — install function-sequencer as a prerequisite, configure enableDeletionSequencing: true and replayDeletion: true
Write v1 vs v2 migration note — document API group change, Usage vs ClusterUsage, and feature flag differences
Add e2e test cases for each example:
Apply the Composition and Claim, verify all composed resources reach Ready: true
Attempt kubectl delete on a "used" resource — assert deletion is blocked by the Usage webhook
Delete the dependent resource — assert the "used" resource deletion now proceeds
Integrate the new e2e tests into the existing test suite and CI pipeline so examples are validated on every PR
Workarounds & Alternatives
Today, users must manually encode deletion ordering by carefully ordering resource creation in their Helm charts or Kustomize overlays, and rely on CF API errors when deletion of a resource with dependents is attempted. This is fragile — there is no enforcement at the Crossplane level, and a kubectl delete on an Org while Spaces still exist will succeed at the Crossplane level but fail at the CF API level, leaving resources in an inconsistent state.
An alternative is the BTP provider's custom ResourceUsage CRD, but this introduces provider-owned deletion infrastructure that must be maintained and evolved as Crossplane evolves.
Context
Spike #221 confirmed that Crossplane's built-in Usage mechanism works for CloudFoundry managed resource deletion ordering without any provider code changes. The team decided to use existing tools (Crossplane Usage resources with Compositions) rather than implementing provider-managed deletion protection.
However, users currently have no reference examples showing how to compose CF managed resources with correct deletion ordering. Without guidance, users must independently discover how to combine Compositions, Usage resources, and composition functions — a non-trivial effort that slows adoption of the recommended approach.
Scope
Provide runnable Composition examples in the provider repository (
docs/orexamples/) that demonstrate how to:Usageresources (orClusterUsage) to enforce deletion protection between dependent CF resourcesfunction-sequencer,function-deletion-protection) as the recommended approach for automating Usage creation within the composition pipelineProposed examples:
Minimal — Org + Space with manual Usage: An XRD + Composition + Claim that provisions an Organization and a Space, with a manual
Usageresource ensuring the Space is deleted before the Organization. Usesfunction-patch-and-transformonly, no function-sequencer. Target audience: users who want the simplest possible example.Typical Stack — Org + Space + ServiceInstance + ServiceCredentialBinding: An XRD + Composition + Claim that provisions a full CF application stack (Org → Space → ServiceInstance → ServiceCredentialBinding) with automated deletion ordering via
function-sequencer. Deletion order: bindings → instances → spaces → orgs. Demonstratesfunction-sequencerwithenableDeletionSequencing: trueandreplayDeletion: true. This is the "typical stack" requested in [SPIKE] Investigate Crossplane ResourceUsage Viability for Cross-Resource Deletion Protection #221 (see comment by @sdischer-sap).Crossplane v2 Migration Note: A short guide showing the API differences for v1 (
apiextensions.crossplane.io/v1alpha1Usage) vs v2 (protection.crossplane.io/v1beta1Usage/ClusterUsage), so users can adapt the examples when upgrading.Each example must include complete, runnable YAML (XRD, Composition, Claim, required
Function+Providerreferences), prerequisites (Crossplane with--enable-usagesfor v1, or v2 where it is enabled by default; required composition functions installed), and a "Test deletion ordering" section withkubectl deletecommands proving that deletion of a "used" resource is blocked. Crossplane v1 vs v2 differences (API group, namespaced vs cluster-scoped, feature flag) must be documented.All Composition examples must be covered by e2e tests that verify both creation succeeds and deletion ordering is enforced (i.e., deleting a "used" resource is blocked, and proceeds only after dependents are removed).
Out of scope
sharedSpaces(cross-composition references) — requires a dedicated spike per [SPIKE] Investigate Crossplane ResourceUsage Viability for Cross-Resource Deletion Protection #221ResourceUsageCRD (BTP-provider approach) — not in scope for CF providerTechnical Steps
examples/compositions/directory (ordocs/end-user guide section) in the provider repositoryfunction-patch-and-transform, add aUsageresource in the Compositionfunction-sequencer) — installfunction-sequenceras a prerequisite, configureenableDeletionSequencing: trueandreplayDeletion: trueUsagevsClusterUsage, and feature flag differencesReady: truekubectl deleteon a "used" resource — assert deletion is blocked by the Usage webhookWorkarounds & Alternatives
Today, users must manually encode deletion ordering by carefully ordering resource creation in their Helm charts or Kustomize overlays, and rely on CF API errors when deletion of a resource with dependents is attempted. This is fragile — there is no enforcement at the Crossplane level, and a
kubectl deleteon an Org while Spaces still exist will succeed at the Crossplane level but fail at the CF API level, leaving resources in an inconsistent state.An alternative is the BTP provider's custom
ResourceUsageCRD, but this introduces provider-owned deletion infrastructure that must be maintained and evolved as Crossplane evolves.Additional context
Usageto ensure ordered deletion #65function-sequencerfunction-deletion-protection