summaryrefslogtreecommitdiffhomepage
path: root/runsc/cmd/list.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2020-12-17 10:44:44 -0800
committergVisor bot <gvisor-bot@google.com>2020-12-17 10:52:44 -0800
commit8ea19b5818d0c1e9b798bd0bd288c7f51a46261d (patch)
treed7f9da9c969f460fc6267e6fe212e37bfdf12185 /runsc/cmd/list.go
parente7493a9e23325c00ad9a0db341d5887afe3ae5eb (diff)
Add sandbox ID to state file name
This allows to find all containers inside a sandbox more efficiently. This operation is required every time a container starts and stops, and previously required loading *all* container state files to check whether the container belonged to the sandbox. Apert from being inneficient, it has caused problems when state files are stale or corrupt, causing inavalability to create any container. Also adjust commands `list` and `debug` to skip over files that fail to load. Resolves #5052 PiperOrigin-RevId: 348050637
Diffstat (limited to 'runsc/cmd/list.go')
-rw-r--r--runsc/cmd/list.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/runsc/cmd/list.go b/runsc/cmd/list.go
index 6907eb16a..9f9a47bd8 100644
--- a/runsc/cmd/list.go
+++ b/runsc/cmd/list.go
@@ -24,6 +24,7 @@ import (
"github.com/google/subcommands"
specs "github.com/opencontainers/runtime-spec/specs-go"
+ "gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/runsc/config"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
@@ -71,7 +72,7 @@ func (l *List) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
if l.quiet {
for _, id := range ids {
- fmt.Println(id)
+ fmt.Println(id.ContainerID)
}
return subcommands.ExitSuccess
}
@@ -79,9 +80,10 @@ func (l *List) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
// Collect the containers.
var containers []*container.Container
for _, id := range ids {
- c, err := container.LoadAndCheck(conf.RootDir, id)
+ c, err := container.Load(conf.RootDir, id, container.LoadOpts{Exact: true})
if err != nil {
- Fatalf("loading container %q: %v", id, err)
+ log.Warningf("Skipping container %q: %v", id, err)
+ continue
}
containers = append(containers, c)
}