Skip to content

Commit b4dad64

Browse files
committed
Fix server compatibility with pre-0.19.27 runners
Closes: #3048
1 parent 289a912 commit b4dad64

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

runner/consts/consts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ const (
2626
// The current user's homedir (as of 2024-12-28, it's always root) should be used
2727
// instead of the hardcoded value
2828
RunnerHomeDir = "/root"
29-
// A repo directory and a default working directory for the job
30-
RunnerWorkingDir = "/workflow"
3129
)
3230

31+
const LegacyRepoDir = "/workflow"
32+
3333
const (
3434
RunnerHTTPPort = 10999
3535
RunnerSSHPort = 10022

runner/internal/executor/executor.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,10 @@ func (ex *RunExecutor) setJobWorkingDir(ctx context.Context) error {
360360
return gerrors.Wrap(err)
361361
}
362362
} else {
363-
ex.jobWorkingDir, err = common.ExpandPath(*ex.jobSpec.WorkingDir, "", ex.jobHomeDir)
363+
// We still support relative paths, as 0.19.27 server uses relative paths when possible
364+
// for compatibility with pre-0.19.27 runners.
365+
// Replace consts.LegacyRepoDir with "" eventually.
366+
ex.jobWorkingDir, err = common.ExpandPath(*ex.jobSpec.WorkingDir, consts.LegacyRepoDir, ex.jobHomeDir)
364367
if err != nil {
365368
return gerrors.Wrap(err)
366369
}

src/dstack/_internal/server/services/jobs/configurators/base.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,23 @@ def _repo_dir(self) -> str:
310310

311311
def _working_dir(self) -> Optional[str]:
312312
"""
313-
Returns absolute path or None
313+
Returns path or None
314+
314315
None means the default working directory taken from the image
316+
317+
Currently, for compatibility with pre-0.19.27 runners, the path may be relative.
318+
Future versions should return only absolute paths
315319
"""
316320
working_dir = self.run_spec.configuration.working_dir
317-
if working_dir is None or is_absolute_posix_path(working_dir):
321+
if working_dir is None:
318322
return working_dir
319-
# Legacy configuration; relative working_dir is deprecated
320-
return str(PurePosixPath(LEGACY_REPO_DIR) / working_dir)
323+
# Return a relative path if possible
324+
if is_absolute_posix_path(working_dir):
325+
try:
326+
return str(PurePosixPath(working_dir).relative_to(LEGACY_REPO_DIR))
327+
except ValueError:
328+
pass
329+
return working_dir
321330

322331
def _python(self) -> str:
323332
if self.run_spec.configuration.python is not None:

0 commit comments

Comments
 (0)