mirror of
https://github.com/clearlinux/rkt.git
synced 2026-11-25 21:42:50 +00:00
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.
This commit is contained in:
+9
-5
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user