A reconciliation deadlock is present in the following scenario.
Scenario
- CR manifest applied.
- Resource correctly created.
status.id correctly populated.
- External resource manually delated (web portal).
- Observe (
GET /resources/{id}) -> 404.
- Create (
POST /resources) -> 202 with Operation object (returns fields not related to resource).
- In this Create (POST) operation,
status.id is not updated with new id from the external system since the response is not related to the resource in this 202 case (populateStatusFields() is called but no fields are populated due to the response).
- Subsequent Observe will perform
get operation and not findby since status.id is present in the CR and RDC will declare that the get operation can be used.
- Observe will fail since it will use the stale
id.
Note that his problem happens with:
- 202 Pending with POST returns a response body unrelated to the resource (e.g., Operation instead of Project)
- the endpoint is of the shape:
GET /resources/{id} and the id is located in status.id.
In other scenarios like GET /resources/{name} where name is located in the spec of the CR, no problems arise.
Potential solution
Clear status of the CR when setting Pending condition (during a Create operation) so that the following Observe operation will be forced to use the findby action since status.id is not available.
Additional check: this operation should probably be done only if the RestDefinition has a findby action set.
Otherwise it would not make much sense to clear the status. For instance, the GitHub Collaborator resource (which has 202 Pending behaviour) already worked without this reconciliation problem since it uses spec.name for the GET endpoint (GET /resources/{name}).
A reconciliation deadlock is present in the following scenario.
Scenario
status.idcorrectly populated.GET /resources/{id}) -> 404.POST /resources) -> 202 with Operation object (returns fields not related to resource).status.idis not updated with newidfrom the external system since the response is not related to the resource in this 202 case (populateStatusFields()is called but no fields are populated due to the response).getoperation and notfindbysincestatus.idis present in the CR and RDC will declare that thegetoperation can be used.id.Note that his problem happens with:
GET /resources/{id}and theidis located instatus.id.In other scenarios like
GET /resources/{name}wherenameis located in the spec of the CR, no problems arise.Potential solution
Clear status of the CR when setting Pending condition (during a Create operation) so that the following Observe operation will be forced to use the
findbyaction sincestatus.idis not available.Additional check: this operation should probably be done only if the RestDefinition has a
findbyaction set.Otherwise it would not make much sense to clear the status. For instance, the GitHub Collaborator resource (which has 202 Pending behaviour) already worked without this reconciliation problem since it uses
spec.namefor the GET endpoint (GET /resources/{name}).