Repository navigation
fix(terraform): read team per-model rpm/tpm limits from metadata and clear them on removal - #40439
Conversation
…clear them on removal Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Greptile SummaryThis PR updates the Terraform team resource to synchronize per-model RPM and TPM limits with the proxy.
Confidence Score: 5/5The PR appears safe to merge with no outstanding findings. The only changes since the previous review remove the redundant comments identified by the resolved thread, leaving the reviewed behavior unchanged; no new issues or applicable rule violations were found.
|
| Filename | Overview |
|---|---|
| terraform/provider/litellm/resource_team.go | Reads per-model limits from metadata and includes empty changed maps in update payloads; the previously flagged comment was removed. |
| terraform/provider/litellm/resource_team_test.go | Adds regression tests for metadata synchronization and explicit limit clearing; the previously flagged comments were removed. |
Reviews (2): Last reviewed commit: "chore(terraform): drop explanatory comme..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
… helper and tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@greptileai please re-review 8808643, which drops the flagged comments and leaves the code unchanged |
4ddc5e2
into
litellm_internal_staging
TLDR
Problem this solves:
litellm_teamacceptsmodel_rpm_limit/model_tpm_limitbut never reads them backterraform planHow it solves it:
team_info.metadata, where the proxy stores them{}on/team/updatewhen a map is removed from configUser Flow
Before: a platform team manages LiteLLM teams with Terraform and cannot trust
terraform planfor per-model limitslitellm_teamwithmodel_rpm_limit = { "gpt-4o-mini" = 100 }andmodel_tpm_limit = { "gpt-4o-mini" = 5000 }and runterraform apply"metadata": {"model_rpm_limit": {"gpt-4o-mini": 100}, "model_tpm_limit": {"gpt-4o-mini": 5000}}, so creation works{"team_id": "<id>", "model_rpm_limit": {"gpt-4o-mini": 250}}terraform plansaysNo changes. Your infrastructure matches the configuration.even though the proxy now enforces 250.tffile and runterraform apply; Terraform printsApply complete! Resources: 0 added, 1 changed{"gpt-4o-mini": 250}and{"gpt-4o-mini": 5000}: the limits were never removedterraform importof an existing team followed byterraform planalways wants to re-add the maps, even when the proxy already has those exact valuesAfter:
terraform planreflects what the proxy enforces and removing a map clears itlitellm_teamwith both maps,terraform applyterraform plannow shows~ "gpt-4o-mini" = 250 -> 100andterraform applysets the proxy back to 100.tffile and runterraform apply"model_rpm_limit": {}, "model_tpm_limit": {}and a follow-upterraform plansaysNo changesterraform importfollowed byterraform plansaysNo changeswhen the config matches the proxyRelevant issues
Fixes BerriAI/terraform-provider-litellm#58
Linear ticket
Resolves LIT-6400
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Shared setup: LiteLLM proxy from this branch's merge base on
http://127.0.0.1:20400with Postgres, master keysk-1234, twomodel_listentries (gpt-4o-mini,anthropic-haiku-4-5, both backed by Anthropic). Terraform 1.13.3 with adev_overridesentry pointing at a provider binary built fromterraform/providerwithgo build. The proxy code is identical in both legs; only the provider binary changes. Fixture used in both legs:INFObelow is:Before (096984b)
Case 1: out-of-band change on the proxy
terraform apply -auto-approve, thenINFOcurl -s -X POST http://127.0.0.1:20400/team/update -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d '{"team_id":"'$TEAM_ID'","model_rpm_limit":{"gpt-4o-mini":250}}' -o /dev/null -w 'update http %{http_code}\n'; INFOterraform plan -no-colorCase 2: remove both maps from config
model_*_limitblocks from the fixture,terraform apply -auto-approve -no-colorINFOterraform plan -no-colorCase 3: import then plan
terraform import litellm_team.t $TEAM_ID, thenterraform plan -no-colorAfter (8808643)
Case 1: out-of-band change on the proxy
terraform apply -auto-approve, thenINFOPOST /team/updateto 250, thenINFOterraform plan -no-colorterraform apply -auto-approve, thenINFO, thenterraform plan -no-colorCase 2: remove both maps from config
model_*_limitblocks from the fixture,terraform apply -auto-approve -no-colorINFOterraform plan -no-colorCase 3: import then plan
terraform import litellm_team.t $TEAM_ID, thenterraform plan -no-colorRegression tests
TestTeamReadMapsPerModelLimitsFromMetadataandTestTeamUpdateClearsRemovedPerModelLimitsinterraform/provider/litellm/resource_team_test.goboth fail on the merge base and pass on this branch (checked by swappingresource_team.goback toHEADand running them)Type
🐛 Bug Fix
Caveats (if any)
Low
{}for a limit reads back as an empty map, which Terraform treats the same as an absent attributemodel_rpm_limit/model_tpm_limitkeys in/team/infoare still preferred if the proxy ever starts returning them thereFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/9e85dfd3970b419ca00228e1343612b6
Open in Devin Desktop: https://app.devin.ai/desktop/session/9e85dfd3970b419ca00228e1343612b6?variant=devin
Requested by: @yassin-berriai