From 5ad727d932a15dc05d800944f41e7653cf8aa528 Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Mon, 11 Jan 2016 17:53:40 -0800 Subject: [PATCH 1/2] godep: Update rkt --- Godeps/Godeps.json | 4 +- .../coreos/rkt/api/v1alpha/README.md | 1 + .../coreos/rkt/api/v1alpha/api.pb.go | 51 +++++++++++-- .../coreos/rkt/api/v1alpha/api.proto | 34 +++++++-- .../coreos/rkt/api/v1alpha/client_example.go | 76 +++++++++++++++++++ 5 files changed, 152 insertions(+), 14 deletions(-) create mode 100644 Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/client_example.go diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index a43a081e630..6e5ee2e54d4 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -321,8 +321,8 @@ }, { "ImportPath": "github.com/coreos/rkt/api/v1alpha", - "Comment": "v0.13.0-98-gddfa976", - "Rev": "ddfa97689c1f8e89aff51368300c34da4c74091b" + "Comment": "v0.15.0-22-g8ac03ac", + "Rev": "8ac03ace42034b4d6b31af9e3ef574b9e71ccc1a" }, { "ImportPath": "github.com/cpuguy83/go-md2man/md2man", diff --git a/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/README.md b/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/README.md index 7d4eada04a2..d4428e1df32 100644 --- a/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/README.md +++ b/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/README.md @@ -10,3 +10,4 @@ For more information, see: - #1208 - #1359 - #1468 +- [API Service Subcommand](../../Documentation/subcommands/api-service.md) diff --git a/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/api.pb.go b/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/api.pb.go index 40aa856f006..4195b024298 100644 --- a/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/api.pb.go +++ b/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/api.pb.go @@ -226,6 +226,10 @@ type Image struct { ImportTimestamp int64 `protobuf:"varint,5,opt,name=import_timestamp" json:"import_timestamp,omitempty"` // JSON-encoded byte array that represents the image manifest, optional. Manifest []byte `protobuf:"bytes,6,opt,name=manifest,proto3" json:"manifest,omitempty"` + // Size is the size in bytes of this image in the store. + Size int64 `protobuf:"varint,7,opt,name=size" json:"size,omitempty"` + // Annotations on this image. + Annotations []*KeyValue `protobuf:"bytes,8,rep,name=annotations" json:"annotations,omitempty"` } func (m *Image) Reset() { *m = Image{} } @@ -239,6 +243,13 @@ func (m *Image) GetBaseFormat() *ImageFormat { return nil } +func (m *Image) GetAnnotations() []*KeyValue { + if m != nil { + return m.Annotations + } + return nil +} + // Network describes the network information of a pod. type Network struct { // Name of the network that a pod belongs to, required. @@ -265,6 +276,8 @@ type App struct { // Exit code of the app. optional, only valid if it's returned by InspectPod() and // the app has already exited. ExitCode int32 `protobuf:"zigzag32,4,opt,name=exit_code" json:"exit_code,omitempty"` + // Annotations for this app. + Annotations []*KeyValue `protobuf:"bytes,5,rep,name=annotations" json:"annotations,omitempty"` } func (m *App) Reset() { *m = App{} } @@ -278,21 +291,40 @@ func (m *App) GetImage() *Image { return nil } +func (m *App) GetAnnotations() []*KeyValue { + if m != nil { + return m.Annotations + } + return nil +} + // 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. type Pod struct { - // ID of the pod, in the form of a UUID, required. + // ID of the pod, in the form of a UUID. Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` - // PID of the pod, optional, only valid if it's returned by InspectPod(). A negative value means the pod has exited. + // PID of the stage1 process of the pod. Pid int32 `protobuf:"zigzag32,2,opt,name=pid" json:"pid,omitempty"` - // State of the pod, required. + // State of the pod. State PodState `protobuf:"varint,3,opt,name=state,enum=v1alpha.PodState" json:"state,omitempty"` - // List of apps in the pod, required. + // List of apps in the pod. Apps []*App `protobuf:"bytes,4,rep,name=apps" json:"apps,omitempty"` - // Network information of the pod, optional, non-empty if the pod is running in private net. + // Network information of the pod. // Note that a pod can be in multiple networks. Networks []*Network `protobuf:"bytes,5,rep,name=networks" json:"networks,omitempty"` - // JSON-encoded byte array that represents the pod manifest of the pod, required. + // JSON-encoded byte array that represents the pod manifest of the pod. Manifest []byte `protobuf:"bytes,6,opt,name=manifest,proto3" json:"manifest,omitempty"` + // Annotations on this pod. + Annotations []*KeyValue `protobuf:"bytes,7,rep,name=annotations" json:"annotations,omitempty"` } func (m *Pod) Reset() { *m = Pod{} } @@ -313,6 +345,13 @@ func (m *Pod) GetNetworks() []*Network { return nil } +func (m *Pod) GetAnnotations() []*KeyValue { + if m != nil { + return m.Annotations + } + return nil +} + type KeyValue struct { // Key part of the key-value pair. Key string `protobuf:"bytes,1,opt" json:"Key,omitempty"` diff --git a/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/api.proto b/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/api.proto index 2b68cdbee85..8112c42f5fe 100644 --- a/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/api.proto +++ b/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/api.proto @@ -73,6 +73,12 @@ message Image { // 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; } // Network describes the network information of a pod. @@ -109,6 +115,9 @@ message App { // 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. @@ -133,25 +142,38 @@ enum PodState { } // 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, required. + // ID of the pod, in the form of a UUID. string id = 1; - // PID of the pod, optional, only valid if it's returned by InspectPod(). A negative value means the pod has exited. + // PID of the stage1 process of the pod. sint32 pid = 2; - // State of the pod, required. + // State of the pod. PodState state = 3; - // List of apps in the pod, required. + // List of apps in the pod. repeated App apps = 4; - // Network information of the pod, optional, non-empty if the pod is running in private net. + // 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, required. + // JSON-encoded byte array that represents the pod manifest of the pod. bytes manifest = 6; + + // Annotations on this pod. + repeated KeyValue annotations = 7; } message KeyValue { diff --git a/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/client_example.go b/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/client_example.go new file mode 100644 index 00000000000..7c715408969 --- /dev/null +++ b/Godeps/_workspace/src/github.com/coreos/rkt/api/v1alpha/client_example.go @@ -0,0 +1,76 @@ +// 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 ( + "fmt" + "os" + + // Note that if your project uses Godep to manage dependencies, then + // you need to change following the import paths. + "github.com/coreos/rkt/api/v1alpha" + "golang.org/x/net/context" + "google.golang.org/grpc" +) + +func main() { + conn, err := grpc.Dial("localhost:15441", grpc.WithInsecure()) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + 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(2) + } + + for _, p := range podResp.Pods { + fmt.Printf("Pod %q is running\n", p.Id) + } + + // 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(3) + } + + for _, im := range imgResp.Images { + fmt.Printf("Found image %q\n", im.Name) + } +} From 55f09009c74e3d28185fa9c94703746e9424e0e3 Mon Sep 17 00:00:00 2001 From: Derek Parker Date: Mon, 11 Jan 2016 17:54:42 -0800 Subject: [PATCH 2/2] rkt: Include size in ListImages --- pkg/kubelet/rkt/image.go | 2 +- pkg/kubelet/rkt/rkt_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/kubelet/rkt/image.go b/pkg/kubelet/rkt/image.go index 54e5ff231e5..2a949042ea7 100644 --- a/pkg/kubelet/rkt/image.go +++ b/pkg/kubelet/rkt/image.go @@ -88,7 +88,7 @@ func (r *Runtime) ListImages() ([]kubecontainer.Image, error) { images[i] = kubecontainer.Image{ ID: image.Id, RepoTags: []string{buildImageName(image)}, - //TODO: fill in the size of the image + Size: image.Size, } } return images, nil diff --git a/pkg/kubelet/rkt/rkt_test.go b/pkg/kubelet/rkt/rkt_test.go index 2be0f976ecb..5bece7edcb9 100644 --- a/pkg/kubelet/rkt/rkt_test.go +++ b/pkg/kubelet/rkt/rkt_test.go @@ -294,21 +294,25 @@ func TestListImages(t *testing.T) { Id: "sha512-a2fb8f390702", Name: "quay.io/coreos/alpine-sh", Version: "latest", + Size: 400, }, { Id: "sha512-c6b597f42816", Name: "coreos.com/rkt/stage1-coreos", Version: "0.10.0", + Size: 400, }, }, []kubecontainer.Image{ { ID: "sha512-a2fb8f390702", RepoTags: []string{"quay.io/coreos/alpine-sh:latest"}, + Size: 400, }, { ID: "sha512-c6b597f42816", RepoTags: []string{"coreos.com/rkt/stage1-coreos:0.10.0"}, + Size: 400, }, }, },