Skip to content

Commit cbfb57c

Browse files
committed
feat(sdk): Add /run socket paths for compatibility
Add /run/dstack/*.sock and /run/*.sock to the socket path search list in all SDKs (Rust, Python, JS, Go). This ensures compatibility with systemd socket activation which uses /run instead of /var/run. Search order: 1. /var/run/dstack/*.sock (namespaced path via symlink) 2. /run/dstack/*.sock (namespaced modern path) 3. /run/*.sock (modern systemd path) 4. /var/run/*.sock (legacy path)
1 parent 828f63e commit cbfb57c

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

sdk/go/dstack/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,11 @@ func (c *DstackClient) getEndpoint() string {
240240
c.logger.Info("using simulator endpoint", "endpoint", simEndpoint)
241241
return simEndpoint
242242
}
243-
// Try new path first, fall back to old path for backward compatibility
243+
// Try paths in order of preference (namespaced first, then direct paths for backward compatibility)
244244
socketPaths := []string{
245245
"/var/run/dstack/dstack.sock",
246+
"/run/dstack/dstack.sock",
247+
"/run/dstack.sock",
246248
"/var/run/dstack.sock",
247249
}
248250
for _, path := range socketPaths {

sdk/go/tappd/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,11 @@ func (c *TappdClient) getEndpoint() string {
230230
c.logger.Info("using simulator endpoint", "endpoint", simEndpoint)
231231
return simEndpoint
232232
}
233-
// Try new path first, fall back to old path for backward compatibility
233+
// Try paths in order of preference (namespaced first, then direct paths for backward compatibility)
234234
socketPaths := []string{
235235
"/var/run/dstack/tappd.sock",
236+
"/run/dstack/tappd.sock",
237+
"/run/tappd.sock",
236238
"/var/run/tappd.sock",
237239
}
238240
for _, path := range socketPaths {

sdk/js/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,11 @@ export class DstackClient<T extends TcbInfo = TcbInfoV05x> {
179179
console.warn(`Using simulator endpoint: ${process.env.DSTACK_SIMULATOR_ENDPOINT}`)
180180
endpoint = process.env.DSTACK_SIMULATOR_ENDPOINT
181181
} else {
182-
// Try new path first, fall back to old path for backward compatibility
182+
// Try paths in order of preference (namespaced first, then direct paths for backward compatibility)
183183
const socketPaths = [
184184
'/var/run/dstack/dstack.sock',
185+
'/run/dstack/dstack.sock',
186+
'/run/dstack.sock',
185187
'/var/run/dstack.sock',
186188
]
187189
endpoint = socketPaths.find(p => fs.existsSync(p)) ?? socketPaths[0]
@@ -407,9 +409,11 @@ export class TappdClient extends DstackClient<TcbInfoV03x> {
407409
console.warn(`Using tappd endpoint: ${process.env.TAPPD_SIMULATOR_ENDPOINT}`)
408410
endpoint = process.env.TAPPD_SIMULATOR_ENDPOINT
409411
} else {
410-
// Try new path first, fall back to old path for backward compatibility
412+
// Try paths in order of preference (namespaced first, then direct paths for backward compatibility)
411413
const socketPaths = [
412414
'/var/run/dstack/tappd.sock',
415+
'/run/dstack/tappd.sock',
416+
'/run/tappd.sock',
413417
'/var/run/tappd.sock',
414418
]
415419
endpoint = socketPaths.find(p => fs.existsSync(p)) ?? socketPaths[0]

sdk/python/src/dstack_sdk/dstack_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ def get_endpoint(endpoint: str | None = None) -> str:
5151
f"Using simulator endpoint: {os.environ['DSTACK_SIMULATOR_ENDPOINT']}"
5252
)
5353
return os.environ["DSTACK_SIMULATOR_ENDPOINT"]
54-
# Try new path first, fall back to old path for backward compatibility
54+
# Try paths in order of preference (namespaced first, then direct paths for backward compatibility)
5555
socket_paths = [
5656
"/var/run/dstack/dstack.sock",
57+
"/run/dstack/dstack.sock",
58+
"/run/dstack.sock",
5759
"/var/run/dstack.sock",
5860
]
5961
for path in socket_paths:
@@ -69,9 +71,11 @@ def get_tappd_endpoint(endpoint: str | None = None) -> str:
6971
if "TAPPD_SIMULATOR_ENDPOINT" in os.environ:
7072
logger.info(f"Using tappd endpoint: {os.environ['TAPPD_SIMULATOR_ENDPOINT']}")
7173
return os.environ["TAPPD_SIMULATOR_ENDPOINT"]
72-
# Try new path first, fall back to old path for backward compatibility
74+
# Try paths in order of preference (namespaced first, then direct paths for backward compatibility)
7375
socket_paths = [
7476
"/var/run/dstack/tappd.sock",
77+
"/run/dstack/tappd.sock",
78+
"/run/tappd.sock",
7579
"/var/run/tappd.sock",
7680
]
7781
for path in socket_paths:

sdk/rust/src/dstack_client.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ fn get_endpoint(endpoint: Option<&str>) -> String {
3636
if let Ok(sim_endpoint) = env::var("DSTACK_SIMULATOR_ENDPOINT") {
3737
return sim_endpoint;
3838
}
39-
// Try new path first, fall back to old path for backward compatibility
40-
const SOCKET_PATHS: &[&str] = &["/var/run/dstack/dstack.sock", "/var/run/dstack.sock"];
39+
// Try paths in order of preference (namespaced first, then direct paths for backward compatibility)
40+
const SOCKET_PATHS: &[&str] = &[
41+
"/var/run/dstack/dstack.sock",
42+
"/run/dstack/dstack.sock",
43+
"/run/dstack.sock",
44+
"/var/run/dstack.sock",
45+
];
4146
for path in SOCKET_PATHS {
4247
if std::path::Path::new(path).exists() {
4348
return path.to_string();

sdk/rust/src/tappd_client.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ fn get_tappd_endpoint(endpoint: Option<&str>) -> String {
2121
if let Ok(sim_endpoint) = env::var("TAPPD_SIMULATOR_ENDPOINT") {
2222
return sim_endpoint;
2323
}
24-
// Try new path first, fall back to old path for backward compatibility
25-
const SOCKET_PATHS: &[&str] = &["/var/run/dstack/tappd.sock", "/var/run/tappd.sock"];
24+
// Try paths in order of preference (namespaced first, then direct paths for backward compatibility)
25+
const SOCKET_PATHS: &[&str] = &[
26+
"/var/run/dstack/tappd.sock",
27+
"/run/dstack/tappd.sock",
28+
"/run/tappd.sock",
29+
"/var/run/tappd.sock",
30+
];
2631
for path in SOCKET_PATHS {
2732
if std::path::Path::new(path).exists() {
2833
return path.to_string();

0 commit comments

Comments
 (0)