feat(BA-4631): Add update_deployment_policy GQL mutation#10300
Merged
Conversation
update_deployment_policy GQL mutation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new GraphQL mutation for updating (upserting) a deployment policy in the Manager’s Strawberry GraphQL API, wiring it through the deployment module exports and top-level schema mutation registry.
Changes:
- Introduces
update_deployment_policyStrawberry mutation resolver that calls the deployment processor’s upsert action. - Adds new GraphQL input/payload types for the mutation (
UpdateDeploymentPolicyInputGQL,UpdateDeploymentPolicyPayloadGQL). - Exposes the new resolver and types via
deploymentmodule exports and the top-levelMutationschema.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/ai/backend/manager/api/gql/schema.py |
Registers update_deployment_policy on the root Mutation. |
src/ai/backend/manager/api/gql/deployment/types/policy.py |
Adds mutation input/payload types and input-to-service upserter conversion logic. |
src/ai/backend/manager/api/gql/deployment/types/__init__.py |
Re-exports the new policy mutation types. |
src/ai/backend/manager/api/gql/deployment/resolver/policy.py |
Implements the new update_deployment_policy mutation resolver. |
src/ai/backend/manager/api/gql/deployment/resolver/__init__.py |
Exposes the new policy resolver from the resolver package. |
src/ai/backend/manager/api/gql/deployment/__init__.py |
Re-exports the new resolver and mutation types at the deployment module level. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+150
to
+153
| def to_upserter(self, deployment_uuid: UUID) -> DeploymentPolicyUpserter: | ||
| """Convert to DeploymentPolicyUpserter for the service layer.""" | ||
| from ai.backend.manager.errors.api import InvalidAPIParameters | ||
|
|
Comment on lines
+158
to
+166
| if self.rolling_update is None: | ||
| strategy_spec = RollingUpdateSpec(max_surge=1, max_unavailable=0) | ||
| else: | ||
| strategy_spec = self.rolling_update.to_spec() | ||
| case DeploymentStrategy.BLUE_GREEN: | ||
| if self.blue_green is None: | ||
| strategy_spec = BlueGreenSpec(auto_promote=False, promote_delay_seconds=0) | ||
| else: | ||
| strategy_spec = self.blue_green.to_spec() |
Comment on lines
+139
to
+175
| @strawberry.input( | ||
| name="UpdateDeploymentPolicyInput", | ||
| description="Added in 26.3.0. Input for updating a deployment policy. Internally upserts the policy.", | ||
| ) | ||
| class UpdateDeploymentPolicyInputGQL: | ||
| deployment_id: ID | ||
| strategy: DeploymentStrategyTypeGQL | ||
| rollback_on_failure: bool = False | ||
| rolling_update: RollingUpdateConfigInputGQL | None = None | ||
| blue_green: BlueGreenConfigInputGQL | None = None | ||
|
|
||
| def to_upserter(self, deployment_uuid: UUID) -> DeploymentPolicyUpserter: | ||
| """Convert to DeploymentPolicyUpserter for the service layer.""" | ||
| from ai.backend.manager.errors.api import InvalidAPIParameters | ||
|
|
||
| strategy = DeploymentStrategy(self.strategy.value) | ||
| strategy_spec: RollingUpdateSpec | BlueGreenSpec | ||
| match strategy: | ||
| case DeploymentStrategy.ROLLING: | ||
| if self.rolling_update is None: | ||
| strategy_spec = RollingUpdateSpec(max_surge=1, max_unavailable=0) | ||
| else: | ||
| strategy_spec = self.rolling_update.to_spec() | ||
| case DeploymentStrategy.BLUE_GREEN: | ||
| if self.blue_green is None: | ||
| strategy_spec = BlueGreenSpec(auto_promote=False, promote_delay_seconds=0) | ||
| else: | ||
| strategy_spec = self.blue_green.to_spec() | ||
| case _: | ||
| raise InvalidAPIParameters(f"Unsupported deployment strategy: {strategy}") | ||
|
|
||
| return DeploymentPolicyUpserter( | ||
| deployment_id=deployment_uuid, | ||
| strategy=strategy, | ||
| strategy_spec=strategy_spec, | ||
| rollback_on_failure=self.rollback_on_failure, | ||
| ) |
update_deployment_policy GQL mutationadmin_update_deployment_policy GQL mutation
admin_update_deployment_policy GQL mutationupdate_deployment_policy GQL mutation
HyeockJinKim
approved these changes
Mar 19, 2026
Add Strawberry GraphQL mutation for updating deployment policies, internally using the existing upsert mechanism. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: octodog <mu001@lablup.com>
- Rename to admin_update_deployment_policy with check_admin_only() - Remove redundant deployment_uuid param from to_upserter(), derive from self.deployment_id - Add explicit validation requiring matching config for strategy type - Align version markers to 26.4.0 - Add unit tests for to_upserter() conversion and validation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add mock processor/context tests following test_bulk_upsert_mutations pattern: processor call verification, created flag, and superadmin check. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolve BA-4631.
Summary
updateDeploymentPolicyStrawberry GraphQL mutation that upserts a deployment policy viaUpsertDeploymentPolicyActionUpdateDeploymentPolicyInputGQLwith strategy, rollback, rolling_update/blue_green config fieldsUpdateDeploymentPolicyPayloadGQLreturning the applied policydedent_stripfor all deployment policy typesTest plan
updateDeploymentPolicymutation works with ROLLING strategyupdateDeploymentPolicymutation works with BLUE_GREEN strategy🤖 Generated with Claude Code
📚 Documentation preview 📚: https://sorna--10300.org.readthedocs.build/en/10300/
📚 Documentation preview 📚: https://sorna-ko--10300.org.readthedocs.build/ko/10300/