Skip to content

Conversation

jvstme
Copy link
Collaborator

@jvstme jvstme commented Jun 19, 2025

Support rolling deployment when some service
configuration properties are changed. During the
deployment, dstack updates service replicas one
by one. It first starts a new version of the
replica, then waits until it is running, then
stops the old version of the replica.

As part of the implementation, introduce a new run
and job property - deployment_num. When a new
configuration is applied, the deployment_num of
the run is incremented. Then, dstack gradually
updates the jobs so that their deployment_num
matches that of the run. Some jobs are updated
in-place, if the new configuration does not affect
their spec, others are redeployed as described
above.

> dstack apply

Active run test-service already exists. Detected configuration changes that can be updated in-place: ['image', 'env', 'commands']
Update the run? [y/n]: y
⠋ Launching test-service...
 NAME                            BACKEND          RESOURCES                        PRICE    STATUS       SUBMITTED
 test-service deployment=1                                                                  running      11 mins ago
   replica=0 job=0 deployment=0  aws (us-west-2)  cpu=2 mem=1GB disk=100GB (spot)  $0.0026  terminating  11 mins ago
   replica=1 job=0 deployment=1  aws (us-west-2)  cpu=2 mem=1GB disk=100GB (spot)  $0.0026  running      1 min ago

Initial and main part of #2180

Support rolling deployment when some service
configuration properties are changed. During the
deployment, `dstack` updates service replicas one
by one. It first starts a new version of the
replica, then waits until it is running, then
stops the old version of the replica.

As part of the implementation, introduce a new run
and job property - `deployment_num`. When a new
configuration is applied, the `deployment_num` of
the run is incremented. Then, `dstack` gradually
updates the jobs so that their `deployment_num`
matches that of the run. Some jobs are updated
in-place, if the new configuration does not affect
their spec, others are redeployed as described
above.

```shell
> dstack apply

Active run test-service already exists. Detected configuration changes that can be updated in-place: ['image', 'env', 'commands']
Update the run? [y/n]: y
⠋ Launching test-service...
 NAME                            BACKEND          RESOURCES                        PRICE    STATUS       SUBMITTED
 test-service deployment=1                                                                  running      11 mins ago
   replica=0 job=0 deployment=0  aws (us-west-2)  cpu=2 mem=1GB disk=100GB (spot)  $0.0026  terminating  11 mins ago
   replica=1 job=0 deployment=1  aws (us-west-2)  cpu=2 mem=1GB disk=100GB (spot)  $0.0026  running      1 min ago
```
@jvstme
Copy link
Collaborator Author

jvstme commented Jun 19, 2025

I'm yet to test on Postgres and possibly add some unit tests. The rest should be ready for the initial release

@jvstme jvstme requested a review from un-def June 19, 2025 11:09
@jvstme jvstme merged commit 908f079 into master Jun 19, 2025
25 checks passed
@jvstme jvstme deleted the issue_2180_rolling_deployment branch June 19, 2025 17:00
haydnli-shopify pushed a commit to haydnli-shopify/dstack that referenced this pull request Jun 23, 2025
Support rolling deployment when some service
configuration properties are changed. During the
deployment, `dstack` updates service replicas one
by one. It first starts a new version of the
replica, then waits until it is running, then
stops the old version of the replica.

As part of the implementation, introduce a new run
and job property - `deployment_num`. When a new
configuration is applied, the `deployment_num` of
the run is incremented. Then, `dstack` gradually
updates the jobs so that their `deployment_num`
matches that of the run. Some jobs are updated
in-place, if the new configuration does not affect
their spec, others are redeployed as described
above.

```shell
> dstack apply

Active run test-service already exists. Detected configuration changes that can be updated in-place: ['image', 'env', 'commands']
Update the run? [y/n]: y
⠋ Launching test-service...
 NAME                            BACKEND          RESOURCES                        PRICE    STATUS       SUBMITTED
 test-service deployment=1                                                                  running      11 mins ago
   replica=0 job=0 deployment=0  aws (us-west-2)  cpu=2 mem=1GB disk=100GB (spot)  $0.0026  terminating  11 mins ago
   replica=1 job=0 deployment=1  aws (us-west-2)  cpu=2 mem=1GB disk=100GB (spot)  $0.0026  running      1 min ago
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants