Skip to content

Commit b88777f

Browse files
authored
Merge pull request #480 from Dstack-TEE/feat/sdk-run-socket-paths
feat(sdk): Add /run socket paths for compatibility
2 parents 40e46b9 + 5439d14 commit b88777f

File tree

6 files changed

+38
-16
lines changed

6 files changed

+38
-16
lines changed

sdk/go/dstack/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,12 @@ 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: legacy paths first, then namespaced paths
244244
socketPaths := []string{
245-
"/var/run/dstack/dstack.sock",
246245
"/var/run/dstack.sock",
246+
"/run/dstack.sock",
247+
"/var/run/dstack/dstack.sock",
248+
"/run/dstack/dstack.sock",
247249
}
248250
for _, path := range socketPaths {
249251
if _, err := os.Stat(path); err == nil {

sdk/go/tappd/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,12 @@ 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: legacy paths first, then namespaced paths
234234
socketPaths := []string{
235-
"/var/run/dstack/tappd.sock",
236235
"/var/run/tappd.sock",
236+
"/run/tappd.sock",
237+
"/var/run/dstack/tappd.sock",
238+
"/run/dstack/tappd.sock",
237239
}
238240
for _, path := range socketPaths {
239241
if _, err := os.Stat(path); err == nil {

sdk/js/src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,12 @@ 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: legacy paths first, then namespaced paths
183183
const socketPaths = [
184-
'/var/run/dstack/dstack.sock',
185184
'/var/run/dstack.sock',
185+
'/run/dstack.sock',
186+
'/var/run/dstack/dstack.sock',
187+
'/run/dstack/dstack.sock',
186188
]
187189
endpoint = socketPaths.find(p => fs.existsSync(p)) ?? socketPaths[0]
188190
}
@@ -407,10 +409,12 @@ 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: legacy paths first, then namespaced paths
411413
const socketPaths = [
412-
'/var/run/dstack/tappd.sock',
413414
'/var/run/tappd.sock',
415+
'/run/tappd.sock',
416+
'/var/run/dstack/tappd.sock',
417+
'/run/dstack/tappd.sock',
414418
]
415419
endpoint = socketPaths.find(p => fs.existsSync(p)) ?? socketPaths[0]
416420
}

sdk/python/src/dstack_sdk/dstack_client.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ 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: legacy paths first, then namespaced paths
5555
socket_paths = [
56-
"/var/run/dstack/dstack.sock",
5756
"/var/run/dstack.sock",
57+
"/run/dstack.sock",
58+
"/var/run/dstack/dstack.sock",
59+
"/run/dstack/dstack.sock",
5860
]
5961
for path in socket_paths:
6062
if os.path.exists(path):
@@ -69,10 +71,12 @@ 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: legacy paths first, then namespaced paths
7375
socket_paths = [
74-
"/var/run/dstack/tappd.sock",
7576
"/var/run/tappd.sock",
77+
"/run/tappd.sock",
78+
"/var/run/dstack/tappd.sock",
79+
"/run/dstack/tappd.sock",
7680
]
7781
for path in socket_paths:
7882
if os.path.exists(path):

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: legacy paths first, then namespaced paths
40+
const SOCKET_PATHS: &[&str] = &[
41+
"/var/run/dstack.sock",
42+
"/run/dstack.sock",
43+
"/var/run/dstack/dstack.sock",
44+
"/run/dstack/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: legacy paths first, then namespaced paths
25+
const SOCKET_PATHS: &[&str] = &[
26+
"/var/run/tappd.sock",
27+
"/run/tappd.sock",
28+
"/var/run/dstack/tappd.sock",
29+
"/run/dstack/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)