crossplane-contrib / crossplane-contrib/function-go-templating

Bug: `requirements didn't stabilize` error is non-deterministic when using multiple ExtraResources keys

Open
#624 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
100
Forks
65
Avg merge
2d 6h
Merged PRs (30d)
9

Description

## Summary

When a composition function returns multiple `ExtraResources` requirements, the error `requirements didn't stabilize after the maximum number of iterations (5)` occurs non-deterministically. The same XR and composition will sometimes succeed and sometimes fail across runs with no changes to inputs.

## Versions

- `function-go-templating`: v0.12.3
- `crossplane`: v1.20.x
- `crossplane render` CLI: v1.20.x

## Steps to Reproduce

Requirements:
- `crossplane render` CLI v1.20.x
- `function-go-templating` v0.12.3 running locally (`function-go-templating --insecure`)
-
**xr.yaml:**
```yaml
apiVersion: example.org/v1alpha1
kind: FooXRD
metadata:
name: foo-bar-abc123
spec:
claimRef:
apiVersion: example.org/v1alpha1
kind: Foo
name: foo-bar
namespace: foo-ns
compositionRef:
name: foo-composition
parameters:
suspend: false
```

**composition.yaml:**
```yaml
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: foo-composition
spec:
compositeTypeRef:
apiVersion: example.org/v1alpha1
kind: FooXRD
mode: Pipeline
pipeline:
- step: foo-step
functionRef:
name: function-go-templating
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
apiVersion: meta.gotemplating.fn.crossplane.io/v1alpha1
kind: ExtraResources
requirements:
foo:
apiVersion: example.org/v1alpha1
kind: FooResource
matchLabels:
example.org/foo: foo-value
bar:
apiVersion: example.org/v1alpha1
kind: BarResource
matchLabels:
example.org/bar: bar-value
baz:
apiVersion: example.org/v1alpha1
kind: BazResource
matchLabels:
example.org/baz: baz-value
qux:
apiVersion: v1
kind: ConfigMap
matchLabels:
example.org/qux: qux-value
```

**function.yaml:**
```yaml
apiVersion: pkg.crossplane.io/v1
kind: Function
metadata:
name: function-go-templating
annotations:
render.crossplane.io/runtime: Development
render.crossplane.io/runtime-development-target: localhost:9443
spec:
package: function-go-templating
```

Start the function locally then run the repro script:
```bash
function-go-templating --insecure &

for i in $(seq 1 20); do
result=$(crossplane render xr.yaml composition.yaml function.yaml 2>&1)
if echo "$result" | grep -q "stabilize"; then
echo "Run $i: FAILED (requirements didn't stabilize)"
else
echo "Run $i: PASSED"
fi
done
```

**Expected:** All 20 runs pass (requirements are static and never change).

**Actual:** Non-deterministically fails, e.g.:
```
Run 1: FAILED (requirements didn't stabilize)
Run 2: PASSED
Run 3: PASSED
Run 4: FAILED (requirements didn't stabilize)
Run 5: PASSED
Run 6: PASSED
Run 7: PASSED
Run 8: FAILED (requirements didn't stabilize)
Run 9: PASSED
Run 10: PASSED
Run 11: FAILED (requirements didn't stabilize)
Run 12: PASSED
Run 13: PASSED
Run 14: PASSED
Run 15: FAILED (requirements didn't stabilize)
Run 16: PASSED
Run 17: PASSED
Run 18: FAILED (requirements didn't stabilize)
Run 19: PASSED
Run 20: PASSED
```

## Additional Notes

- The issue is more likely to surface with 4 or more ExtraResources keys.
- In production the error recurs on every reconcile (~every 10s), blocking the XR from ever composing successfully.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided xr.yaml, composition.yaml, and function.yaml, then run the local function and the 20-run crossplane render reproduction loop. Trace how the four ExtraResources requirements are processed across iterations. Done means all runs consistently pass without the "requirements didn't stabilize" error and static requirements remain stable.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.