crossplane / crossplane/crossplane-runtime

Multiple Resolver resolution results in infinite patching

Open
#694 15 comments 17 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
198
Forks
161
Avg merge
1d 11h
Merged PRs (30d)
9

Description

### What happened?
We found a reproducable inconsistancy when persisting resolved references. Basically whenever you have more then one reference and one of them is resolved in a later reconcilation loop then the first one patching this newly resolved value will purge previously resolved values at the same time, which will result in an endless loop of patching different values back and forth.

Debugging this issue showed that the issue must lie in the way that the change is send as a server-sided apply in this line:
https://github.com/crossplane/crossplane-runtime/blob/master/pkg/reconciler/managed/api.go#L193

Just FYI, doing the same patch from kubectl using a merge patch instead worked as expected.

### How can we reproduce it?
A reproducable case can be easily reproduce in this example provider: https://github.com/mirzakopic/provider-xp-bug
You will find a `mytype` Kind having two references towards other kinds called `sometype` and `othertype`.
The issue appears when you first apply the mytype with only one reference and reapply another version with both references being set.

You can reproduce that with the provider using this flow:
1. (Setup the provider in a local environment)
2. `kubectl apply -f examples/sample/mytype.yaml`
3. `kubectl apply -f examples/sample/mytype_added_ref.yaml`

Screenflow of endless resolving:
![refresolverpatchbugxp (1)](https://github.com/crossplane/crossplane-runtime/assets/129972012/61294035-e402-4a88-bcc0-c86b0929fd01)

### What environment did it happen in?
Crossplane version:
1.16 and 1.15 (but should apply to older versions as well(

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at pkg/reconciler/managed/api.go#L193 and compare the server-sided apply behavior with the merge patch behavior described in the issue. Reproduce the loop using provider-xp-bug, applying examples/sample/mytype.yaml followed by examples/sample/mytype_added_ref.yaml. Done means both resolved references persist without endlessly patching values back and forth.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.