From 39891160a1dda77bc1e13702e6a78c947e75f29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Mon, 16 Mar 2015 11:30:39 +0100 Subject: [PATCH] rkt: get appcount from the CRM We will mount an overlay filesystem in a new mount namespace so we won't have access to container's directories from outside the namespace. To solve it, we now get the app count from the Container Runtime Manifest, which is available outside the namespace. --- rkt/containers.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/rkt/containers.go b/rkt/containers.go index e272957..692ffcb 100644 --- a/rkt/containers.go +++ b/rkt/containers.go @@ -26,6 +26,7 @@ import ( "time" "github.com/coreos/rocket/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid" + "github.com/coreos/rocket/Godeps/_workspace/src/github.com/appc/spec/schema" "github.com/coreos/rocket/Godeps/_workspace/src/github.com/appc/spec/schema/types" "github.com/coreos/rocket/common" "github.com/coreos/rocket/networking/netinfo" @@ -699,14 +700,17 @@ func (c *container) getAppCount() (int, error) { return -1, fmt.Errorf("error: only prepared containers can get their app count") } - appsPath := common.AppImagesPath(".") - - lapps, err := c.getDirNames(appsPath) + b, err := ioutil.ReadFile(common.ContainerManifestPath(c.path())) if err != nil { - return -1, fmt.Errorf("error getting the list of names from %q: %v", appsPath, err) + return -1, fmt.Errorf("error reading container manifest: %v", err) } - return len(lapps), nil + m := schema.ContainerRuntimeManifest{} + if err = m.UnmarshalJSON(b); err != nil { + return -1, fmt.Errorf("unable to load manifest: %v", err) + } + + return len(m.Apps), nil } // getExitStatuses returns a map of the statuses of the container.