Feat: AE-2089: update sls endpoint template params#198
Conversation
jhcipar
commented
Feb 12, 2026
- Fixes serverless endpoint update behavior so template changes are reliably persisted during in-place updates.
- Adds a direct saveTemplate GraphQL path and wires serverless updates to resolve and reuse templateId
- Preserves input-only config fields (like env, networkVolume, and related local state) after GraphQL hydration to avoid false drift/redeploy loops
- Syncs templateId back onto caller objects after deploy/update
There was a problem hiding this comment.
Pull request overview
This PR enhances serverless endpoint template update functionality to ensure template changes are reliably persisted during in-place updates. It introduces a dedicated GraphQL path for template updates via the update_template method, properly resolves and reuses templateId across operations, and preserves input-only configuration fields (env, networkVolume, datacenter) after GraphQL hydration to prevent false drift detection and unnecessary redeployments.
Changes:
- Added
update_templateGraphQL mutation method to enable separate template updates - Modified serverless update flow to call
saveTemplateseparately when template changes are detected - Enhanced deploy and update methods to sync
templateIdback to caller objects after operations
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/runpod_flash/core/api/runpod.py | Added update_template method with saveTemplate GraphQL mutation |
| src/runpod_flash/core/resources/serverless.py | Added _build_template_update_payload method, modified update flow to call update_template separately, and synced templateId to caller objects in deploy and update methods |
| tests/unit/resources/test_serverless.py | Added tests for templateId syncing, input-only field restoration during updates, and separate template update calls |
| tests/unit/resources/test_resource_manager.py | Added test verifying config drift triggers in-place update instead of redeploy |
| tests/conftest.py | Added mock for update_template in shared test fixtures |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mock_runpod_client.update_template.assert_called_once() | ||
| template_payload = mock_runpod_client.update_template.call_args.args[0] | ||
| assert template_payload["id"] == "template-existing" | ||
| assert template_payload["imageName"] == "image:v2" |
There was a problem hiding this comment.
The test creates a PodTemplate with dockerArgs="--flag" but doesn't verify that dockerArgs is included in the template_payload sent to update_template. Consider adding an assertion like assert template_payload["dockerArgs"] == "--flag" to ensure the _build_template_update_payload method correctly includes all template fields.
| assert template_payload["imageName"] == "image:v2" | |
| assert template_payload["imageName"] == "image:v2" | |
| assert template_payload["dockerArgs"] == "--flag" |
| if not updated.templateId: | ||
| updated.templateId = ( | ||
| resolved_template_id or self.templateId or new_config.templateId | ||
| ) |
There was a problem hiding this comment.
The templateId fallback logic has redundancy. Line 588-590 already resolves templateId from the result, self, or new_config. Then lines 608-611 do the same fallback again. This creates confusing control flow where the same logic is duplicated. Consider removing the second fallback since resolved_template_id should already contain the correct value from line 588-590.
| if not updated.templateId: | |
| updated.templateId = ( | |
| resolved_template_id or self.templateId or new_config.templateId | |
| ) | |
| if not updated.templateId and resolved_template_id: | |
| updated.templateId = resolved_template_id |
| payload = { | ||
| key: value for key, value in template_data.items() if key in allowed_fields | ||
| } | ||
| # savetemplate mutation requires volumeInGb, but for sls this is always 0 |
There was a problem hiding this comment.
The comment on line 508 has a typo: "savetemplate" should be "saveTemplate" to match the GraphQL mutation name and maintain consistency with the rest of the codebase which uses camelCase for mutation names.
| # savetemplate mutation requires volumeInGb, but for sls this is always 0 | |
| # saveTemplate mutation requires volumeInGb, but for sls this is always 0 |
| raise ValueError("Cannot update: endpoint not deployed") | ||
|
|
||
| try: | ||
| resolved_template_id = self.templateId or new_config.templateId |