mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-05 23:46:57 +08:00
Fix bundle path for exec
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
17
exec.go
17
exec.go
@@ -6,7 +6,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -79,19 +78,17 @@ func execProcess(context *cli.Context) (int, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
detach := context.Bool("detach")
|
||||||
var (
|
state, err := container.State()
|
||||||
detach = context.Bool("detach")
|
if err != nil {
|
||||||
rootfs = container.Config().Rootfs
|
return -1, err
|
||||||
)
|
}
|
||||||
|
bundle := searchLabels(state.Config.Labels, "bundle")
|
||||||
p, err := getProcess(context, path.Dir(rootfs))
|
p, err := getProcess(context, bundle)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return runProcess(container, p, nil, context.String("console"), context.String("pid-file"), detach)
|
return runProcess(container, p, nil, context.String("console"), context.String("pid-file"), detach)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getProcess(context *cli.Context, bundle string) (*specs.Process, error) {
|
func getProcess(context *cli.Context, bundle string) (*specs.Process, error) {
|
||||||
|
8
list.go
8
list.go
@@ -117,20 +117,20 @@ func getContainers(context *cli.Context) ([]containerState, error) {
|
|||||||
ID: state.BaseState.ID,
|
ID: state.BaseState.ID,
|
||||||
InitProcessPid: state.BaseState.InitProcessPid,
|
InitProcessPid: state.BaseState.InitProcessPid,
|
||||||
Status: containerStatus.String(),
|
Status: containerStatus.String(),
|
||||||
Bundle: getBundlePath(state.Config.Labels),
|
Bundle: searchLabels(state.Config.Labels, "bundle"),
|
||||||
Created: state.BaseState.Created})
|
Created: state.BaseState.Created})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBundlePath(labels []string) string {
|
func searchLabels(labels []string, query string) string {
|
||||||
for _, l := range labels {
|
for _, l := range labels {
|
||||||
parts := strings.SplitN(l, "=", 2)
|
parts := strings.SplitN(l, "=", 2)
|
||||||
if len(parts) < 1 {
|
if len(parts) < 2 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if parts[0] == "bundle" {
|
if parts[0] == query {
|
||||||
return parts[1]
|
return parts[1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user