Skip to content

feat(BA-4631): Add update_deployment_policy GQL mutation#10300

Merged
HyeockJinKim merged 10 commits into
mainfrom
BA-4631_2
Mar 19, 2026
Merged

feat(BA-4631): Add update_deployment_policy GQL mutation#10300
HyeockJinKim merged 10 commits into
mainfrom
BA-4631_2

Conversation

@jopemachine
Copy link
Copy Markdown
Member

@jopemachine jopemachine commented Mar 18, 2026

Resolve BA-4631.

Summary

  • Add updateDeploymentPolicy Strawberry GraphQL mutation that upserts a deployment policy via UpsertDeploymentPolicyAction
  • New input type UpdateDeploymentPolicyInputGQL with strategy, rollback, rolling_update/blue_green config fields
  • New payload type UpdateDeploymentPolicyPayloadGQL returning the applied policy
  • Detailed GraphQL descriptions using dedent_strip for all deployment policy types
  • Unit tests with parametrized scenarios for input conversion and resolver behavior

Test plan

  • Verify updateDeploymentPolicy mutation works with ROLLING strategy
  • Verify updateDeploymentPolicy mutation works with BLUE_GREEN strategy
  • Verify upsert behavior (creates on first call, updates on subsequent calls)
  • Verify missing strategy config raises appropriate error

🤖 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/

Copilot AI review requested due to automatic review settings March 18, 2026 08:11
@github-actions github-actions Bot added size:L 100~500 LoC comp:manager Related to Manager component labels Mar 18, 2026
@jopemachine jopemachine changed the title feat(BA-4631): Add update_deployment_policy GQL mutation feat(BA-4631): Add update_deployment_policy GQL mutation Mar 18, 2026
@github-actions github-actions Bot added the area:docs Documentations label Mar 18, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_policy Strawberry 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 deployment module exports and the top-level Mutation schema.

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 thread src/ai/backend/manager/api/gql/deployment/resolver/policy.py Outdated
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,
)
@jopemachine jopemachine changed the title feat(BA-4631): Add update_deployment_policy GQL mutation feat(BA-4631): Add admin_update_deployment_policy GQL mutation Mar 18, 2026
@jopemachine jopemachine added this to the 26.4 milestone Mar 18, 2026
@jopemachine jopemachine marked this pull request as draft March 18, 2026 08:33
@github-actions github-actions Bot added size:XL 500~ LoC and removed size:L 100~500 LoC labels Mar 19, 2026
@jopemachine jopemachine requested a review from a team March 19, 2026 01:53
@jopemachine jopemachine marked this pull request as ready for review March 19, 2026 01:53
@jopemachine jopemachine changed the title feat(BA-4631): Add admin_update_deployment_policy GQL mutation feat(BA-4631): Add update_deployment_policy GQL mutation Mar 19, 2026
@github-actions github-actions Bot added size:L 100~500 LoC and removed size:XL 500~ LoC labels Mar 19, 2026
@HyeockJinKim HyeockJinKim enabled auto-merge (squash) March 19, 2026 08:46
jopemachine and others added 9 commits March 19, 2026 17:57
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>
@HyeockJinKim HyeockJinKim merged commit 5f1d1f6 into main Mar 19, 2026
33 checks passed
@HyeockJinKim HyeockJinKim deleted the BA-4631_2 branch March 19, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Documentations comp:manager Related to Manager component size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants