fix: handle model not found retry #27
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
This pull request fixes a race condition in the retryModelRead function that caused the Terraform provider to fail in multi-node environments with the error Provider produced inconsistent result after apply.
In a distributed setup with replication lag, a Read operation immediately following a Create could target a node that had not yet received the new resource data. The provider would interpret the resulting "not found" API error as the resource being deleted, clearing its ID from the Terraform state (
d.SetId("")).The changes in litellm/resource_model_crud.go address this by:
Storing the model's ID before entering the retry loop.
Removing the brittle hardcoded error string check for "model not found".
If the retry loop completes without successfully reading the model, the original ID is restored to the resource data (
d.SetId(model_id)).