You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Preserve existing logic and resolve runtime path from runtime name.
306
+
307
+
name:=shimbinary.BinaryName(runtime)
308
+
ifname=="" {
309
+
return"", fmt.Errorf("invalid runtime name %s, correct runtime name should be either format like `io.containerd.runc.v1` or a full path to the binary", runtime)
310
+
}
311
+
312
+
ifpath, ok:=m.runtimePaths.Load(name); ok {
313
+
returnpath.(string), nil
314
+
}
315
+
316
+
var (
317
+
cmdPathstring
318
+
lerrerror
319
+
)
320
+
321
+
binaryPath:=shimbinary.BinaryPath(runtime)
322
+
if_, serr:=os.Stat(binaryPath); serr==nil {
323
+
cmdPath=binaryPath
324
+
}
325
+
326
+
ifcmdPath=="" {
327
+
ifcmdPath, lerr=exec.LookPath(name); lerr!=nil {
328
+
ifeerr, ok:=lerr.(*exec.Error); ok {
329
+
ifeerr.Err==exec.ErrNotFound {
330
+
self, err:=os.Executable()
331
+
iferr!=nil {
332
+
return"", err
333
+
}
334
+
335
+
// Match the calling binaries (containerd) path and see
336
+
// if they are side by side. If so, execute the shim
337
+
// found there.
338
+
testPath:=filepath.Join(filepath.Dir(self), name)
339
+
if_, serr:=os.Stat(testPath); serr==nil {
340
+
cmdPath=testPath
341
+
}
342
+
ifcmdPath=="" {
343
+
return"", errors.Wrapf(os.ErrNotExist, "runtime %q binary not installed %q", runtime, name)
344
+
}
345
+
}
346
+
}
347
+
}
348
+
}
349
+
350
+
cmdPath, err:=filepath.Abs(cmdPath)
351
+
iferr!=nil {
352
+
return"", err
353
+
}
354
+
355
+
ifpath, ok:=m.runtimePaths.LoadOrStore(name, cmdPath); ok {
356
+
// We didn't store cmdPath we loaded an already cached value. Use it.
357
+
cmdPath=path.(string)
358
+
}
359
+
360
+
returncmdPath, nil
361
+
}
362
+
279
363
// cleanupShim attempts to properly delete and cleanup shim after error
0 commit comments