Skip to content

[Bug]: IndexError in dstack apply if pending service is terminated #4140

Description

@jvstme

Steps to reproduce

  1. Submit a zero-scaled service.
Submit the run test-service? [y/n]: y
⠋ test-service is waiting for requests...
 NAME          BACKEND  GPU  PRICE  STATUS   SUBMITTED  
 test-service           -    -      pending  2 mins ago 
Service is published at:
  http://test-service.example.com
  1. Before it scales, stop it using dstack stop in a new terminal.
  2. Return to the dstack apply terminal.

Actual behaviour

Submit the run test-service? [y/n]: y
Traceback (most recent call last):
  File "/venv/bin/dstack", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/dstack/_internal/cli/main.py", line 99, in main
    args.func(args)
  File "/dstack/_internal/cli/commands/apply.py", line 98, in _command
    configurator.apply_configuration(
  File "/dstack/_internal/cli/services/configurators/run.py", line 101, in apply_configuration
    return self.apply_plan(
           ^^^^^^^^^^^^^^^^
  File "/dstack/_internal/cli/services/configurators/run.py", line 241, in apply_plan
    while not _is_ready_to_attach(run):
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dstack/_internal/cli/services/configurators/run.py", line 967, in _is_ready_to_attach
    or run._run.jobs[0].job_submissions[-1].status
       ~~~~~~~~~~~~~^^^
IndexError: list index out of range

Expected behaviour

Submit the run test-service? [y/n]: y
 NAME          BACKEND  GPU  PRICE  STATUS      SUBMITTED 
 test-service           -    -      terminated  19:07     

test-service provisioning completed (terminated)
Terminated

dstack version

0.21.0

Server logs

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions