Drop support for rkt - which is now archived
Change-Id: I4bc38990251fe12be521a242ff9b9c81e2d03501
This commit is contained in:
parent
b253b65835
commit
b35086151a
5
Godeps/Godeps.json
generated
5
Godeps/Godeps.json
generated
@ -241,11 +241,6 @@
|
|||||||
"Comment": "v2",
|
"Comment": "v2",
|
||||||
"Rev": "7f080b6c11ac2d2347c3cd7521e810207ea1a041"
|
"Rev": "7f080b6c11ac2d2347c3cd7521e810207ea1a041"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"ImportPath": "github.com/coreos/rkt/api/v1alpha",
|
|
||||||
"Comment": "v1.25.0",
|
|
||||||
"Rev": "ec37f3cb649bfb72408906e7cbf330e4aeda1075"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/cyphar/filepath-securejoin",
|
"ImportPath": "github.com/cyphar/filepath-securejoin",
|
||||||
"Comment": "v0.2.1-1-gae69057",
|
"Comment": "v0.2.1-1-gae69057",
|
||||||
|
@ -32,7 +32,6 @@ type ContainerType int
|
|||||||
const (
|
const (
|
||||||
ContainerTypeRaw ContainerType = iota
|
ContainerTypeRaw ContainerType = iota
|
||||||
ContainerTypeDocker
|
ContainerTypeDocker
|
||||||
ContainerTypeRkt
|
|
||||||
ContainerTypeSystemd
|
ContainerTypeSystemd
|
||||||
ContainerTypeCrio
|
ContainerTypeCrio
|
||||||
ContainerTypeContainerd
|
ContainerTypeContainerd
|
||||||
|
@ -20,6 +20,5 @@ import (
|
|||||||
_ "github.com/google/cadvisor/container/crio/install"
|
_ "github.com/google/cadvisor/container/crio/install"
|
||||||
_ "github.com/google/cadvisor/container/docker/install"
|
_ "github.com/google/cadvisor/container/docker/install"
|
||||||
_ "github.com/google/cadvisor/container/mesos/install"
|
_ "github.com/google/cadvisor/container/mesos/install"
|
||||||
_ "github.com/google/cadvisor/container/rkt/install"
|
|
||||||
_ "github.com/google/cadvisor/container/systemd/install"
|
_ "github.com/google/cadvisor/container/systemd/install"
|
||||||
)
|
)
|
||||||
|
@ -1,96 +0,0 @@
|
|||||||
// 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"
|
|
||||||
|
|
||||||
"github.com/blang/semver"
|
|
||||||
rktapi "github.com/coreos/rkt/api/v1alpha"
|
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
defaultRktAPIServiceAddr = "localhost:15441"
|
|
||||||
timeout = 2 * time.Second
|
|
||||||
minimumRktBinVersion = "1.6.0"
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
apisvc := rktapi.NewPublicAPIClient(apisvcConn)
|
|
||||||
|
|
||||||
resp, err := apisvc.GetInfo(context.Background(), &rktapi.GetInfoRequest{})
|
|
||||||
if err != nil {
|
|
||||||
rktClientErr = fmt.Errorf("rkt: GetInfo() failed: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
binVersion, err := semver.Make(resp.Info.RktVersion)
|
|
||||||
if err != nil {
|
|
||||||
rktClientErr = fmt.Errorf("rkt: couldn't parse RtVersion: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if binVersion.LT(semver.MustParse(minimumRktBinVersion)) {
|
|
||||||
rktClientErr = fmt.Errorf("rkt: binary version is too old(%v), requires at least %v", resp.Info.RktVersion, minimumRktBinVersion)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
rktClient = apisvc
|
|
||||||
})
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
// 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 (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/blang/semver"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestMinParse(t *testing.T) {
|
|
||||||
_, err := semver.Make(minimumRktBinVersion)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Couldn't parse the minimumRktBinVersion(%v): %v", minimumRktBinVersion, err)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,99 +0,0 @@
|
|||||||
// 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"
|
|
||||||
|
|
||||||
"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/google/cadvisor/watcher"
|
|
||||||
|
|
||||||
"k8s.io/klog"
|
|
||||||
)
|
|
||||||
|
|
||||||
const RktNamespace = "rkt"
|
|
||||||
|
|
||||||
type rktFactory struct {
|
|
||||||
machineInfoFactory info.MachineInfoFactory
|
|
||||||
|
|
||||||
cgroupSubsystems *libcontainer.CgroupSubsystems
|
|
||||||
|
|
||||||
fsInfo fs.FsInfo
|
|
||||||
|
|
||||||
includedMetrics 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.includedMetrics)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *rktFactory) CanHandleAndAccept(name string) (bool, bool, error) {
|
|
||||||
accept, err := verifyPod(name)
|
|
||||||
|
|
||||||
return accept, accept, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *rktFactory) DebugInfo() map[string][]string {
|
|
||||||
return map[string][]string{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Register(machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, includedMetrics 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(includedMetrics)
|
|
||||||
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")
|
|
||||||
}
|
|
||||||
|
|
||||||
klog.V(1).Infof("Registering Rkt factory")
|
|
||||||
factory := &rktFactory{
|
|
||||||
machineInfoFactory: machineInfoFactory,
|
|
||||||
fsInfo: fsInfo,
|
|
||||||
cgroupSubsystems: &cgroupSubsystems,
|
|
||||||
includedMetrics: includedMetrics,
|
|
||||||
rktPath: rktPath,
|
|
||||||
}
|
|
||||||
container.RegisterContainerHandlerFactory(factory, []watcher.ContainerWatchSource{watcher.Rkt})
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -1,280 +0,0 @@
|
|||||||
// 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"
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
cgroupfs "github.com/opencontainers/runc/libcontainer/cgroups/fs"
|
|
||||||
"github.com/opencontainers/runc/libcontainer/configs"
|
|
||||||
"k8s.io/klog"
|
|
||||||
)
|
|
||||||
|
|
||||||
type rktContainerHandler struct {
|
|
||||||
machineInfoFactory info.MachineInfoFactory
|
|
||||||
|
|
||||||
// Absolute path to the cgroup hierarchies of this container.
|
|
||||||
// (e.g.: "cpu" -> "/sys/fs/cgroup/cpu/test")
|
|
||||||
cgroupPaths map[string]string
|
|
||||||
|
|
||||||
fsInfo fs.FsInfo
|
|
||||||
|
|
||||||
isPod bool
|
|
||||||
|
|
||||||
rootfsStorageDir string
|
|
||||||
|
|
||||||
// Filesystem handler.
|
|
||||||
fsHandler common.FsHandler
|
|
||||||
|
|
||||||
includedMetrics container.MetricSet
|
|
||||||
|
|
||||||
apiPod *rktapi.Pod
|
|
||||||
|
|
||||||
labels map[string]string
|
|
||||||
|
|
||||||
reference info.ContainerReference
|
|
||||||
|
|
||||||
libcontainerHandler *libcontainer.Handler
|
|
||||||
}
|
|
||||||
|
|
||||||
func newRktContainerHandler(name string, rktClient rktapi.PublicAPIClient, rktPath string, cgroupSubsystems *libcontainer.CgroupSubsystems, machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, rootFs string, includedMetrics 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
|
|
||||||
}
|
|
||||||
annotations := resp.Pod.Annotations
|
|
||||||
if parsed.Container != "" { // As not empty string, an App container
|
|
||||||
if contAnnotations, ok := findAnnotations(resp.Pod.Apps, parsed.Container); !ok {
|
|
||||||
klog.Warningf("couldn't find app %v in pod", parsed.Container)
|
|
||||||
} else {
|
|
||||||
annotations = append(annotations, contAnnotations...)
|
|
||||||
}
|
|
||||||
} else { // The Pod container
|
|
||||||
pid = int(resp.Pod.Pid)
|
|
||||||
apiPod = resp.Pod
|
|
||||||
}
|
|
||||||
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,
|
|
||||||
}
|
|
||||||
|
|
||||||
libcontainerHandler := libcontainer.NewHandler(cgroupManager, rootFs, pid, includedMetrics)
|
|
||||||
|
|
||||||
rootfsStorageDir := getRootFs(rktPath, parsed)
|
|
||||||
|
|
||||||
containerReference := info.ContainerReference{
|
|
||||||
Name: name,
|
|
||||||
Aliases: aliases,
|
|
||||||
Namespace: RktNamespace,
|
|
||||||
}
|
|
||||||
|
|
||||||
handler := &rktContainerHandler{
|
|
||||||
machineInfoFactory: machineInfoFactory,
|
|
||||||
cgroupPaths: cgroupPaths,
|
|
||||||
fsInfo: fsInfo,
|
|
||||||
isPod: isPod,
|
|
||||||
rootfsStorageDir: rootfsStorageDir,
|
|
||||||
includedMetrics: includedMetrics,
|
|
||||||
apiPod: apiPod,
|
|
||||||
labels: labels,
|
|
||||||
reference: containerReference,
|
|
||||||
libcontainerHandler: libcontainerHandler,
|
|
||||||
}
|
|
||||||
|
|
||||||
if includedMetrics.Has(container.DiskUsageMetrics) {
|
|
||||||
handler.fsHandler = common.NewFsHandler(common.DefaultPeriod, 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 handler.reference, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (handler *rktContainerHandler) Start() {
|
|
||||||
handler.fsHandler.Start()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (handler *rktContainerHandler) Cleanup() {
|
|
||||||
handler.fsHandler.Stop()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (handler *rktContainerHandler) GetSpec() (info.ContainerSpec, error) {
|
|
||||||
hasNetwork := handler.isPod && handler.includedMetrics.Has(container.NetworkUsageMetrics)
|
|
||||||
hasFilesystem := handler.includedMetrics.Has(container.DiskUsageMetrics)
|
|
||||||
|
|
||||||
spec, err := common.GetSpec(handler.cgroupPaths, handler.machineInfoFactory, hasNetwork, hasFilesystem)
|
|
||||||
|
|
||||||
spec.Labels = handler.labels
|
|
||||||
|
|
||||||
return spec, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (handler *rktContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
|
||||||
mi, err := handler.machineInfoFactory.GetMachineInfo()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if handler.includedMetrics.Has(container.DiskIOMetrics) {
|
|
||||||
common.AssignDeviceNamesToDiskStats((*common.MachineInfoNamer)(mi), &stats.DiskIo)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !handler.includedMetrics.Has(container.DiskUsageMetrics) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
deviceInfo, err := handler.fsInfo.GetDirFsDevice(handler.rootfsStorageDir)
|
|
||||||
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}
|
|
||||||
|
|
||||||
usage := handler.fsHandler.Usage()
|
|
||||||
fsStat.BaseUsage = usage.BaseUsageBytes
|
|
||||||
fsStat.Usage = usage.TotalUsageBytes
|
|
||||||
fsStat.Inodes = usage.InodeUsage
|
|
||||||
|
|
||||||
stats.Filesystem = append(stats.Filesystem, fsStat)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (handler *rktContainerHandler) GetStats() (*info.ContainerStats, error) {
|
|
||||||
stats, err := handler.libcontainerHandler.GetStats()
|
|
||||||
if err != nil {
|
|
||||||
return stats, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get filesystem stats.
|
|
||||||
err = handler.getFsStats(stats)
|
|
||||||
if err != nil {
|
|
||||||
return stats, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return stats, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *rktContainerHandler) GetContainerIPAddress() string {
|
|
||||||
// attempt to return the ip address of the pod
|
|
||||||
// if a specific ip address of the pod could not be determined, return the system ip address
|
|
||||||
if self.isPod && len(self.apiPod.Networks) > 0 {
|
|
||||||
address := self.apiPod.Networks[0].Ipv4
|
|
||||||
if address != "" {
|
|
||||||
return address
|
|
||||||
} else {
|
|
||||||
return self.apiPod.Networks[0].Ipv6
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return "127.0.0.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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.reference.Name)
|
|
||||||
}
|
|
||||||
return path, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (handler *rktContainerHandler) GetContainerLabels() map[string]string {
|
|
||||||
return handler.labels
|
|
||||||
}
|
|
||||||
|
|
||||||
func (handler *rktContainerHandler) ListContainers(listType container.ListType) ([]info.ContainerReference, error) {
|
|
||||||
return common.ListContainers(handler.reference.Name, handler.cgroupPaths, listType)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (handler *rktContainerHandler) ListProcesses(listType container.ListType) ([]int, error) {
|
|
||||||
return handler.libcontainerHandler.GetProcesses()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (handler *rktContainerHandler) Exists() bool {
|
|
||||||
return common.CgroupExists(handler.cgroupPaths)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (handler *rktContainerHandler) Type() container.ContainerType {
|
|
||||||
return container.ContainerTypeRkt
|
|
||||||
}
|
|
@ -1,141 +0,0 @@
|
|||||||
// 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"
|
|
||||||
|
|
||||||
rktapi "github.com/coreos/rkt/api/v1alpha"
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
"k8s.io/klog"
|
|
||||||
)
|
|
||||||
|
|
||||||
type parsedName struct {
|
|
||||||
Pod string
|
|
||||||
Container string
|
|
||||||
}
|
|
||||||
|
|
||||||
func verifyPod(name string) (bool, error) {
|
|
||||||
pod, err := cgroupToPod(name)
|
|
||||||
|
|
||||||
if err != nil || pod == nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Anything handler can handle is also accepted.
|
|
||||||
// Accept cgroups that are sub the pod cgroup, except "system.slice"
|
|
||||||
// - "system.slice" doesn't contain any processes itself
|
|
||||||
accept := !strings.HasSuffix(name, "/system.slice")
|
|
||||||
|
|
||||||
return accept, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func cgroupToPod(name string) (*rktapi.Pod, error) {
|
|
||||||
rktClient, err := Client()
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("couldn't get rkt api service: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := rktClient.ListPods(context.Background(), &rktapi.ListPodsRequest{
|
|
||||||
Filters: []*rktapi.PodFilter{
|
|
||||||
{
|
|
||||||
States: []rktapi.PodState{rktapi.PodState_POD_STATE_RUNNING},
|
|
||||||
PodSubCgroups: []string{name},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to list pods: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(resp.Pods) == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(resp.Pods) != 1 {
|
|
||||||
return nil, fmt.Errorf("returned %d (expected 1) pods for cgroup %v", len(resp.Pods), name)
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp.Pods[0], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse cgroup name into a pod/container name struct
|
|
||||||
Example cgroup fs name
|
|
||||||
|
|
||||||
pod - /machine.slice/machine-rkt\\x2df556b64a\\x2d17a7\\x2d47d7\\x2d93ec\\x2def2275c3d67e.scope/
|
|
||||||
or /system.slice/k8s-..../
|
|
||||||
container under pod - /machine.slice/machine-rkt\\x2df556b64a\\x2d17a7\\x2d47d7\\x2d93ec\\x2def2275c3d67e.scope/system.slice/alpine-sh.service
|
|
||||||
or /system.slice/k8s-..../system.slice/pause.service
|
|
||||||
*/
|
|
||||||
func parseName(name string) (*parsedName, error) {
|
|
||||||
pod, err := cgroupToPod(name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("parseName: couldn't convert %v to a rkt pod: %v", name, err)
|
|
||||||
}
|
|
||||||
if pod == nil {
|
|
||||||
return nil, fmt.Errorf("parseName: didn't return a pod for %v", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
splits := strings.Split(name, "/")
|
|
||||||
|
|
||||||
parsed := &parsedName{}
|
|
||||||
|
|
||||||
if len(splits) == 3 || len(splits) == 5 {
|
|
||||||
parsed.Pod = pod.Id
|
|
||||||
|
|
||||||
if len(splits) == 5 {
|
|
||||||
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 {
|
|
||||||
klog.Errorf("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)
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
// Copyright 2019 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.
|
|
||||||
|
|
||||||
// The install package registers rkt.NewPlugin() as the "rkt" container provider when imported
|
|
||||||
package install
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/google/cadvisor/container"
|
|
||||||
"github.com/google/cadvisor/container/rkt"
|
|
||||||
"k8s.io/klog"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
err := container.RegisterPlugin("rkt", rkt.NewPlugin())
|
|
||||||
if err != nil {
|
|
||||||
klog.Fatalf("Failed to register rkt plugin: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
// Copyright 2019 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 (
|
|
||||||
"github.com/google/cadvisor/container"
|
|
||||||
"github.com/google/cadvisor/fs"
|
|
||||||
info "github.com/google/cadvisor/info/v1"
|
|
||||||
"github.com/google/cadvisor/watcher"
|
|
||||||
"k8s.io/klog"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewPlugin returns an implementation of container.Plugin suitable for passing to container.RegisterPlugin()
|
|
||||||
func NewPlugin() container.Plugin {
|
|
||||||
return &plugin{}
|
|
||||||
}
|
|
||||||
|
|
||||||
type plugin struct{}
|
|
||||||
|
|
||||||
func (p *plugin) InitializeFSContext(context *fs.Context) error {
|
|
||||||
if tmpRktPath, err := RktPath(); err != nil {
|
|
||||||
klog.V(5).Infof("Rkt not connected: %v", err)
|
|
||||||
} else {
|
|
||||||
context.RktPath = tmpRktPath
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *plugin) Register(factory info.MachineInfoFactory, fsInfo fs.FsInfo, includedMetrics container.MetricSet) (watcher.ContainerWatcher, error) {
|
|
||||||
err := Register(factory, fsInfo, includedMetrics)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return NewRktContainerWatcher()
|
|
||||||
}
|
|
@ -1,153 +0,0 @@
|
|||||||
// 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 implements the watcher interface for rkt
|
|
||||||
package rkt
|
|
||||||
|
|
||||||
import (
|
|
||||||
"path/filepath"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/google/cadvisor/watcher"
|
|
||||||
|
|
||||||
rktapi "github.com/coreos/rkt/api/v1alpha"
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
"k8s.io/klog"
|
|
||||||
)
|
|
||||||
|
|
||||||
type rktContainerWatcher struct {
|
|
||||||
// Signal for watcher thread to stop.
|
|
||||||
stopWatcher chan error
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRktContainerWatcher() (watcher.ContainerWatcher, error) {
|
|
||||||
watcher := &rktContainerWatcher{
|
|
||||||
stopWatcher: make(chan error),
|
|
||||||
}
|
|
||||||
|
|
||||||
return watcher, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *rktContainerWatcher) Start(events chan watcher.ContainerEvent) error {
|
|
||||||
go self.detectRktContainers(events)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *rktContainerWatcher) Stop() error {
|
|
||||||
// Rendezvous with the watcher thread.
|
|
||||||
self.stopWatcher <- nil
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *rktContainerWatcher) detectRktContainers(events chan watcher.ContainerEvent) {
|
|
||||||
klog.V(1).Infof("Starting detectRktContainers thread")
|
|
||||||
ticker := time.Tick(10 * time.Second)
|
|
||||||
curpods := make(map[string]*rktapi.Pod)
|
|
||||||
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-ticker:
|
|
||||||
pods, err := listRunningPods()
|
|
||||||
if err != nil {
|
|
||||||
klog.Errorf("detectRktContainers: listRunningPods failed: %v", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
curpods = self.syncRunningPods(pods, events, curpods)
|
|
||||||
|
|
||||||
case <-self.stopWatcher:
|
|
||||||
klog.Infof("Exiting rktContainer Thread")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *rktContainerWatcher) syncRunningPods(pods []*rktapi.Pod, events chan watcher.ContainerEvent, curpods map[string]*rktapi.Pod) map[string]*rktapi.Pod {
|
|
||||||
newpods := make(map[string]*rktapi.Pod)
|
|
||||||
|
|
||||||
for _, pod := range pods {
|
|
||||||
newpods[pod.Id] = pod
|
|
||||||
// if pods become mutable, have to handle this better
|
|
||||||
if _, ok := curpods[pod.Id]; !ok {
|
|
||||||
// should create all cgroups not including system.slice
|
|
||||||
// i.e. /system.slice/rkt-test.service and /system.slice/rkt-test.service/system.slice/pause.service
|
|
||||||
for _, cgroup := range podToCgroup(pod) {
|
|
||||||
self.sendUpdateEvent(cgroup, events)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for id, pod := range curpods {
|
|
||||||
if _, ok := newpods[id]; !ok {
|
|
||||||
for _, cgroup := range podToCgroup(pod) {
|
|
||||||
klog.V(2).Infof("cgroup to delete = %v", cgroup)
|
|
||||||
self.sendDestroyEvent(cgroup, events)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return newpods
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *rktContainerWatcher) sendUpdateEvent(cgroup string, events chan watcher.ContainerEvent) {
|
|
||||||
events <- watcher.ContainerEvent{
|
|
||||||
EventType: watcher.ContainerAdd,
|
|
||||||
Name: cgroup,
|
|
||||||
WatchSource: watcher.Rkt,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *rktContainerWatcher) sendDestroyEvent(cgroup string, events chan watcher.ContainerEvent) {
|
|
||||||
events <- watcher.ContainerEvent{
|
|
||||||
EventType: watcher.ContainerDelete,
|
|
||||||
Name: cgroup,
|
|
||||||
WatchSource: watcher.Rkt,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func listRunningPods() ([]*rktapi.Pod, error) {
|
|
||||||
client, err := Client()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := client.ListPods(context.Background(), &rktapi.ListPodsRequest{
|
|
||||||
// Specify the request: Fetch and print only running pods and their details.
|
|
||||||
Detail: true,
|
|
||||||
Filters: []*rktapi.PodFilter{
|
|
||||||
{
|
|
||||||
States: []rktapi.PodState{rktapi.PodState_POD_STATE_RUNNING},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return resp.Pods, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func podToCgroup(pod *rktapi.Pod) []string {
|
|
||||||
cgroups := make([]string, 1+len(pod.Apps), 1+len(pod.Apps))
|
|
||||||
|
|
||||||
baseCgroup := pod.Cgroup
|
|
||||||
cgroups[0] = baseCgroup
|
|
||||||
|
|
||||||
for i, app := range pod.Apps {
|
|
||||||
cgroups[i+1] = filepath.Join(baseCgroup, "system.slice", app.Name+".service")
|
|
||||||
}
|
|
||||||
|
|
||||||
return cgroups
|
|
||||||
}
|
|
16
fs/fs.go
16
fs/fs.go
@ -41,7 +41,6 @@ import (
|
|||||||
const (
|
const (
|
||||||
LabelSystemRoot = "root"
|
LabelSystemRoot = "root"
|
||||||
LabelDockerImages = "docker-images"
|
LabelDockerImages = "docker-images"
|
||||||
LabelRktImages = "rkt-images"
|
|
||||||
LabelCrioImages = "crio-images"
|
LabelCrioImages = "crio-images"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -118,7 +117,6 @@ func NewFsInfo(context Context) (FsInfo, error) {
|
|||||||
fsInfo.mounts[mount.Mountpoint] = mount
|
fsInfo.mounts[mount.Mountpoint] = mount
|
||||||
}
|
}
|
||||||
|
|
||||||
fsInfo.addRktImagesLabel(context, mounts)
|
|
||||||
// need to call this before the log line below printing out the partitions, as this function may
|
// need to call this before the log line below printing out the partitions, as this function may
|
||||||
// add a "partition" for devicemapper to fsInfo.partitions
|
// add a "partition" for devicemapper to fsInfo.partitions
|
||||||
fsInfo.addDockerImagesLabel(context, mounts)
|
fsInfo.addDockerImagesLabel(context, mounts)
|
||||||
@ -296,20 +294,6 @@ func (self *RealFsInfo) addCrioImagesLabel(context Context, mounts []*mount.Info
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *RealFsInfo) addRktImagesLabel(context Context, mounts []*mount.Info) {
|
|
||||||
if context.RktPath != "" {
|
|
||||||
rktPath := context.RktPath
|
|
||||||
rktImagesPaths := map[string]struct{}{
|
|
||||||
"/": {},
|
|
||||||
}
|
|
||||||
for rktPath != "/" && rktPath != "." {
|
|
||||||
rktImagesPaths[rktPath] = struct{}{}
|
|
||||||
rktPath = filepath.Dir(rktPath)
|
|
||||||
}
|
|
||||||
self.updateContainerImagesPath(LabelRktImages, mounts, rktImagesPaths)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate a list of possible mount points for docker image management from the docker root directory.
|
// Generate a list of possible mount points for docker image management from the docker root directory.
|
||||||
// Right now, we look for each type of supported graph driver directories, but we can do better by parsing
|
// Right now, we look for each type of supported graph driver directories, but we can do better by parsing
|
||||||
// some of the context from `docker info`.
|
// some of the context from `docker info`.
|
||||||
|
@ -20,9 +20,8 @@ import (
|
|||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
// docker root directory.
|
// docker root directory.
|
||||||
Docker DockerContext
|
Docker DockerContext
|
||||||
RktPath string
|
Crio CrioContext
|
||||||
Crio CrioContext
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DockerContext struct {
|
type DockerContext struct {
|
||||||
|
@ -1121,9 +1121,6 @@ func (self *manager) watchForNewContainers(quit chan error) error {
|
|||||||
switch {
|
switch {
|
||||||
case event.EventType == watcher.ContainerAdd:
|
case event.EventType == watcher.ContainerAdd:
|
||||||
switch event.WatchSource {
|
switch event.WatchSource {
|
||||||
// the Rkt and Raw watchers can race, and if Raw wins, we want Rkt to override and create a new handler for Rkt containers
|
|
||||||
case watcher.Rkt:
|
|
||||||
err = self.overrideContainer(event.Name, event.WatchSource)
|
|
||||||
default:
|
default:
|
||||||
err = self.createContainer(event.Name, event.WatchSource)
|
err = self.createContainer(event.Name, event.WatchSource)
|
||||||
}
|
}
|
||||||
|
201
vendor/github.com/coreos/rkt/LICENSE
generated
vendored
201
vendor/github.com/coreos/rkt/LICENSE
generated
vendored
@ -1,201 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction,
|
|
||||||
and distribution as defined by Sections 1 through 9 of this document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by
|
|
||||||
the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all
|
|
||||||
other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition,
|
|
||||||
"control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or
|
|
||||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity
|
|
||||||
exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications,
|
|
||||||
including but not limited to software source code, documentation
|
|
||||||
source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical
|
|
||||||
transformation or translation of a Source form, including but
|
|
||||||
not limited to compiled object code, generated documentation,
|
|
||||||
and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or
|
|
||||||
Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work
|
|
||||||
(an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object
|
|
||||||
form, that is based on (or derived from) the Work and for which the
|
|
||||||
editorial revisions, annotations, elaborations, or other modifications
|
|
||||||
represent, as a whole, an original work of authorship. For the purposes
|
|
||||||
of this License, Derivative Works shall not include works that remain
|
|
||||||
separable from, or merely link (or bind by name) to the interfaces of,
|
|
||||||
the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including
|
|
||||||
the original version of the Work and any modifications or additions
|
|
||||||
to that Work or Derivative Works thereof, that is intentionally
|
|
||||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of
|
|
||||||
the copyright owner. For the purposes of this definition, "submitted"
|
|
||||||
means any form of electronic, verbal, or written communication sent
|
|
||||||
to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems,
|
|
||||||
and issue tracking systems that are managed by, or on behalf of, the
|
|
||||||
Licensor for the purpose of discussing and improving the Work, but
|
|
||||||
excluding communication that is conspicuously marked or otherwise
|
|
||||||
designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
||||||
on behalf of whom a Contribution has been received by Licensor and
|
|
||||||
subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
copyright license to reproduce, prepare Derivative Works of,
|
|
||||||
publicly display, publicly perform, sublicense, and distribute the
|
|
||||||
Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of
|
|
||||||
this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
||||||
(except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
||||||
where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their
|
|
||||||
Contribution(s) alone or by combination of their Contribution(s)
|
|
||||||
with the Work to which such Contribution(s) was submitted. If You
|
|
||||||
institute patent litigation against any entity (including a
|
|
||||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
||||||
or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses
|
|
||||||
granted to You under this License for that Work shall terminate
|
|
||||||
as of the date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the
|
|
||||||
Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You
|
|
||||||
meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or
|
|
||||||
Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices
|
|
||||||
stating that You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works
|
|
||||||
that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work,
|
|
||||||
excluding those notices that do not pertain to any part of
|
|
||||||
the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its
|
|
||||||
distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained
|
|
||||||
within such NOTICE file, excluding those notices that do not
|
|
||||||
pertain to any part of the Derivative Works, in at least one
|
|
||||||
of the following places: within a NOTICE text file distributed
|
|
||||||
as part of the Derivative Works; within the Source form or
|
|
||||||
documentation, if provided along with the Derivative Works; or,
|
|
||||||
within a display generated by the Derivative Works, if and
|
|
||||||
wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and
|
|
||||||
do not modify the License. You may add Your own attribution
|
|
||||||
notices within Derivative Works that You distribute, alongside
|
|
||||||
or as an addendum to the NOTICE text from the Work, provided
|
|
||||||
that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and
|
|
||||||
may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or
|
|
||||||
for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with
|
|
||||||
the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
||||||
any Contribution intentionally submitted for inclusion in the Work
|
|
||||||
by You to the Licensor shall be under the terms and conditions of
|
|
||||||
this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify
|
|
||||||
the terms of any separate license agreement you may have executed
|
|
||||||
with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade
|
|
||||||
names, trademarks, service marks, or product names of the Licensor,
|
|
||||||
except as required for reasonable and customary use in describing the
|
|
||||||
origin of the Work and reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
||||||
agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions
|
|
||||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
||||||
appropriateness of using or redistributing the Work and assume any
|
|
||||||
risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory,
|
|
||||||
whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly
|
|
||||||
negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special,
|
|
||||||
incidental, or consequential damages of any character arising as a
|
|
||||||
result of this License or out of the use or inability to use the
|
|
||||||
Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all
|
|
||||||
other commercial damages or losses), even if such Contributor
|
|
||||||
has been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing
|
|
||||||
the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
||||||
or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only
|
|
||||||
on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify,
|
|
||||||
defend, and hold each Contributor harmless for any liability
|
|
||||||
incurred by, or claims asserted against, such Contributor by reason
|
|
||||||
of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
||||||
replaced with your own identifying information. (Don't include
|
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
|
||||||
comment syntax for the file format. We also recommend that a
|
|
||||||
file or class name and description of purpose be included on the
|
|
||||||
same "printed page" as the copyright notice for easier
|
|
||||||
identification within third-party archives.
|
|
||||||
|
|
||||||
Copyright {yyyy} {name of copyright owner}
|
|
||||||
|
|
||||||
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.
|
|
21
vendor/github.com/coreos/rkt/api/v1alpha/README.md
generated
vendored
21
vendor/github.com/coreos/rkt/api/v1alpha/README.md
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
# WARNING
|
|
||||||
|
|
||||||
The API defined here is proposed, experimental, and (for now) subject to change at any time.
|
|
||||||
|
|
||||||
If you think you want to use it, or for any other queries, contact <rkt-dev@googlegroups.com> or file an [issue](https://github.com/coreos/rkt/issues/new)
|
|
||||||
|
|
||||||
For more information, see:
|
|
||||||
- #1208
|
|
||||||
- #1359
|
|
||||||
- #1468
|
|
||||||
- [API Service Subcommand](../../Documentation/subcommands/api-service.md)
|
|
||||||
|
|
||||||
## Protobuf
|
|
||||||
|
|
||||||
The rkt gRPC API uses Protocol Buffers for its services.
|
|
||||||
In order to rebuild the generated code make sure you have protobuf 3.0.0 installed (https://github.com/google/protobuf)
|
|
||||||
and execute from the top-level directory:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ make protobuf
|
|
||||||
```
|
|
1775
vendor/github.com/coreos/rkt/api/v1alpha/api.pb.go
generated
vendored
1775
vendor/github.com/coreos/rkt/api/v1alpha/api.pb.go
generated
vendored
File diff suppressed because it is too large
Load Diff
487
vendor/github.com/coreos/rkt/api/v1alpha/api.proto
generated
vendored
487
vendor/github.com/coreos/rkt/api/v1alpha/api.proto
generated
vendored
@ -1,487 +0,0 @@
|
|||||||
// Copyright 2015 The rkt Authors
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
// *************************************************** //
|
|
||||||
// ************ WARNING - HERE BE DRAGONS ************ //
|
|
||||||
// //
|
|
||||||
// The API defined here is proposed, experimental, //
|
|
||||||
// and (for now) subject to change at any time. //
|
|
||||||
// //
|
|
||||||
// If you think you want to use it, or for any other //
|
|
||||||
// queries, contact <rkt-dev@googlegroups.com> //
|
|
||||||
// or file an issue on github.com/coreos/rkt //
|
|
||||||
// //
|
|
||||||
// *************************************************** //
|
|
||||||
// ****************** END WARNING ******************** //
|
|
||||||
|
|
||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package v1alpha;
|
|
||||||
|
|
||||||
// ImageType defines the supported image type.
|
|
||||||
enum ImageType {
|
|
||||||
IMAGE_TYPE_UNDEFINED = 0;
|
|
||||||
IMAGE_TYPE_APPC = 1;
|
|
||||||
IMAGE_TYPE_DOCKER = 2;
|
|
||||||
IMAGE_TYPE_OCI = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageFormat defines the format of the image.
|
|
||||||
message ImageFormat {
|
|
||||||
// Type of the image, required.
|
|
||||||
ImageType type = 1;
|
|
||||||
|
|
||||||
// Version of the image format, required.
|
|
||||||
string version = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Image describes the image's information.
|
|
||||||
message Image {
|
|
||||||
// Base format of the image, required. This indicates the original format
|
|
||||||
// for the image as nowadays all the image formats will be transformed to
|
|
||||||
// ACI.
|
|
||||||
ImageFormat base_format = 1;
|
|
||||||
|
|
||||||
// ID of the image, a string that can be used to uniquely identify the image,
|
|
||||||
// e.g. sha512 hash of the ACIs, required.
|
|
||||||
string id = 2;
|
|
||||||
|
|
||||||
// Name of the image in the image manifest, e.g. 'coreos.com/etcd', optional.
|
|
||||||
string name = 3;
|
|
||||||
|
|
||||||
// Version of the image, e.g. 'latest', '2.0.10', optional.
|
|
||||||
string version = 4;
|
|
||||||
|
|
||||||
// Timestamp of when the image is imported, it is the seconds since epoch, optional.
|
|
||||||
int64 import_timestamp = 5;
|
|
||||||
|
|
||||||
// JSON-encoded byte array that represents the image manifest, optional.
|
|
||||||
bytes manifest = 6;
|
|
||||||
|
|
||||||
// Size is the size in bytes of this image in the store.
|
|
||||||
int64 size = 7;
|
|
||||||
|
|
||||||
// Annotations on this image.
|
|
||||||
repeated KeyValue annotations = 8;
|
|
||||||
|
|
||||||
// Labels of this image.
|
|
||||||
repeated KeyValue labels = 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Network describes the network information of a pod.
|
|
||||||
message Network {
|
|
||||||
// Name of the network that a pod belongs to, required.
|
|
||||||
string name = 1;
|
|
||||||
|
|
||||||
// Pod's IPv4 address within the network, optional if IPv6 address is given.
|
|
||||||
string ipv4 = 2;
|
|
||||||
|
|
||||||
// Pod's IPv6 address within the network, optional if IPv4 address is given.
|
|
||||||
string ipv6 = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// AppState defines the possible states of the app.
|
|
||||||
enum AppState {
|
|
||||||
APP_STATE_UNDEFINED = 0;
|
|
||||||
APP_STATE_RUNNING = 1;
|
|
||||||
APP_STATE_EXITED = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// App describes the information of an app that's running in a pod.
|
|
||||||
message App {
|
|
||||||
// Name of the app, required.
|
|
||||||
string name = 1;
|
|
||||||
|
|
||||||
// Image used by the app, required. However, this may only contain the image id
|
|
||||||
// if it is returned by ListPods().
|
|
||||||
Image image = 2;
|
|
||||||
|
|
||||||
// State of the app. optional, non-empty only if it's returned by InspectPod().
|
|
||||||
AppState state = 3;
|
|
||||||
|
|
||||||
// Exit code of the app. optional, only valid if it's returned by InspectPod() and
|
|
||||||
// the app has already exited.
|
|
||||||
sint32 exit_code = 4;
|
|
||||||
|
|
||||||
// Annotations for this app.
|
|
||||||
repeated KeyValue annotations = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodState defines the possible states of the pod.
|
|
||||||
// See https://github.com/coreos/rkt/blob/master/Documentation/devel/pod-lifecycle.md for a detailed
|
|
||||||
// explanation of each state.
|
|
||||||
enum PodState {
|
|
||||||
POD_STATE_UNDEFINED = 0;
|
|
||||||
|
|
||||||
// States before the pod is running.
|
|
||||||
POD_STATE_EMBRYO = 1; // Pod is created, ready to entering 'preparing' state.
|
|
||||||
POD_STATE_PREPARING = 2; // Pod is being prepared. On success it will become 'prepared', otherwise it will become 'aborted prepared'.
|
|
||||||
POD_STATE_PREPARED = 3; // Pod has been successfully prepared, ready to enter 'running' state. it can also enter 'deleting' if it's garbage collected before running.
|
|
||||||
|
|
||||||
// State that indicates the pod is running.
|
|
||||||
POD_STATE_RUNNING = 4; // Pod is running, when it exits, it will become 'exited'.
|
|
||||||
|
|
||||||
// States that indicates the pod is exited, and will never run.
|
|
||||||
POD_STATE_ABORTED_PREPARE = 5; // Pod failed to prepare, it will only be garbage collected and will never run again.
|
|
||||||
POD_STATE_EXITED = 6; // Pod has exited, it now can be garbage collected.
|
|
||||||
POD_STATE_DELETING = 7; // Pod is being garbage collected, after that it will enter 'garbage' state.
|
|
||||||
POD_STATE_GARBAGE = 8; // Pod is marked as garbage collected, it no longer exists on the machine.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pod describes a pod's information.
|
|
||||||
// If a pod is in Embryo, Preparing, AbortedPrepare state,
|
|
||||||
// only id and state will be returned.
|
|
||||||
//
|
|
||||||
// If a pod is in other states, the pod manifest and
|
|
||||||
// apps will be returned when 'detailed' is true in the request.
|
|
||||||
//
|
|
||||||
// A valid pid of the stage1 process of the pod will be returned
|
|
||||||
// if the pod is Running has run once.
|
|
||||||
//
|
|
||||||
// Networks are only returned when a pod is in Running.
|
|
||||||
message Pod {
|
|
||||||
// ID of the pod, in the form of a UUID.
|
|
||||||
string id = 1;
|
|
||||||
|
|
||||||
// PID of the stage1 process of the pod.
|
|
||||||
sint32 pid = 2;
|
|
||||||
|
|
||||||
// State of the pod.
|
|
||||||
PodState state = 3;
|
|
||||||
|
|
||||||
// List of apps in the pod.
|
|
||||||
repeated App apps = 4;
|
|
||||||
|
|
||||||
// Network information of the pod.
|
|
||||||
// Note that a pod can be in multiple networks.
|
|
||||||
repeated Network networks = 5;
|
|
||||||
|
|
||||||
// JSON-encoded byte array that represents the pod manifest of the pod.
|
|
||||||
bytes manifest = 6;
|
|
||||||
|
|
||||||
// Annotations on this pod.
|
|
||||||
repeated KeyValue annotations = 7;
|
|
||||||
|
|
||||||
// Cgroup of the pod, empty if the pod is not running.
|
|
||||||
string cgroup = 8;
|
|
||||||
|
|
||||||
// Timestamp of when the pod is created, nanoseconds since epoch.
|
|
||||||
// Zero if the pod is not created.
|
|
||||||
int64 created_at = 9;
|
|
||||||
|
|
||||||
// Timestamp of when the pod is started, nanoseconds since epoch.
|
|
||||||
// Zero if the pod is not started.
|
|
||||||
int64 started_at = 10;
|
|
||||||
|
|
||||||
// Timestamp of when the pod is moved to exited-garbage/garbage,
|
|
||||||
// in nanoseconds since epoch.
|
|
||||||
// Zero if the pod is not moved to exited-garbage/garbage yet.
|
|
||||||
int64 gc_marked_at = 11;
|
|
||||||
}
|
|
||||||
|
|
||||||
message KeyValue {
|
|
||||||
// Key part of the key-value pair.
|
|
||||||
string Key = 1;
|
|
||||||
// Value part of the key-value pair.
|
|
||||||
string value = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PodFilter defines the condition that the returned pods need to satisfy in ListPods().
|
|
||||||
// The conditions are combined by 'AND', and different filters are combined by 'OR'.
|
|
||||||
message PodFilter {
|
|
||||||
// If not empty, the pods that have any of the ids will be returned.
|
|
||||||
repeated string ids = 1;
|
|
||||||
|
|
||||||
// If not empty, the pods that have any of the states will be returned.
|
|
||||||
repeated PodState states = 2;
|
|
||||||
|
|
||||||
// If not empty, the pods that all of the apps will be returned.
|
|
||||||
repeated string app_names = 3;
|
|
||||||
|
|
||||||
// If not empty, the pods that have all of the images(in the apps) will be returned
|
|
||||||
repeated string image_ids = 4;
|
|
||||||
|
|
||||||
// If not empty, the pods that are in all of the networks will be returned.
|
|
||||||
repeated string network_names = 5;
|
|
||||||
|
|
||||||
// If not empty, the pods that have all of the annotations will be returned.
|
|
||||||
repeated KeyValue annotations = 6;
|
|
||||||
|
|
||||||
// If not empty, the pods whose cgroup are listed will be returned.
|
|
||||||
repeated string cgroups = 7;
|
|
||||||
|
|
||||||
// If not empty, the pods whose these cgroup belong to will be returned.
|
|
||||||
// i.e. the pod's cgroup is a prefix of the specified cgroup
|
|
||||||
repeated string pod_sub_cgroups = 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImageFilter defines the condition that the returned images need to satisfy in ListImages().
|
|
||||||
// The conditions are combined by 'AND', and different filters are combined by 'OR'.
|
|
||||||
message ImageFilter {
|
|
||||||
// If not empty, the images that have any of the ids will be returned.
|
|
||||||
repeated string ids = 1;
|
|
||||||
|
|
||||||
// if not empty, the images that have any of the prefixes in the name will be returned.
|
|
||||||
repeated string prefixes = 2;
|
|
||||||
|
|
||||||
// If not empty, the images that have any of the base names will be returned.
|
|
||||||
// For example, both 'coreos.com/etcd' and 'k8s.io/etcd' will be returned if 'etcd' is included,
|
|
||||||
// however 'k8s.io/etcd-backup' will not be returned.
|
|
||||||
repeated string base_names = 3;
|
|
||||||
|
|
||||||
// If not empty, the images that have any of the keywords in the name will be returned.
|
|
||||||
// For example, both 'kubernetes-etcd', 'etcd:latest' will be returned if 'etcd' is included,
|
|
||||||
repeated string keywords = 4;
|
|
||||||
|
|
||||||
// If not empty, the images that have all of the labels will be returned.
|
|
||||||
repeated KeyValue labels = 5;
|
|
||||||
|
|
||||||
// If set, the images that are imported after this timestamp will be returned.
|
|
||||||
int64 imported_after = 6;
|
|
||||||
|
|
||||||
// If set, the images that are imported before this timestamp will be returned.
|
|
||||||
int64 imported_before = 7;
|
|
||||||
|
|
||||||
// If not empty, the images that have all of the annotations will be returned.
|
|
||||||
repeated KeyValue annotations = 8;
|
|
||||||
|
|
||||||
// If not empty, the images that have any of the exact full names will be returned.
|
|
||||||
repeated string full_names = 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GlobalFlags describes the flags that passed to rkt api service when it is launched.
|
|
||||||
message GlobalFlags {
|
|
||||||
// Data directory.
|
|
||||||
string dir = 1;
|
|
||||||
|
|
||||||
// System configuration directory.
|
|
||||||
string system_config_dir = 2;
|
|
||||||
|
|
||||||
// Local configuration directory.
|
|
||||||
string local_config_dir = 3;
|
|
||||||
|
|
||||||
// User configuration directory.
|
|
||||||
string user_config_dir = 4;
|
|
||||||
|
|
||||||
// Insecure flags configurates what security features to disable.
|
|
||||||
string insecure_flags = 5;
|
|
||||||
|
|
||||||
// Whether to automatically trust gpg keys fetched from https
|
|
||||||
bool trust_keys_from_https = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Info describes the information of rkt on the machine.
|
|
||||||
message Info {
|
|
||||||
// Version of rkt, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/).
|
|
||||||
string rkt_version = 1;
|
|
||||||
|
|
||||||
// Version of appc, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/).
|
|
||||||
string appc_version = 2;
|
|
||||||
|
|
||||||
// Latest version of the api that's supported by the service, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/).
|
|
||||||
string api_version = 3;
|
|
||||||
|
|
||||||
// The global flags that passed to the rkt api service when it's launched.
|
|
||||||
GlobalFlags global_flags = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
// EventType defines the type of the events that will be received via ListenEvents().
|
|
||||||
enum EventType {
|
|
||||||
EVENT_TYPE_UNDEFINED = 0;
|
|
||||||
|
|
||||||
// Pod events.
|
|
||||||
EVENT_TYPE_POD_PREPARED = 1;
|
|
||||||
EVENT_TYPE_POD_PREPARE_ABORTED = 2;
|
|
||||||
EVENT_TYPE_POD_STARTED = 3;
|
|
||||||
EVENT_TYPE_POD_EXITED = 4;
|
|
||||||
EVENT_TYPE_POD_GARBAGE_COLLECTED = 5;
|
|
||||||
|
|
||||||
// App events.
|
|
||||||
EVENT_TYPE_APP_STARTED = 6;
|
|
||||||
EVENT_TYPE_APP_EXITED = 7; // (XXX)yifan: Maybe also return exit code in the event object?
|
|
||||||
|
|
||||||
// Image events.
|
|
||||||
EVENT_TYPE_IMAGE_IMPORTED = 8;
|
|
||||||
EVENT_TYPE_IMAGE_REMOVED = 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event describes the events that will be received via ListenEvents().
|
|
||||||
message Event {
|
|
||||||
// Type of the event, required.
|
|
||||||
EventType type = 1;
|
|
||||||
|
|
||||||
// ID of the subject that causes the event, required.
|
|
||||||
// If the event is a pod or app event, the id is the pod's uuid.
|
|
||||||
// If the event is an image event, the id is the image's id.
|
|
||||||
string id = 2;
|
|
||||||
|
|
||||||
// Name of the subject that causes the event, required.
|
|
||||||
// If the event is a pod event, the name is the pod's name.
|
|
||||||
// If the event is an app event, the name is the app's name.
|
|
||||||
// If the event is an image event, the name is the image's name.
|
|
||||||
string from = 3;
|
|
||||||
|
|
||||||
// Timestamp of when the event happens, it is the seconds since epoch, required.
|
|
||||||
int64 time = 4;
|
|
||||||
|
|
||||||
// Data of the event, in the form of key-value pairs, optional.
|
|
||||||
repeated KeyValue data = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
// EventFilter defines the condition that the returned events needs to satisfy in ListImages().
|
|
||||||
// The condition are combined by 'AND'.
|
|
||||||
message EventFilter {
|
|
||||||
// If not empty, then only returns the events that have the listed types.
|
|
||||||
repeated EventType types = 1;
|
|
||||||
|
|
||||||
// If not empty, then only returns the events whose 'id' is included in the listed ids.
|
|
||||||
repeated string ids = 2;
|
|
||||||
|
|
||||||
// If not empty, then only returns the events whose 'from' is included in the listed names.
|
|
||||||
repeated string names = 3;
|
|
||||||
|
|
||||||
// If set, then only returns the events after this timestamp.
|
|
||||||
// If the server starts after since_time, then only the events happened after the start of the server will be returned.
|
|
||||||
// If since_time is a future timestamp, then no events will be returned until that time.
|
|
||||||
int64 since_time = 4;
|
|
||||||
|
|
||||||
// If set, then only returns the events before this timestamp.
|
|
||||||
// If it is a future timestamp, then the event stream will be closed at that moment.
|
|
||||||
int64 until_time = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request for GetInfo().
|
|
||||||
message GetInfoRequest {}
|
|
||||||
|
|
||||||
// Response for GetInfo().
|
|
||||||
message GetInfoResponse {
|
|
||||||
Info info = 1; // Required.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request for ListPods().
|
|
||||||
message ListPodsRequest {
|
|
||||||
repeated PodFilter filters = 1; // Optional.
|
|
||||||
bool detail = 2; // Optional.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Response for ListPods().
|
|
||||||
message ListPodsResponse {
|
|
||||||
repeated Pod pods = 1; // Required.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request for InspectPod().
|
|
||||||
message InspectPodRequest {
|
|
||||||
// ID of the pod which we are querying status for, required.
|
|
||||||
string id = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Response for InspectPod().
|
|
||||||
message InspectPodResponse {
|
|
||||||
Pod pod = 1; // Required.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request for ListImages().
|
|
||||||
message ListImagesRequest {
|
|
||||||
repeated ImageFilter filters = 1; // Optional.
|
|
||||||
bool detail = 2; // Optional.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Response for ListImages().
|
|
||||||
message ListImagesResponse {
|
|
||||||
repeated Image images = 1; // Required.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request for InspectImage().
|
|
||||||
message InspectImageRequest {
|
|
||||||
string id = 1; // Required.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Response for InspectImage().
|
|
||||||
message InspectImageResponse {
|
|
||||||
Image image = 1; // Required.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request for ListenEvents().
|
|
||||||
message ListenEventsRequest {
|
|
||||||
EventFilter filter = 1; // Optional.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Response for ListenEvents().
|
|
||||||
message ListenEventsResponse {
|
|
||||||
// Aggregate multiple events to reduce round trips, optional as the response can contain no events.
|
|
||||||
repeated Event events = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request for GetLogs().
|
|
||||||
message GetLogsRequest {
|
|
||||||
// ID of the pod which we will get logs from, required.
|
|
||||||
string pod_id = 1;
|
|
||||||
|
|
||||||
// Name of the app within the pod which we will get logs
|
|
||||||
// from, optional. If not set, then the logs of all the
|
|
||||||
// apps within the pod will be returned.
|
|
||||||
string app_name = 2;
|
|
||||||
|
|
||||||
// Number of most recent lines to return, optional.
|
|
||||||
int32 lines = 3;
|
|
||||||
|
|
||||||
// If true, then a response stream will not be closed,
|
|
||||||
// and new log response will be sent via the stream, default is false.
|
|
||||||
bool follow = 4;
|
|
||||||
|
|
||||||
// If set, then only the logs after the timestamp will
|
|
||||||
// be returned, optional.
|
|
||||||
int64 since_time = 5;
|
|
||||||
|
|
||||||
// If set, then only the logs before the timestamp will
|
|
||||||
// be returned, optional.
|
|
||||||
int64 until_time = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Response for GetLogs().
|
|
||||||
message GetLogsResponse {
|
|
||||||
// List of the log lines that returned, optional as the response can contain no logs.
|
|
||||||
repeated string lines = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PublicAPI defines the read-only APIs that will be supported.
|
|
||||||
// These will be handled over TCP sockets.
|
|
||||||
service PublicAPI {
|
|
||||||
// GetInfo gets the rkt's information on the machine.
|
|
||||||
rpc GetInfo (GetInfoRequest) returns (GetInfoResponse) {}
|
|
||||||
|
|
||||||
// ListPods lists rkt pods on the machine.
|
|
||||||
rpc ListPods (ListPodsRequest) returns (ListPodsResponse) {}
|
|
||||||
|
|
||||||
// InspectPod gets detailed pod information of the specified pod.
|
|
||||||
rpc InspectPod (InspectPodRequest) returns (InspectPodResponse) {}
|
|
||||||
|
|
||||||
// ListImages lists the images on the machine.
|
|
||||||
rpc ListImages (ListImagesRequest) returns (ListImagesResponse) {}
|
|
||||||
|
|
||||||
// InspectImage gets the detailed image information of the specified image.
|
|
||||||
rpc InspectImage (InspectImageRequest) returns (InspectImageResponse) {}
|
|
||||||
|
|
||||||
// ListenEvents listens for the events, it will return a response stream
|
|
||||||
// that will contain event objects.
|
|
||||||
rpc ListenEvents (ListenEventsRequest) returns (stream ListenEventsResponse) {}
|
|
||||||
|
|
||||||
// GetLogs gets the logs for a pod, if the app is also specified, then only the logs
|
|
||||||
// of the app will be returned.
|
|
||||||
//
|
|
||||||
// If 'follow' in the 'GetLogsRequest' is set to 'true', then the response stream
|
|
||||||
// will not be closed after the first response, the future logs will be sent via
|
|
||||||
// the stream.
|
|
||||||
rpc GetLogs(GetLogsRequest) returns (stream GetLogsResponse) {}
|
|
||||||
}
|
|
154
vendor/github.com/coreos/rkt/api/v1alpha/client_example.go
generated
vendored
154
vendor/github.com/coreos/rkt/api/v1alpha/client_example.go
generated
vendored
@ -1,154 +0,0 @@
|
|||||||
// Copyright 2015 The rkt Authors
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/coreos/rkt/api/v1alpha"
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
func getLogsWithoutFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) {
|
|
||||||
if len(p.Apps) == 0 {
|
|
||||||
fmt.Printf("Pod %q has no apps\n", p.Id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{
|
|
||||||
PodId: p.Id,
|
|
||||||
Follow: false,
|
|
||||||
AppName: p.Apps[0].Name,
|
|
||||||
SinceTime: time.Now().Add(-time.Second * 5).Unix(),
|
|
||||||
Lines: 10,
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
os.Exit(254)
|
|
||||||
}
|
|
||||||
|
|
||||||
logsRecvResp, err := logsResp.Recv()
|
|
||||||
|
|
||||||
if err == io.EOF {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, l := range logsRecvResp.Lines {
|
|
||||||
fmt.Println(l)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getLogsWithFollow(c v1alpha.PublicAPIClient, p *v1alpha.Pod) {
|
|
||||||
if len(p.Apps) == 0 {
|
|
||||||
fmt.Printf("Pod %q has no apps\n", p.Id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
logsResp, err := c.GetLogs(context.Background(), &v1alpha.GetLogsRequest{
|
|
||||||
PodId: p.Id,
|
|
||||||
Follow: true,
|
|
||||||
AppName: p.Apps[0].Name,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
os.Exit(254)
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
logsRecvResp, err := logsResp.Recv()
|
|
||||||
if err == io.EOF {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, l := range logsRecvResp.Lines {
|
|
||||||
fmt.Println(l)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
followFlag := flag.Bool("follow", false, "enable 'follow' option on GetLogs")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
conn, err := grpc.Dial("localhost:15441", grpc.WithInsecure())
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
os.Exit(254)
|
|
||||||
}
|
|
||||||
c := v1alpha.NewPublicAPIClient(conn)
|
|
||||||
defer conn.Close()
|
|
||||||
|
|
||||||
// List pods.
|
|
||||||
podResp, err := c.ListPods(context.Background(), &v1alpha.ListPodsRequest{
|
|
||||||
// Specify the request: Fetch and print only running pods and their details.
|
|
||||||
Detail: true,
|
|
||||||
Filters: []*v1alpha.PodFilter{
|
|
||||||
{
|
|
||||||
States: []v1alpha.PodState{v1alpha.PodState_POD_STATE_RUNNING},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
os.Exit(254)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, p := range podResp.Pods {
|
|
||||||
if *followFlag {
|
|
||||||
fmt.Printf("Pod %q is running. Following logs:\n", p.Id)
|
|
||||||
getLogsWithFollow(c, p)
|
|
||||||
} else {
|
|
||||||
fmt.Printf("Pod %q is running.\n", p.Id)
|
|
||||||
getLogsWithoutFollow(c, p)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// List images.
|
|
||||||
imgResp, err := c.ListImages(context.Background(), &v1alpha.ListImagesRequest{
|
|
||||||
// In this request, we fetch the details of images whose names are prefixed with "coreos.com".
|
|
||||||
Detail: true,
|
|
||||||
Filters: []*v1alpha.ImageFilter{
|
|
||||||
{
|
|
||||||
Prefixes: []string{"coreos.com"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
os.Exit(254)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, im := range imgResp.Images {
|
|
||||||
fmt.Printf("Found image %q\n", im.Name)
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,7 +28,6 @@ type ContainerWatchSource int
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
Raw ContainerWatchSource = iota
|
Raw ContainerWatchSource = iota
|
||||||
Rkt
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContainerEvent represents a
|
// ContainerEvent represents a
|
||||||
|
Loading…
Reference in New Issue
Block a user