mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-10-12 10:09:04 +00:00
Move deps from _workspace/ to vendor/
godep restore pushd $GOPATH/src/github.com/appc/spec git co master popd go get go4.org/errorutil rm -rf Godeps godep save ./... git add vendor git add -f $(git ls-files --other vendor/) git co -- Godeps/LICENSES Godeps/.license_file_state Godeps/OWNERS
This commit is contained in:
76
vendor/github.com/google/cadvisor/container/rkt/client.go
generated
vendored
Normal file
76
vendor/github.com/google/cadvisor/container/rkt/client.go
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package rkt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
rktapi "github.com/coreos/rkt/api/v1alpha"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultRktAPIServiceAddr = "localhost:15441"
|
||||
timeout = 2 * time.Second
|
||||
)
|
||||
|
||||
var (
|
||||
rktClient rktapi.PublicAPIClient
|
||||
rktClientErr error
|
||||
once sync.Once
|
||||
)
|
||||
|
||||
func Client() (rktapi.PublicAPIClient, error) {
|
||||
once.Do(func() {
|
||||
conn, err := net.DialTimeout("tcp", defaultRktAPIServiceAddr, timeout)
|
||||
if err != nil {
|
||||
rktClient = nil
|
||||
rktClientErr = fmt.Errorf("rkt: cannot tcp Dial rkt api service: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
conn.Close()
|
||||
|
||||
apisvcConn, err := grpc.Dial(defaultRktAPIServiceAddr, grpc.WithInsecure(), grpc.WithTimeout(timeout))
|
||||
if err != nil {
|
||||
rktClient = nil
|
||||
rktClientErr = fmt.Errorf("rkt: cannot grpc Dial rkt api service: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
rktClient = rktapi.NewPublicAPIClient(apisvcConn)
|
||||
})
|
||||
|
||||
return rktClient, rktClientErr
|
||||
}
|
||||
|
||||
func RktPath() (string, error) {
|
||||
client, err := Client()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
resp, err := client.GetInfo(context.Background(), &rktapi.GetInfoRequest{})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("couldn't GetInfo from rkt api service: %v", err)
|
||||
}
|
||||
|
||||
return resp.Info.GlobalFlags.Dir, nil
|
||||
}
|
104
vendor/github.com/google/cadvisor/container/rkt/factory.go
generated
vendored
Normal file
104
vendor/github.com/google/cadvisor/container/rkt/factory.go
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package rkt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/google/cadvisor/container"
|
||||
"github.com/google/cadvisor/container/libcontainer"
|
||||
"github.com/google/cadvisor/fs"
|
||||
info "github.com/google/cadvisor/info/v1"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
const RktNamespace = "rkt"
|
||||
|
||||
type rktFactory struct {
|
||||
machineInfoFactory info.MachineInfoFactory
|
||||
|
||||
cgroupSubsystems *libcontainer.CgroupSubsystems
|
||||
|
||||
fsInfo fs.FsInfo
|
||||
|
||||
ignoreMetrics container.MetricSet
|
||||
|
||||
rktPath string
|
||||
}
|
||||
|
||||
func (self *rktFactory) String() string {
|
||||
return "rkt"
|
||||
}
|
||||
|
||||
func (self *rktFactory) NewContainerHandler(name string, inHostNamespace bool) (container.ContainerHandler, error) {
|
||||
client, err := Client()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rootFs := "/"
|
||||
if !inHostNamespace {
|
||||
rootFs = "/rootfs"
|
||||
}
|
||||
return newRktContainerHandler(name, client, self.rktPath, self.cgroupSubsystems, self.machineInfoFactory, self.fsInfo, rootFs, self.ignoreMetrics)
|
||||
}
|
||||
|
||||
func (self *rktFactory) CanHandleAndAccept(name string) (bool, bool, error) {
|
||||
// will ignore all cgroup names that don't either correspond to the machine.slice that is the pod or the containers that belong to the pod
|
||||
// only works for machined rkt pods at the moment
|
||||
|
||||
if strings.HasPrefix(name, "/machine.slice/machine-rkt\\x2d") {
|
||||
accept, err := verifyName(name)
|
||||
return true, accept, err
|
||||
}
|
||||
return false, false, fmt.Errorf("%s not handled by rkt handler", name)
|
||||
}
|
||||
|
||||
func (self *rktFactory) DebugInfo() map[string][]string {
|
||||
return map[string][]string{}
|
||||
}
|
||||
|
||||
func Register(machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, ignoreMetrics container.MetricSet) error {
|
||||
_, err := Client()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to communicate with Rkt api service: %v", err)
|
||||
}
|
||||
|
||||
rktPath, err := RktPath()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get the RktPath variable %v", err)
|
||||
}
|
||||
|
||||
cgroupSubsystems, err := libcontainer.GetCgroupSubsystems()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get cgroup subsystems: %v", err)
|
||||
}
|
||||
if len(cgroupSubsystems.Mounts) == 0 {
|
||||
return fmt.Errorf("failed to find supported cgroup mounts for the raw factory")
|
||||
}
|
||||
|
||||
glog.Infof("Registering Rkt factory")
|
||||
factory := &rktFactory{
|
||||
machineInfoFactory: machineInfoFactory,
|
||||
fsInfo: fsInfo,
|
||||
cgroupSubsystems: &cgroupSubsystems,
|
||||
ignoreMetrics: ignoreMetrics,
|
||||
rktPath: rktPath,
|
||||
}
|
||||
container.RegisterContainerHandlerFactory(factory)
|
||||
return nil
|
||||
}
|
327
vendor/github.com/google/cadvisor/container/rkt/handler.go
generated
vendored
Normal file
327
vendor/github.com/google/cadvisor/container/rkt/handler.go
generated
vendored
Normal file
@@ -0,0 +1,327 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Handler for "rkt" containers.
|
||||
package rkt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
rktapi "github.com/coreos/rkt/api/v1alpha"
|
||||
"github.com/google/cadvisor/container"
|
||||
"github.com/google/cadvisor/container/common"
|
||||
"github.com/google/cadvisor/container/libcontainer"
|
||||
"github.com/google/cadvisor/fs"
|
||||
info "github.com/google/cadvisor/info/v1"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups"
|
||||
cgroupfs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
|
||||
"github.com/opencontainers/runc/libcontainer/configs"
|
||||
)
|
||||
|
||||
type rktContainerHandler struct {
|
||||
rktClient rktapi.PublicAPIClient
|
||||
// Name of the container for this handler.
|
||||
name string
|
||||
cgroupSubsystems *libcontainer.CgroupSubsystems
|
||||
machineInfoFactory info.MachineInfoFactory
|
||||
|
||||
// Absolute path to the cgroup hierarchies of this container.
|
||||
// (e.g.: "cpu" -> "/sys/fs/cgroup/cpu/test")
|
||||
cgroupPaths map[string]string
|
||||
|
||||
// Manager of this container's cgroups.
|
||||
cgroupManager cgroups.Manager
|
||||
|
||||
// Whether this container has network isolation enabled.
|
||||
hasNetwork bool
|
||||
|
||||
fsInfo fs.FsInfo
|
||||
|
||||
rootFs string
|
||||
|
||||
isPod bool
|
||||
|
||||
aliases []string
|
||||
|
||||
pid int
|
||||
|
||||
rootfsStorageDir string
|
||||
|
||||
labels map[string]string
|
||||
|
||||
// Filesystem handler.
|
||||
fsHandler common.FsHandler
|
||||
|
||||
ignoreMetrics container.MetricSet
|
||||
|
||||
apiPod *rktapi.Pod
|
||||
}
|
||||
|
||||
func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPath string, cgroupSubsystems *libcontainer.CgroupSubsystems, machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, rootFs string, ignoreMetrics container.MetricSet) (container.ContainerHandler, error) {
|
||||
aliases := make([]string, 1)
|
||||
isPod := false
|
||||
|
||||
apiPod := &rktapi.Pod{}
|
||||
|
||||
parsed, err := parseName(name)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("this should be impossible!, new handler failing, but factory allowed, name = %s", name)
|
||||
}
|
||||
|
||||
//rktnetes uses containerID: rkt://fff40827-b994-4e3a-8f88-6427c2c8a5ac:nginx
|
||||
if parsed.Container == "" {
|
||||
isPod = true
|
||||
aliases = append(aliases, "rkt://"+parsed.Pod)
|
||||
} else {
|
||||
aliases = append(aliases, "rkt://"+parsed.Pod+":"+parsed.Container)
|
||||
}
|
||||
|
||||
pid := os.Getpid()
|
||||
labels := make(map[string]string)
|
||||
resp, err := rktClient.InspectPod(context.Background(), &rktapi.InspectPodRequest{
|
||||
Id: parsed.Pod,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
var annotations []*rktapi.KeyValue
|
||||
if parsed.Container == "" {
|
||||
pid = int(resp.Pod.Pid)
|
||||
apiPod = resp.Pod
|
||||
annotations = resp.Pod.Annotations
|
||||
} else {
|
||||
var ok bool
|
||||
if annotations, ok = findAnnotations(resp.Pod.Apps, parsed.Container); !ok {
|
||||
glog.Warningf("couldn't find application in Pod matching %v", parsed.Container)
|
||||
}
|
||||
}
|
||||
labels = createLabels(annotations)
|
||||
}
|
||||
|
||||
cgroupPaths := common.MakeCgroupPaths(cgroupSubsystems.MountPoints, name)
|
||||
|
||||
// Generate the equivalent cgroup manager for this container.
|
||||
cgroupManager := &cgroupfs.Manager{
|
||||
Cgroups: &configs.Cgroup{
|
||||
Name: name,
|
||||
},
|
||||
Paths: cgroupPaths,
|
||||
}
|
||||
|
||||
hasNetwork := false
|
||||
if isPod {
|
||||
hasNetwork = true
|
||||
}
|
||||
|
||||
rootfsStorageDir := getRootFs(rktPath, parsed)
|
||||
|
||||
handler := &rktContainerHandler{
|
||||
name: name,
|
||||
rktClient: rktClient,
|
||||
cgroupSubsystems: cgroupSubsystems,
|
||||
machineInfoFactory: machineInfoFactory,
|
||||
cgroupPaths: cgroupPaths,
|
||||
cgroupManager: cgroupManager,
|
||||
fsInfo: fsInfo,
|
||||
hasNetwork: hasNetwork,
|
||||
rootFs: rootFs,
|
||||
isPod: isPod,
|
||||
aliases: aliases,
|
||||
pid: pid,
|
||||
labels: labels,
|
||||
rootfsStorageDir: rootfsStorageDir,
|
||||
ignoreMetrics: ignoreMetrics,
|
||||
apiPod: apiPod,
|
||||
}
|
||||
|
||||
if !ignoreMetrics.Has(container.DiskUsageMetrics) {
|
||||
handler.fsHandler = common.NewFsHandler(time.Minute, rootfsStorageDir, "", fsInfo)
|
||||
}
|
||||
|
||||
return handler, nil
|
||||
}
|
||||
|
||||
func findAnnotations(apps []*rktapi.App, container string) ([]*rktapi.KeyValue, bool) {
|
||||
for _, app := range apps {
|
||||
if app.Name == container {
|
||||
return app.Annotations, true
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func createLabels(annotations []*rktapi.KeyValue) map[string]string {
|
||||
labels := make(map[string]string)
|
||||
for _, kv := range annotations {
|
||||
labels[kv.Key] = kv.Value
|
||||
}
|
||||
|
||||
return labels
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) ContainerReference() (info.ContainerReference, error) {
|
||||
return info.ContainerReference{
|
||||
Name: handler.name,
|
||||
Aliases: handler.aliases,
|
||||
Namespace: RktNamespace,
|
||||
Labels: handler.labels,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) Start() {
|
||||
handler.fsHandler.Start()
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) Cleanup() {
|
||||
handler.fsHandler.Stop()
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) GetSpec() (info.ContainerSpec, error) {
|
||||
hasNetwork := handler.hasNetwork && !handler.ignoreMetrics.Has(container.NetworkUsageMetrics)
|
||||
hasFilesystem := !handler.ignoreMetrics.Has(container.DiskUsageMetrics)
|
||||
return common.GetSpec(handler.cgroupPaths, handler.machineInfoFactory, hasNetwork, hasFilesystem)
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
||||
if handler.ignoreMetrics.Has(container.DiskUsageMetrics) {
|
||||
return nil
|
||||
}
|
||||
|
||||
deviceInfo, err := handler.fsInfo.GetDirFsDevice(handler.rootfsStorageDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
mi, err := handler.machineInfoFactory.GetMachineInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var limit uint64 = 0
|
||||
|
||||
// Use capacity as limit.
|
||||
for _, fs := range mi.Filesystems {
|
||||
if fs.Device == deviceInfo.Device {
|
||||
limit = fs.Capacity
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
fsStat := info.FsStats{Device: deviceInfo.Device, Limit: limit}
|
||||
|
||||
fsStat.BaseUsage, fsStat.Usage = handler.fsHandler.Usage()
|
||||
|
||||
stats.Filesystem = append(stats.Filesystem, fsStat)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) GetStats() (*info.ContainerStats, error) {
|
||||
stats, err := libcontainer.GetStats(handler.cgroupManager, handler.rootFs, handler.pid, handler.ignoreMetrics)
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
|
||||
// Get filesystem stats.
|
||||
err = handler.getFsStats(stats)
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) GetCgroupPath(resource string) (string, error) {
|
||||
path, ok := handler.cgroupPaths[resource]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("could not find path for resource %q for container %q\n", resource, handler.name)
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) GetContainerLabels() map[string]string {
|
||||
return handler.labels
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) ListContainers(listType container.ListType) ([]info.ContainerReference, error) {
|
||||
containers := make(map[string]struct{})
|
||||
|
||||
// Rkt containers do not have subcontainers, only the "Pod" does.
|
||||
if handler.isPod == false {
|
||||
var ret []info.ContainerReference
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// Turn the system.slice cgroups into the Pod's subcontainers
|
||||
for _, cgroupPath := range handler.cgroupPaths {
|
||||
err := common.ListDirectories(path.Join(cgroupPath, "system.slice"), path.Join(handler.name, "system.slice"), listType == container.ListRecursive, containers)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Create the container references. for the Pod's subcontainers
|
||||
ret := make([]info.ContainerReference, 0, len(handler.apiPod.Apps))
|
||||
for cont := range containers {
|
||||
aliases := make([]string, 1)
|
||||
parsed, err := parseName(cont)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("this should be impossible!, unable to parse rkt subcontainer name = %s", cont)
|
||||
}
|
||||
aliases = append(aliases, parsed.Pod+":"+parsed.Container)
|
||||
|
||||
labels := make(map[string]string)
|
||||
if annotations, ok := findAnnotations(handler.apiPod.Apps, parsed.Container); !ok {
|
||||
glog.Warningf("couldn't find application in Pod matching %v", parsed.Container)
|
||||
} else {
|
||||
labels = createLabels(annotations)
|
||||
}
|
||||
|
||||
ret = append(ret, info.ContainerReference{
|
||||
Name: cont,
|
||||
Aliases: aliases,
|
||||
Namespace: RktNamespace,
|
||||
Labels: labels,
|
||||
})
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) ListThreads(listType container.ListType) ([]int, error) {
|
||||
// TODO(sjpotter): Implement? Not implemented with docker yet
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) ListProcesses(listType container.ListType) ([]int, error) {
|
||||
return libcontainer.GetProcesses(handler.cgroupManager)
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) WatchSubcontainers(events chan container.SubcontainerEvent) error {
|
||||
return fmt.Errorf("watch is unimplemented in the Rkt container driver")
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) StopWatchingSubcontainers() error {
|
||||
// No-op for Rkt driver.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (handler *rktContainerHandler) Exists() bool {
|
||||
return common.CgroupExists(handler.cgroupPaths)
|
||||
}
|
93
vendor/github.com/google/cadvisor/container/rkt/helpers.go
generated
vendored
Normal file
93
vendor/github.com/google/cadvisor/container/rkt/helpers.go
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package rkt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
)
|
||||
|
||||
type parsedName struct {
|
||||
Pod string
|
||||
Container string
|
||||
}
|
||||
|
||||
func verifyName(name string) (bool, error) {
|
||||
_, err := parseName(name)
|
||||
return err == nil, err
|
||||
}
|
||||
|
||||
/* Parse cgroup name into a pod/container name struct
|
||||
Example cgroup fs name
|
||||
|
||||
pod - /sys/fs/cgroup/cpu/machine.slice/machine-rkt\\x2df556b64a\\x2d17a7\\x2d47d7\\x2d93ec\\x2def2275c3d67e.scope/
|
||||
container under pod - /sys/fs/cgroup/cpu/machine.slice/machine-rkt\\x2df556b64a\\x2d17a7\\x2d47d7\\x2d93ec\\x2def2275c3d67e.scope/system.slice/alpine-sh.service
|
||||
*/
|
||||
//TODO{sjpotter}: this currently only recognizes machined started pods, which actually doesn't help with k8s which uses them as systemd services, need a solution for both
|
||||
func parseName(name string) (*parsedName, error) {
|
||||
splits := strings.Split(name, "/")
|
||||
if len(splits) == 3 || len(splits) == 5 {
|
||||
parsed := &parsedName{}
|
||||
|
||||
if splits[1] == "machine.slice" {
|
||||
replacer := strings.NewReplacer("machine-rkt\\x2d", "", ".scope", "", "\\x2d", "-")
|
||||
parsed.Pod = replacer.Replace(splits[2])
|
||||
if len(splits) == 3 {
|
||||
return parsed, nil
|
||||
}
|
||||
if splits[3] == "system.slice" {
|
||||
parsed.Container = strings.Replace(splits[4], ".service", "", -1)
|
||||
return parsed, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("%s not handled by rkt handler", name)
|
||||
}
|
||||
|
||||
// Gets a Rkt container's overlay upper dir
|
||||
func getRootFs(root string, parsed *parsedName) string {
|
||||
/* Example of where it stores the upper dir key
|
||||
for container
|
||||
/var/lib/rkt/pods/run/bc793ec6-c48f-4480-99b5-6bec16d52210/appsinfo/alpine-sh/treeStoreID
|
||||
for pod
|
||||
/var/lib/rkt/pods/run/f556b64a-17a7-47d7-93ec-ef2275c3d67e/stage1TreeStoreID
|
||||
|
||||
*/
|
||||
|
||||
var tree string
|
||||
if parsed.Container == "" {
|
||||
tree = path.Join(root, "pods/run", parsed.Pod, "stage1TreeStoreID")
|
||||
} else {
|
||||
tree = path.Join(root, "pods/run", parsed.Pod, "appsinfo", parsed.Container, "treeStoreID")
|
||||
}
|
||||
|
||||
bytes, err := ioutil.ReadFile(tree)
|
||||
if err != nil {
|
||||
glog.Infof("ReadFile failed, couldn't read %v to get upper dir: %v", tree, err)
|
||||
return ""
|
||||
}
|
||||
|
||||
s := string(bytes)
|
||||
|
||||
/* Example of where the upper dir is stored via key read above
|
||||
/var/lib/rkt/pods/run/bc793ec6-c48f-4480-99b5-6bec16d52210/overlay/deps-sha512-82a099e560a596662b15dec835e9adabab539cad1f41776a30195a01a8f2f22b/
|
||||
*/
|
||||
return path.Join(root, "pods/run", parsed.Pod, "overlay", s)
|
||||
}
|
Reference in New Issue
Block a user