├── code-of-conduct.md ├── .github └── PULL_REQUEST_TEMPLATE.md ├── doc.go ├── SECURITY_CONTACTS ├── pkg ├── errors │ ├── doc.go │ ├── errors_test.go │ └── errors.go └── apis │ ├── testing │ ├── utils.go │ ├── fake_image_service.go │ └── fake_runtime_service.go │ ├── runtime │ └── v1 │ │ ├── constants.go │ │ └── api_grpc.pb.go │ └── services.go ├── OWNERS ├── go.mod ├── CONTRIBUTING.md ├── go.sum ├── LICENSE └── README.md /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | # Kubernetes Community Code of Conduct 2 | 3 | Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Sorry, we do not accept changes directly against this repository. Please see 2 | CONTRIBUTING.md for information on where and how to contribute instead. 3 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package criapi 18 | -------------------------------------------------------------------------------- /SECURITY_CONTACTS: -------------------------------------------------------------------------------- 1 | # Defined below are the security contacts for this repo. 2 | # 3 | # They are the contact point for the Product Security Committee to reach out 4 | # to for triaging and handling of incoming issues. 5 | # 6 | # The below names agree to abide by the 7 | # [Embargo Policy](https://git.k8s.io/security/private-distributors-list.md#embargo-policy) 8 | # and will be removed and replaced if they violate that agreement. 9 | # 10 | # DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE 11 | # INSTRUCTIONS AT https://kubernetes.io/security/ 12 | 13 | tallclair 14 | yujuhong 15 | dims 16 | cjcullen 17 | joelsmith 18 | liggitt 19 | philips 20 | -------------------------------------------------------------------------------- /pkg/errors/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package errors provides helper functions for use by the kubelet 18 | // to deal with CRI errors. 19 | package errors 20 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | # Disable inheritance as this is owned by sig-node (should mirror same contents as pkg/kubelet/OWNERS) 4 | options: 5 | no_parent_owners: true 6 | filters: 7 | # to use filters all entries must be under filters https://go.k8s.io/owners/#filters 8 | # use .* for approvers that should have all files 9 | ".*": 10 | approvers: 11 | - dims 12 | - feiskyer 13 | - sig-node-approvers 14 | - api-approvers 15 | - sig-node-cri-approvers 16 | reviewers: 17 | - sig-node-reviewers 18 | - dims 19 | labels: 20 | - sig/node 21 | - area/kubelet 22 | emeritus_approvers: 23 | - resouer 24 | # go.{mod,sum,work,work.sum} files relate to go dependencies, 25 | # and should be reviewed by the dep-approvers 26 | "go\\.(mod|sum|work|work\\.sum)$": 27 | approvers: 28 | - dep-approvers 29 | reviewers: 30 | - dep-reviewers 31 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | // This is a generated file. Do not edit directly. 2 | 3 | module k8s.io/cri-api 4 | 5 | go 1.25.0 6 | 7 | godebug default=go1.25 8 | 9 | require ( 10 | github.com/stretchr/testify v1.11.1 11 | google.golang.org/grpc v1.75.0 12 | google.golang.org/protobuf v1.36.8 13 | ) 14 | 15 | require ( 16 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect 17 | github.com/kr/pretty v0.3.1 // indirect 18 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect 19 | github.com/rogpeppe/go-internal v1.14.1 // indirect 20 | go.opentelemetry.io/otel v1.38.0 // indirect 21 | go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect 22 | golang.org/x/net v0.47.0 // indirect 23 | golang.org/x/sys v0.38.0 // indirect 24 | golang.org/x/text v0.31.0 // indirect 25 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect 26 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect 27 | gopkg.in/yaml.v3 v3.0.1 // indirect 28 | ) 29 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | Do not open pull requests directly against this repository, they will be ignored. 4 | Instead, please open pull requests against [kubernetes/kubernetes](https://git.k8s.io/kubernetes/). 5 | Please follow the same [contributing guide](https://git.k8s.io/kubernetes/CONTRIBUTING.md) 6 | you would follow for any other pull request made to kubernetes/kubernetes. 7 | 8 | Issues related to CRI API can be filed at [kubernetes/kubernetes repository](https://github.com/kubernetes/kubernetes/issues). 9 | For issues in specific implementations of CRI API (e.g. container runtime) - follow processes of the specific runtime. 10 | For support, ask your Kubernetes vendor or ask at the [forum](https://discuss.kubernetes.io/). 11 | 12 | This repository is published from [kubernetes/kubernetes/staging/src/k8s.io/cri-api](https://git.k8s.io/kubernetes/staging/src/k8s.io/cri-api) 13 | by the [kubernetes publishing-bot](https://git.k8s.io/publishing-bot). 14 | 15 | Please see [Staging Directory and Publishing](https://git.k8s.io/community/contributors/devel/sig-architecture/staging.md) for more information. 16 | -------------------------------------------------------------------------------- /pkg/errors/errors_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "fmt" 21 | "testing" 22 | 23 | "google.golang.org/grpc/codes" 24 | "google.golang.org/grpc/status" 25 | ) 26 | 27 | func TestErrorIsNotFound(t *testing.T) { 28 | enf := status.Errorf(codes.NotFound, "container not found") 29 | if !IsNotFound(enf) { 30 | t.Errorf("%v expected to pass not found check", enf) 31 | } 32 | } 33 | 34 | func TestSimpleErrorDoesNotTriggerNotFound(t *testing.T) { 35 | err := fmt.Errorf("Some random error") 36 | if IsNotFound(err) { 37 | t.Errorf("%v unexpectedly passed not found check", err) 38 | } 39 | } 40 | 41 | func TestOtherGrpcErrorDoesNotTriggerNotFound(t *testing.T) { 42 | gerr := status.Errorf(codes.DeadlineExceeded, "timed out") 43 | if IsNotFound(gerr) { 44 | t.Errorf("%v unexpectedly passed not found check", gerr) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /pkg/apis/testing/utils.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package testing 18 | 19 | import ( 20 | "fmt" 21 | 22 | runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" 23 | ) 24 | 25 | // BuildContainerName creates a unique container name string. 26 | func BuildContainerName(metadata *runtimeapi.ContainerMetadata, sandboxID string) string { 27 | // include the sandbox ID to make the container ID unique. 28 | return fmt.Sprintf("%s_%s_%d", sandboxID, metadata.Name, metadata.Attempt) 29 | } 30 | 31 | // BuildSandboxName creates a unique sandbox name string. 32 | func BuildSandboxName(metadata *runtimeapi.PodSandboxMetadata) string { 33 | return fmt.Sprintf("%s_%s_%s_%d", metadata.Name, metadata.Namespace, metadata.Uid, metadata.Attempt) 34 | } 35 | 36 | func filterInLabels(filter, labels map[string]string) bool { 37 | for k, v := range filter { 38 | if value, ok := labels[k]; ok { 39 | if value != v { 40 | return false 41 | } 42 | } else { 43 | return false 44 | } 45 | } 46 | 47 | return true 48 | } 49 | -------------------------------------------------------------------------------- /pkg/errors/errors.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "errors" 21 | 22 | "google.golang.org/grpc/codes" 23 | "google.golang.org/grpc/status" 24 | ) 25 | 26 | var ( 27 | // ErrRegistryUnavailable - Get http error on the PullImage RPC call. 28 | ErrRegistryUnavailable = errors.New("RegistryUnavailable") 29 | 30 | // ErrSignatureValidationFailed - Unable to validate the image signature on the PullImage RPC call. 31 | ErrSignatureValidationFailed = errors.New("SignatureValidationFailed") 32 | 33 | // ErrRROUnsupported - Unable to enforce recursive readonly mounts 34 | ErrRROUnsupported = errors.New("RROUnsupported") 35 | 36 | // ErrImageVolumeMountFailed - Unable to mount an image volume. 37 | ErrImageVolumeMountFailed = errors.New("ImageVolumeMountFailed") 38 | ) 39 | 40 | // IsNotFound returns a boolean indicating whether the error 41 | // is grpc not found error. 42 | // See https://github.com/grpc/grpc/blob/master/doc/statuscodes.md 43 | // for a list of grpc status codes. 44 | func IsNotFound(err error) bool { 45 | s, ok := status.FromError(err) 46 | if !ok { 47 | return ok 48 | } 49 | if s.Code() == codes.NotFound { 50 | return true 51 | } 52 | 53 | return false 54 | } 55 | -------------------------------------------------------------------------------- /pkg/apis/runtime/v1/constants.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | // This file contains all constants defined in CRI. 20 | 21 | // Required runtime condition type. 22 | const ( 23 | // RuntimeReady means the runtime is up and ready to accept basic containers. 24 | RuntimeReady = "RuntimeReady" 25 | // NetworkReady means the runtime network is up and ready to accept containers which require network. 26 | NetworkReady = "NetworkReady" 27 | ) 28 | 29 | // LogStreamType is the type of the stream in CRI container log. 30 | type LogStreamType string 31 | 32 | const ( 33 | // Stdout is the stream type for stdout. 34 | Stdout LogStreamType = "stdout" 35 | // Stderr is the stream type for stderr. 36 | Stderr LogStreamType = "stderr" 37 | ) 38 | 39 | // LogTag is the tag of a log line in CRI container log. 40 | // Currently defined log tags: 41 | // * First tag: Partial/Full - P/F. 42 | // The field in the container log format can be extended to include multiple 43 | // tags by using a delimiter, but changes should be rare. If it becomes clear 44 | // that better extensibility is desired, a more extensible format (e.g., json) 45 | // should be adopted as a replacement and/or addition. 46 | type LogTag string 47 | 48 | const ( 49 | // LogTagPartial means the line is part of multiple lines. 50 | LogTagPartial LogTag = "P" 51 | // LogTagFull means the line is a single full line or the end of multiple lines. 52 | LogTagFull LogTag = "F" 53 | // LogTagDelimiter is the delimiter for different log tags. 54 | LogTagDelimiter = ":" 55 | ) 56 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= 2 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= 3 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= 5 | github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= 6 | github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= 7 | github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= 8 | github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= 9 | github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= 10 | github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= 11 | github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= 12 | github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= 13 | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 14 | github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 15 | github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 16 | github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= 17 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 18 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 19 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 20 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 21 | github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= 22 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= 23 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 24 | github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= 25 | github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= 26 | github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= 27 | github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= 28 | github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= 29 | go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= 30 | go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= 31 | go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= 32 | go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= 33 | go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= 34 | go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= 35 | go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= 36 | go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= 37 | go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= 38 | go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= 39 | go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= 40 | go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= 41 | golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= 42 | golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= 43 | golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= 44 | golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= 45 | golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= 46 | golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= 47 | gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= 48 | gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= 49 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE= 50 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5/go.mod h1:M4/wBTSeyLxupu3W3tJtOgB14jILAS/XWPSSa3TAlJc= 51 | google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4= 52 | google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ= 53 | google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= 54 | google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= 55 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 56 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= 57 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= 58 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 59 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 60 | -------------------------------------------------------------------------------- /pkg/apis/testing/fake_image_service.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package testing 18 | 19 | import ( 20 | "context" 21 | "sync" 22 | "testing" 23 | 24 | "github.com/stretchr/testify/assert" 25 | 26 | runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" 27 | ) 28 | 29 | // FakeImageService fakes the image service. 30 | type FakeImageService struct { 31 | sync.Mutex 32 | 33 | FakeImageSize uint64 34 | Called []string 35 | Errors map[string][]error 36 | Images map[string]*runtimeapi.Image 37 | Pinned map[string]bool 38 | 39 | pulledImages []*pulledImage 40 | 41 | FakeFilesystemUsage []*runtimeapi.FilesystemUsage 42 | FakeContainerFilesystemUsage []*runtimeapi.FilesystemUsage 43 | } 44 | 45 | // SetFakeImages sets the list of fake images for the FakeImageService. 46 | func (r *FakeImageService) SetFakeImages(images []string) { 47 | r.Lock() 48 | defer r.Unlock() 49 | 50 | r.Images = make(map[string]*runtimeapi.Image) 51 | for _, image := range images { 52 | r.Images[image] = r.makeFakeImage( 53 | &runtimeapi.ImageSpec{ 54 | Image: image, 55 | Annotations: make(map[string]string)}) 56 | } 57 | } 58 | 59 | // SetFakeImagesWithAnnotations sets the list of fake images for the FakeImageService with annotations. 60 | func (r *FakeImageService) SetFakeImagesWithAnnotations(imageSpecs []*runtimeapi.ImageSpec) { 61 | r.Lock() 62 | defer r.Unlock() 63 | 64 | r.Images = make(map[string]*runtimeapi.Image) 65 | for _, imageSpec := range imageSpecs { 66 | r.Images[imageSpec.Image] = r.makeFakeImage(imageSpec) 67 | } 68 | } 69 | 70 | // SetFakeImageSize sets the image size for the FakeImageService. 71 | func (r *FakeImageService) SetFakeImageSize(size uint64) { 72 | r.Lock() 73 | defer r.Unlock() 74 | 75 | r.FakeImageSize = size 76 | } 77 | 78 | // SetFakeImagePinned sets the image Pinned field for one image. 79 | func (r *FakeImageService) SetFakeImagePinned(image string, pinned bool) { 80 | r.Lock() 81 | defer r.Unlock() 82 | 83 | if r.Pinned == nil { 84 | r.Pinned = make(map[string]bool) 85 | } 86 | r.Pinned[image] = pinned 87 | } 88 | 89 | // SetFakeFilesystemUsage sets the FilesystemUsage for FakeImageService. 90 | func (r *FakeImageService) SetFakeFilesystemUsage(usage []*runtimeapi.FilesystemUsage) { 91 | r.Lock() 92 | defer r.Unlock() 93 | 94 | r.FakeFilesystemUsage = usage 95 | } 96 | 97 | // SetFakeFilesystemUsage sets the FilesystemUsage for FakeImageService. 98 | func (r *FakeImageService) SetFakeContainerFilesystemUsage(usage []*runtimeapi.FilesystemUsage) { 99 | r.Lock() 100 | defer r.Unlock() 101 | 102 | r.FakeContainerFilesystemUsage = usage 103 | } 104 | 105 | // NewFakeImageService creates a new FakeImageService. 106 | func NewFakeImageService() *FakeImageService { 107 | return &FakeImageService{ 108 | Called: make([]string, 0), 109 | Errors: make(map[string][]error), 110 | Images: make(map[string]*runtimeapi.Image), 111 | } 112 | } 113 | 114 | func (r *FakeImageService) makeFakeImage(image *runtimeapi.ImageSpec) *runtimeapi.Image { 115 | return &runtimeapi.Image{ 116 | Id: image.Image, 117 | Size: r.FakeImageSize, 118 | Spec: image, 119 | RepoTags: []string{image.Image}, 120 | Pinned: r.Pinned[image.Image], 121 | } 122 | } 123 | 124 | // stringInSlice returns true if s is in list 125 | func stringInSlice(s string, list []string) bool { 126 | for _, v := range list { 127 | if v == s { 128 | return true 129 | } 130 | } 131 | 132 | return false 133 | } 134 | 135 | // InjectError sets the error message for the FakeImageService. 136 | func (r *FakeImageService) InjectError(f string, err error) { 137 | r.Lock() 138 | defer r.Unlock() 139 | r.Errors[f] = append(r.Errors[f], err) 140 | } 141 | 142 | // caller of popError must grab a lock. 143 | func (r *FakeImageService) popError(f string) error { 144 | if r.Errors == nil { 145 | return nil 146 | } 147 | errs := r.Errors[f] 148 | if len(errs) == 0 { 149 | return nil 150 | } 151 | err, errs := errs[0], errs[1:] 152 | r.Errors[f] = errs 153 | return err 154 | } 155 | 156 | // ListImages returns the list of images from FakeImageService or error if it was previously set. 157 | func (r *FakeImageService) ListImages(_ context.Context, filter *runtimeapi.ImageFilter) ([]*runtimeapi.Image, error) { 158 | r.Lock() 159 | defer r.Unlock() 160 | 161 | r.Called = append(r.Called, "ListImages") 162 | if err := r.popError("ListImages"); err != nil { 163 | return nil, err 164 | } 165 | 166 | images := make([]*runtimeapi.Image, 0) 167 | for _, img := range r.Images { 168 | if filter != nil && filter.Image != nil { 169 | if !stringInSlice(filter.Image.Image, img.RepoTags) { 170 | continue 171 | } 172 | } 173 | 174 | images = append(images, img) 175 | } 176 | return images, nil 177 | } 178 | 179 | // ImageStatus returns the status of the image from the FakeImageService. 180 | func (r *FakeImageService) ImageStatus(_ context.Context, image *runtimeapi.ImageSpec, verbose bool) (*runtimeapi.ImageStatusResponse, error) { 181 | r.Lock() 182 | defer r.Unlock() 183 | 184 | r.Called = append(r.Called, "ImageStatus") 185 | if err := r.popError("ImageStatus"); err != nil { 186 | return nil, err 187 | } 188 | 189 | return &runtimeapi.ImageStatusResponse{Image: r.Images[image.Image]}, nil 190 | } 191 | 192 | // PullImage emulate pulling the image from the FakeImageService. 193 | func (r *FakeImageService) PullImage(_ context.Context, image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig) (string, error) { 194 | r.Lock() 195 | defer r.Unlock() 196 | 197 | r.Called = append(r.Called, "PullImage") 198 | if err := r.popError("PullImage"); err != nil { 199 | return "", err 200 | } 201 | 202 | r.pulledImages = append(r.pulledImages, &pulledImage{imageSpec: image, authConfig: auth}) 203 | // ImageID should be randomized for real container runtime, but here just use 204 | // image's name for easily making fake images. 205 | imageID := image.Image 206 | if _, ok := r.Images[imageID]; !ok { 207 | r.Images[imageID] = r.makeFakeImage(image) 208 | } 209 | 210 | return imageID, nil 211 | } 212 | 213 | // RemoveImage removes image from the FakeImageService. 214 | func (r *FakeImageService) RemoveImage(_ context.Context, image *runtimeapi.ImageSpec) error { 215 | r.Lock() 216 | defer r.Unlock() 217 | 218 | r.Called = append(r.Called, "RemoveImage") 219 | if err := r.popError("RemoveImage"); err != nil { 220 | return err 221 | } 222 | 223 | // Remove the image 224 | delete(r.Images, image.Image) 225 | 226 | return nil 227 | } 228 | 229 | // ImageFsInfo returns information of the filesystem that is used to store images. 230 | func (r *FakeImageService) ImageFsInfo(_ context.Context) (*runtimeapi.ImageFsInfoResponse, error) { 231 | r.Lock() 232 | defer r.Unlock() 233 | 234 | r.Called = append(r.Called, "ImageFsInfo") 235 | if err := r.popError("ImageFsInfo"); err != nil { 236 | return nil, err 237 | } 238 | 239 | return &runtimeapi.ImageFsInfoResponse{ 240 | ImageFilesystems: r.FakeFilesystemUsage, 241 | ContainerFilesystems: r.FakeContainerFilesystemUsage, 242 | }, nil 243 | } 244 | 245 | // AssertImagePulledWithAuth validates whether the image was pulled with auth and asserts if it wasn't. 246 | func (r *FakeImageService) AssertImagePulledWithAuth(t *testing.T, image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, failMsg string) { 247 | r.Lock() 248 | defer r.Unlock() 249 | expected := &pulledImage{imageSpec: image, authConfig: auth} 250 | assert.Contains(t, r.pulledImages, expected, failMsg) 251 | } 252 | 253 | type pulledImage struct { 254 | imageSpec *runtimeapi.ImageSpec 255 | authConfig *runtimeapi.AuthConfig 256 | } 257 | 258 | // Close will shutdown the internal gRPC client connection. 259 | func (r *FakeImageService) Close() error { 260 | r.Lock() 261 | defer r.Unlock() 262 | 263 | r.Called = append(r.Called, "Close") 264 | if err := r.popError("Close"); err != nil { 265 | return err 266 | } 267 | 268 | return nil 269 | } 270 | -------------------------------------------------------------------------------- /pkg/apis/services.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package cri 18 | 19 | import ( 20 | "context" 21 | "time" 22 | 23 | runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" 24 | ) 25 | 26 | // RuntimeVersioner contains methods for runtime name, version and API version. 27 | type RuntimeVersioner interface { 28 | // Version returns the runtime name, runtime version and runtime API version 29 | Version(ctx context.Context, apiVersion string) (*runtimeapi.VersionResponse, error) 30 | } 31 | 32 | // ContainerManager contains methods to manipulate containers managed by a 33 | // container runtime. The methods are thread-safe. 34 | type ContainerManager interface { 35 | // CreateContainer creates a new container in specified PodSandbox. 36 | CreateContainer(ctx context.Context, podSandboxID string, config *runtimeapi.ContainerConfig, sandboxConfig *runtimeapi.PodSandboxConfig) (string, error) 37 | // StartContainer starts the container. 38 | StartContainer(ctx context.Context, containerID string) error 39 | // StopContainer stops a running container with a grace period (i.e., timeout). 40 | StopContainer(ctx context.Context, containerID string, timeout int64) error 41 | // RemoveContainer removes the container. 42 | RemoveContainer(ctx context.Context, containerID string) error 43 | // ListContainers lists all containers by filters. 44 | ListContainers(ctx context.Context, filter *runtimeapi.ContainerFilter) ([]*runtimeapi.Container, error) 45 | // ContainerStatus returns the status of the container. 46 | ContainerStatus(ctx context.Context, containerID string, verbose bool) (*runtimeapi.ContainerStatusResponse, error) 47 | // UpdateContainerResources updates ContainerConfig of the container synchronously. 48 | // If runtime fails to transactionally update the requested resources, an error is returned. 49 | UpdateContainerResources(ctx context.Context, containerID string, resources *runtimeapi.ContainerResources) error 50 | // ExecSync executes a command in the container, and returns the stdout output. 51 | // If command exits with a non-zero exit code, an error is returned. 52 | ExecSync(ctx context.Context, containerID string, cmd []string, timeout time.Duration) (stdout []byte, stderr []byte, err error) 53 | // Exec prepares a streaming endpoint to execute a command in the container, and returns the address. 54 | Exec(ctx context.Context, request *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) 55 | // Attach prepares a streaming endpoint to attach to a running container, and returns the address. 56 | Attach(ctx context.Context, req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) 57 | // ReopenContainerLog asks runtime to reopen the stdout/stderr log file 58 | // for the container. If it returns error, new container log file MUST NOT 59 | // be created. 60 | ReopenContainerLog(ctx context.Context, ContainerID string) error 61 | // CheckpointContainer checkpoints a container 62 | CheckpointContainer(ctx context.Context, options *runtimeapi.CheckpointContainerRequest) error 63 | // GetContainerEvents gets container events from the CRI runtime 64 | GetContainerEvents(ctx context.Context, containerEventsCh chan *runtimeapi.ContainerEventResponse, connectionEstablishedCallback func(runtimeapi.RuntimeService_GetContainerEventsClient)) error 65 | } 66 | 67 | // PodSandboxManager contains methods for operating on PodSandboxes. The methods 68 | // are thread-safe. 69 | type PodSandboxManager interface { 70 | // RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure 71 | // the sandbox is in ready state. 72 | RunPodSandbox(ctx context.Context, config *runtimeapi.PodSandboxConfig, runtimeHandler string) (string, error) 73 | // StopPodSandbox stops the sandbox. If there are any running containers in the 74 | // sandbox, they should be force terminated. 75 | StopPodSandbox(ctx context.Context, podSandboxID string) error 76 | // RemovePodSandbox removes the sandbox. If there are running containers in the 77 | // sandbox, they should be forcibly removed. 78 | RemovePodSandbox(ctx context.Context, podSandboxID string) error 79 | // PodSandboxStatus returns the Status of the PodSandbox. 80 | PodSandboxStatus(ctx context.Context, podSandboxID string, verbose bool) (*runtimeapi.PodSandboxStatusResponse, error) 81 | // ListPodSandbox returns a list of Sandbox. 82 | ListPodSandbox(ctx context.Context, filter *runtimeapi.PodSandboxFilter) ([]*runtimeapi.PodSandbox, error) 83 | // PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address. 84 | PortForward(ctx context.Context, request *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) 85 | // UpdatePodSandboxResources synchronously updates the PodSandboxConfig with 86 | // the pod-level resource configuration. This method is called _after_ the 87 | // Kubelet reconfigures the pod-level cgroups. 88 | // This request is treated as best effort, and failure will not block the 89 | // Kubelet with proceeding with a resize. 90 | UpdatePodSandboxResources(ctx context.Context, request *runtimeapi.UpdatePodSandboxResourcesRequest) (*runtimeapi.UpdatePodSandboxResourcesResponse, error) 91 | } 92 | 93 | // ContainerStatsManager contains methods for retrieving the container 94 | // statistics. 95 | type ContainerStatsManager interface { 96 | // ContainerStats returns stats of the container. If the container does not 97 | // exist, the call returns an error. 98 | ContainerStats(ctx context.Context, containerID string) (*runtimeapi.ContainerStats, error) 99 | // ListContainerStats returns stats of all running containers. 100 | ListContainerStats(ctx context.Context, filter *runtimeapi.ContainerStatsFilter) ([]*runtimeapi.ContainerStats, error) 101 | // PodSandboxStats returns stats of the pod. If the pod does not 102 | // exist, the call returns an error. 103 | PodSandboxStats(ctx context.Context, podSandboxID string) (*runtimeapi.PodSandboxStats, error) 104 | // ListPodSandboxStats returns stats of all running pods. 105 | ListPodSandboxStats(ctx context.Context, filter *runtimeapi.PodSandboxStatsFilter) ([]*runtimeapi.PodSandboxStats, error) 106 | // ListMetricDescriptors gets the descriptors for the metrics that will be returned in ListPodSandboxMetrics. 107 | ListMetricDescriptors(ctx context.Context) ([]*runtimeapi.MetricDescriptor, error) 108 | // ListPodSandboxMetrics returns metrics of all running pods. 109 | ListPodSandboxMetrics(ctx context.Context) ([]*runtimeapi.PodSandboxMetrics, error) 110 | } 111 | 112 | // RuntimeService interface should be implemented by a container runtime. 113 | // The methods should be thread-safe. 114 | type RuntimeService interface { 115 | RuntimeVersioner 116 | ContainerManager 117 | PodSandboxManager 118 | ContainerStatsManager 119 | 120 | // UpdateRuntimeConfig updates runtime configuration if specified 121 | UpdateRuntimeConfig(ctx context.Context, runtimeConfig *runtimeapi.RuntimeConfig) error 122 | // Status returns the status of the runtime. 123 | Status(ctx context.Context, verbose bool) (*runtimeapi.StatusResponse, error) 124 | // RuntimeConfig returns the configuration information of the runtime. 125 | RuntimeConfig(ctx context.Context) (*runtimeapi.RuntimeConfigResponse, error) 126 | // Close will shutdown the internal gRPC client connection. 127 | Close() error 128 | } 129 | 130 | // ImageManagerService interface should be implemented by a container image 131 | // manager. 132 | // The methods should be thread-safe. 133 | type ImageManagerService interface { 134 | // ListImages lists the existing images. 135 | ListImages(ctx context.Context, filter *runtimeapi.ImageFilter) ([]*runtimeapi.Image, error) 136 | // ImageStatus returns the status of the image. 137 | ImageStatus(ctx context.Context, image *runtimeapi.ImageSpec, verbose bool) (*runtimeapi.ImageStatusResponse, error) 138 | // PullImage pulls an image with the authentication config. 139 | PullImage(ctx context.Context, image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig) (string, error) 140 | // RemoveImage removes the image. 141 | RemoveImage(ctx context.Context, image *runtimeapi.ImageSpec) error 142 | // ImageFsInfo returns information of the filesystem(s) used to store the read-only layers and the writeable layer. 143 | ImageFsInfo(ctx context.Context) (*runtimeapi.ImageFsInfoResponse, error) 144 | // Close will shutdown the internal gRPC client connection. 145 | Close() error 146 | } 147 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > ⚠️ **This is an automatically published [staged repository](https://git.k8s.io/kubernetes/staging#external-repository-staging-area) for Kubernetes**. 2 | > Contributions, including issues and pull requests, should be made to the main Kubernetes repository: [https://github.com/kubernetes/kubernetes](https://github.com/kubernetes/kubernetes). 3 | > This repository is read-only for importing, and not used for direct contributions. 4 | > See [CONTRIBUTING.md](./CONTRIBUTING.md) for more details. 5 | 6 | ## Purpose 7 | 8 | This repository contains the definitions for the Container Runtime Interface (CRI). 9 | CRI is a plugin interface which enables kubelet to use a wide variety of container runtimes, 10 | without the need to recompile. CRI consists of a protocol buffers and gRPC API. 11 | Read more about CRI API at [kubernetes docs](https://kubernetes.io/docs/concepts/architecture/cri/). 12 | 13 | The repository [kubernetes/cri-api](https://github.com/kubernetes/cri-api) is a mirror of https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/cri-api. 14 | Please do **not** file issues or submit PRs against the [kubernetes/cri-api](https://github.com/kubernetes/cri-api) 15 | repository as it is readonly, all development is done in [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes). 16 | 17 | The CRI API is defined in [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes) 18 | repository and is **only** intended to be used for kubelet to container runtime 19 | interactions, or for node-level troubleshooting using a tool such as `crictl`. 20 | It is **not** a common purpose container runtime API for general use, and is intended 21 | to be Kubernetes-centric. We try to avoid it, but there may be logic within a container 22 | runtime that optimizes for the order or specific parameters of call(s) that the kubelet 23 | makes. 24 | 25 | ## Version skew policy and feature development 26 | 27 | Please read about: 28 | 29 | - [CRI API version skew policy](https://kubernetes.dev/docs/code/cri-api-version-skew-policy/) 30 | - [Kubernetes feature development and container runtimes](https://kubernetes.dev/docs/code/cri-api-dev-policies/) 31 | 32 | ## Community, discussion, contribution, and support 33 | 34 | Learn how to engage with the Kubernetes community on the [community 35 | page](https://www.k8s.dev/community/). 36 | 37 | You can reach the maintainers of this repository at: 38 | 39 | - Slack: #sig-node (on https://kubernetes.slack.com -- get an 40 | invite at [slack.kubernetes.io](https://slack.kubernetes.io)) 41 | - Mailing List: 42 | https://groups.google.com/a/kubernetes.io/g/sig-node 43 | 44 | Issues can be filed at https://github.com/kubernetes/kubernetes/issues. See [CONTRIBUTING.md](CONTRIBUTING.md). 45 | 46 | ### Code of Conduct 47 | 48 | Participation in the Kubernetes community is governed by the [Kubernetes 49 | Code of Conduct](code-of-conduct.md). 50 | 51 | ### Contribution Guidelines 52 | 53 | See [CONTRIBUTING.md](CONTRIBUTING.md) for more information. Please note that [kubernetes/cri-api](https://github.com/kubernetes/cri-api) 54 | is a readonly mirror repository, all development is done at [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes). 55 | 56 | ## Change history 57 | 58 | Here is the change history of the Container Runtime Interface protocol. The change history is maintained manually: 59 | 60 | ### v1.35 61 | 62 | `git diff v1.34.0 1.35.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 63 | 64 | No changes 65 | 66 | ### v1.34 67 | 68 | `git diff v1.33.0 v1.34.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 69 | 70 | - Removed the [gogo dependency](https://github.com/kubernetes/kubernetes/pull/128653) 71 | - [Added `debug_redact` flags](https://github.com/kubernetes/kubernetes/pull/133135) to the following fields of `AuthConfig`: `password`, `auth`, `identity_token`, `registry_token`. 72 | 73 | ### v1.33 74 | 75 | `git diff v1.32.0 v1.33.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 76 | 77 | - [Clarify the behavior when the host_port value is set to 0 in CRI](https://github.com/kubernetes/kubernetes/pull/130512) 78 | - Added clarifying comment to the [host_port] field of [PortMapping]. 79 | 80 | - [\[KEP-4639\] Graduate image volume sources to beta](https://github.com/kubernetes/kubernetes/pull/130135) 81 | - Added `image_sub_path` to the type `Mount` to represent the subpath inside the image to mount. 82 | 83 | - [\[FG:InPlacePodVerticalScaling\] Add UpdatePodSandboxResources CRI method](https://github.com/kubernetes/kubernetes/pull/128123) 84 | - New method `UpdatePodSandboxResources` to synchronously updates the PodSandboxConfig with the pod-level resource configuration. 85 | - Added the `UpdatePodSandboxResourcesRequest` type to pass as an argument to `UpdatePodSandboxResources`. 86 | - Added the `UpdatePodSandboxResourcesResponse` empty type to return from the `UpdatePodSandboxResources`. 87 | 88 | - [Withdraw alpha support for HostNetwork containers on Windows](https://github.com/kubernetes/kubernetes/pull/130250) 89 | - Added clarifying comment on the `network` field of the type `WindowsNamespaceOption` as HostNetwork containers are not supported. 90 | 91 | - [Surface Pressure Stall Information (PSI) metrics](https://github.com/kubernetes/kubernetes/pull/130701) 92 | - Added `io` field to the types `LinuxPodSandboxStats` and `ContainerStats` to represent the IO usage. 93 | - Added `psi` field to the type `CpuUsage`. 94 | - Added types `IoUsage`, `PsiStats`, and `PsiData` to represent IO usage and PSI statistics. 95 | 96 | - [KEP 4960: Container Stop Signals](https://github.com/kubernetes/kubernetes/pull/130556) 97 | - Added the field `stop_signal` to the `ContainerConfig` type. 98 | - Added the enum `Signal` listing all possible stop signals. 99 | 100 | ### v1.32 101 | 102 | `git diff v1.31.0 v1.32.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 103 | 104 | - [CRI: Add field to support CPU affinity on Windows](https://github.com/kubernetes/kubernetes/pull/124285) 105 | - CRI field `affinity_cpus` to `WindowsContainerResources` struct to support CPU affinity on Windows. 106 | This field will be used by Windows CPU manager to set the logical processors to affinitize 107 | for a particular container down to containerd/hcsshim. 108 | 109 | ### v1.31 110 | 111 | `git diff v1.30.0 v1.31.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 112 | 113 | - [KEP-3619: Add NodeStatus.Features.SupplementalGroupsPolicy API and e2e](https://github.com/kubernetes/kubernetes/pull/125470) 114 | - Added `features` field to the type `StatusResponse` for the runtime to kubelet handshake on what features are supported 115 | 116 | - [KEP-3619: Fine-grained SupplementalGroups control](https://github.com/kubernetes/kubernetes/pull/117842) 117 | - Added `supplemental_groups_policy` field to types `LinuxContainerSecurityContext` and `LinuxSandboxSecurityContext` 118 | - Added `user` field to the type `ContainerStatus` to represent actual user for the container 119 | 120 | - [[KEP-4639] Add OCI VolumeSource CRI API](https://github.com/kubernetes/kubernetes/pull/125659) 121 | - Added `image` field to the type `Mount` to represent the OCI VolumeSource 122 | 123 | ### v1.30 124 | 125 | `git diff v1.29.0 v1.30.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 126 | 127 | - [Recursive Read-only (RRO) mounts](https://github.com/kubernetes/kubernetes/pull/123272) 128 | - Added RuntimeHandler and RuntimeHandlerFeatures type 129 | - Added `recursive_read_only` field to type `Mount` 130 | - Added `runtime_handlers` field to type `StatusResponse` 131 | 132 | - [Add user_namespaces field to RuntimeHandlerFeatures](https://github.com/kubernetes/kubernetes/pull/123356) 133 | - Added `user_namespaces` field to type `RuntimeHandlerFeatures` 134 | 135 | - [Add image_id to CRI Container message](https://github.com/kubernetes/kubernetes/pull/123508) 136 | - Added `image_id` field to type `Container` 137 | 138 | - [Add image_id to CRI ContainerStatus message](https://github.com/kubernetes/kubernetes/pull/123583) 139 | - Added `image_id` field to type `ContainerStatus` 140 | 141 | ### v1.29 142 | 143 | `git diff v1.28.0 v1.29.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 144 | 145 | - [Add runtime handler field to ImageSpec struct](https://github.com/kubernetes/kubernetes/pull/121121) 146 | - Added `runtime_handler` field to type `ImageSpec` 147 | 148 | - [Add container filesystem to the ImageFsInfoResponse](https://github.com/kubernetes/kubernetes/pull/120914) 149 | - Added `container_filesystems` field to type `ImageFsInfoResponse` 150 | 151 | ### v1.28 152 | 153 | `git diff v1.27.0 v1.28.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 154 | 155 | - [cri-api: fix comment lines about PROPAGATION_PRIVATE](https://github.com/kubernetes/kubernetes/pull/115704) 156 | - Fixed comment lines about PROPAGATION_PRIVATE 157 | 158 | - [Add user specified image to CRI ContainerConfig](https://github.com/kubernetes/kubernetes/pull/118652) 159 | - Added the `user_specified_image` field to type `ImageSpec` 160 | 161 | - [kubelet: get cgroup driver config from CRI ](https://github.com/kubernetes/kubernetes/pull/118770) 162 | - Added rpc for querying runtime configuration 163 | - Added cavieats about cgroup driver field 164 | 165 | - [Add swap to stats to Summary API and Prometheus endpoints (/stats/summary and /metrics/resource)](https://github.com/kubernetes/kubernetes/pull/118865) 166 | - Added `SwapUsage` type 167 | - Added `SwapUsage` field to `ContainerStats` type 168 | 169 | - [Expose commit memory used in WindowsMemoryUsage struct](https://github.com/kubernetes/kubernetes/pull/119238) 170 | - Added the `commit_memory_bytes` field to type `WindowsMemoryUsage` 171 | 172 | ### v1.27 173 | 174 | `git diff v1.26.0 v1.27.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 175 | 176 | - [CRI: Add CDI device info for containers](https://github.com/kubernetes/kubernetes/pull/115891/) 177 | - New type `CDIDevice` was introduced and added to container config 178 | 179 | - [Add mappings for volumes](https://github.com/kubernetes/kubernetes/pull/116377) 180 | - Added new fields to the type `Mount` expressing runtime UID/GID mappings for the mount. 181 | 182 | ### v1.26 183 | 184 | `git diff v1.25.0 v1.26.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 185 | 186 | - [CRI: Add Windows Podsandbox Stats](https://github.com/kubernetes/kubernetes/pull/110754) 187 | - Added fields to the type `WindowsPodSandboxStats` expressing stats required to be collected from windows pods. 188 | 189 | - [Windows hostnetwork alpha](https://github.com/kubernetes/kubernetes/pull/112961) 190 | - New type `WindowsNamespaceOption` introduced 191 | - The type `WindowsSandboxSecurityContext` has a new field `namespace_options` of type `WindowsNamespaceOption` 192 | 193 | - [Improve the API description of `PodSecurityContext.SupplementalGroups` to clarify its unfamiliar behavior](https://github.com/kubernetes/kubernetes/pull/113047) 194 | - Clarified the expected behavior of `SupplementalGroups` field of `PodSecurityContext` 195 | 196 | - [Add Support for Evented PLEG](https://github.com/kubernetes/kubernetes/pull/111384) 197 | - The type `ContainerEventResponse` updated: the field `pod_sandbox_metadata` removed and fields `pod_sandbox_status` and `containers_statuses` added. 198 | - The type `PodSandboxStatusResponse` has a new fields `containers_statuses` and `timestamp` 199 | 200 | ### v1.25 201 | 202 | `git diff v1.24.0 v1.25.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 203 | 204 | - [kubelet: add CRI definitions for user namespaces](https://github.com/kubernetes/kubernetes/pull/110535) 205 | - The new type `UserNamespace` introduced to represent user namespaces id mapping 206 | - The type `NamespaceOption` has a new field `userns_options` of type `UserNamespace` 207 | 208 | - [Minimal checkpointing support](https://github.com/kubernetes/kubernetes/pull/104907) 209 | - The new method `CheckpointContainer` introduced with the corresponding request and response types 210 | 211 | - [Update CRI API to support Evented PLEG](https://github.com/kubernetes/kubernetes/pull/111642) 212 | - The new streaming method `GetContainerEvents` is introduced with the corresponding request and response types 213 | 214 | - [CRI changes to support in-place pod resize](https://github.com/kubernetes/kubernetes/pull/111645) 215 | - The new type `ContainerResources` is introduced 216 | - The type `ContainerStatus` has a new field `resources` of type `ContainerResources` 217 | - The semantic of `UpdateContainerResources` updated. The method must be implemented as synchronous and return error on failure 218 | 219 | ### v1.24 220 | 221 | `git diff v1.23.0 v1.24.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 222 | 223 | - [Update CRI-API Capabilities to include a field that allows us to set ambient capabilities](https://github.com/kubernetes/kubernetes/pull/104620) 224 | - The type `Capability` has a new string field `add_ambient_capabilities` 225 | 226 | - [CRI-API - Add rootfs size to WindowsContainerResources](https://github.com/kubernetes/kubernetes/pull/108894) 227 | - The type `WindowsContainerResources` has a new int64 field `rootfs_size_in_bytes` 228 | 229 | ### v1.23 230 | 231 | `git diff v1.22.0 v1.23.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 232 | 233 | - [CRI: add fields for pod level stats to satisfy the /stats/summary API](https://github.com/kubernetes/kubernetes/pull/102789) 234 | - New functions `PodSandboxStats`, `ListPodSandboxStats` with the corresponding types of request and response objects are introduced 235 | 236 | - [pass sandbox resource requirements over CRI](https://github.com/kubernetes/kubernetes/pull/104886) 237 | - New fields on `LinuxPodSandboxConfig`: `overhead` and `resources` of type `LinuxContainerResources`. 238 | 239 | - [prevents garbage collection from removing pinned images](https://github.com/kubernetes/kubernetes/pull/103299) 240 | - The type `Image` has a new boolean field `pinned` 241 | 242 | ### v1.22 243 | 244 | `git diff v1.21.0 v1.22.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 245 | 246 | - [Windows host process support](https://github.com/kubernetes/kubernetes/pull/99576) 247 | - `PodSandboxConfig` has `windows` field of type `WindowsPodSandboxConfig` 248 | - New type `WindowsPodSandboxConfig` introduced 249 | - New type `WindowsSandboxSecurityContext` introduced 250 | - The type `WindowsContainerSecurityContext` has a new `host_process` boolean field 251 | 252 | - [Feature: add unified on CRI to support cgroup v2](https://github.com/kubernetes/kubernetes/pull/102578) 253 | - The type `LinuxContainerResources` has a new field `unified` which is a map of strings 254 | 255 | - [Alpha node swap support](https://github.com/kubernetes/kubernetes/pull/102823) 256 | - The type `LinuxContainerResources` has a new `memory_swap_limit_in_bytes` int64 field 257 | 258 | ### v1.21 259 | 260 | `git diff v1.20.0 v1.21.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 261 | 262 | No changes 263 | 264 | ### v1.20 265 | 266 | `git diff v1.19.0 v1.20.0 -- staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto` 267 | 268 | - CRI [v1 introduced](https://github.com/kubernetes/kubernetes/pull/96387) 269 | -------------------------------------------------------------------------------- /pkg/apis/testing/fake_runtime_service.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package testing 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | "reflect" 23 | "sync" 24 | "time" 25 | 26 | "google.golang.org/protobuf/proto" 27 | runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" 28 | ) 29 | 30 | var ( 31 | // FakeVersion is a version of a fake runtime. 32 | FakeVersion = "0.1.0" 33 | 34 | // FakeRuntimeName is the name of the fake runtime. 35 | FakeRuntimeName = "fakeRuntime" 36 | 37 | // FakePodSandboxIPs is an IP address of the fake runtime. 38 | FakePodSandboxIPs = []string{"192.168.192.168"} 39 | ) 40 | 41 | // FakePodSandbox is the fake implementation of runtimeapi.PodSandboxStatus. 42 | type FakePodSandbox struct { 43 | // PodSandboxStatus contains the runtime information for a sandbox. 44 | runtimeapi.PodSandboxStatus 45 | // RuntimeHandler is the runtime handler that was issued with the RunPodSandbox request. 46 | RuntimeHandler string 47 | } 48 | 49 | // FakeContainer is a fake container. 50 | type FakeContainer struct { 51 | // ContainerStatus contains the runtime information for a container. 52 | runtimeapi.ContainerStatus 53 | 54 | // LinuxResources contains the resources specific to linux containers. 55 | LinuxResources *runtimeapi.LinuxContainerResources 56 | 57 | // the sandbox id of this container 58 | SandboxID string 59 | } 60 | 61 | // FakeRuntimeService is a fake runetime service. 62 | type FakeRuntimeService struct { 63 | sync.Mutex 64 | 65 | Called []string 66 | Errors map[string][]error 67 | 68 | FakeStatus *runtimeapi.RuntimeStatus 69 | Containers map[string]*FakeContainer 70 | Sandboxes map[string]*FakePodSandbox 71 | FakeContainerStats map[string]*runtimeapi.ContainerStats 72 | FakePodSandboxStats map[string]*runtimeapi.PodSandboxStats 73 | FakePodSandboxMetrics map[string]*runtimeapi.PodSandboxMetrics 74 | FakeMetricDescriptors map[string]*runtimeapi.MetricDescriptor 75 | FakeContainerMetrics map[string]*runtimeapi.ContainerMetrics 76 | FakeLinuxConfiguration *runtimeapi.LinuxRuntimeConfiguration 77 | 78 | ErrorOnSandboxCreate bool 79 | } 80 | 81 | // GetContainerID returns the unique container ID from the FakeRuntimeService. 82 | func (r *FakeRuntimeService) GetContainerID(sandboxID, name string, attempt uint32) (string, error) { 83 | r.Lock() 84 | defer r.Unlock() 85 | 86 | for id, c := range r.Containers { 87 | if c.SandboxID == sandboxID && c.Metadata.Name == name && c.Metadata.Attempt == attempt { 88 | return id, nil 89 | } 90 | } 91 | return "", fmt.Errorf("container (name, attempt, sandboxID)=(%q, %d, %q) not found", name, attempt, sandboxID) 92 | } 93 | 94 | // SetFakeSandboxes sets the fake sandboxes for the FakeRuntimeService. 95 | func (r *FakeRuntimeService) SetFakeSandboxes(sandboxes []*FakePodSandbox) { 96 | r.Lock() 97 | defer r.Unlock() 98 | 99 | r.Sandboxes = make(map[string]*FakePodSandbox) 100 | for _, sandbox := range sandboxes { 101 | sandboxID := sandbox.Id 102 | r.Sandboxes[sandboxID] = sandbox 103 | } 104 | } 105 | 106 | // SetFakeContainers sets fake containers for the FakeRuntimeService. 107 | func (r *FakeRuntimeService) SetFakeContainers(containers []*FakeContainer) { 108 | r.Lock() 109 | defer r.Unlock() 110 | 111 | r.Containers = make(map[string]*FakeContainer) 112 | for _, c := range containers { 113 | containerID := c.Id 114 | r.Containers[containerID] = c 115 | } 116 | 117 | } 118 | 119 | // AssertCalls validates whether specified calls were made to the FakeRuntimeService. 120 | func (r *FakeRuntimeService) AssertCalls(calls []string) error { 121 | r.Lock() 122 | defer r.Unlock() 123 | 124 | if !reflect.DeepEqual(calls, r.Called) { 125 | return fmt.Errorf("expected %#v, got %#v", calls, r.Called) 126 | } 127 | return nil 128 | } 129 | 130 | // GetCalls returns the list of calls made to the FakeRuntimeService. 131 | func (r *FakeRuntimeService) GetCalls() []string { 132 | r.Lock() 133 | defer r.Unlock() 134 | return append([]string{}, r.Called...) 135 | } 136 | 137 | // InjectError inject the error to the next call to the FakeRuntimeService. 138 | func (r *FakeRuntimeService) InjectError(f string, err error) { 139 | r.Lock() 140 | defer r.Unlock() 141 | r.Errors[f] = append(r.Errors[f], err) 142 | } 143 | 144 | // caller of popError must grab a lock. 145 | func (r *FakeRuntimeService) popError(f string) error { 146 | if r.Errors == nil { 147 | return nil 148 | } 149 | errs := r.Errors[f] 150 | if len(errs) == 0 { 151 | return nil 152 | } 153 | err, errs := errs[0], errs[1:] 154 | r.Errors[f] = errs 155 | return err 156 | } 157 | 158 | // NewFakeRuntimeService creates a new FakeRuntimeService. 159 | func NewFakeRuntimeService() *FakeRuntimeService { 160 | return &FakeRuntimeService{ 161 | Called: make([]string, 0), 162 | Errors: make(map[string][]error), 163 | Containers: make(map[string]*FakeContainer), 164 | Sandboxes: make(map[string]*FakePodSandbox), 165 | FakeContainerStats: make(map[string]*runtimeapi.ContainerStats), 166 | FakePodSandboxStats: make(map[string]*runtimeapi.PodSandboxStats), 167 | FakePodSandboxMetrics: make(map[string]*runtimeapi.PodSandboxMetrics), 168 | FakeContainerMetrics: make(map[string]*runtimeapi.ContainerMetrics), 169 | } 170 | } 171 | 172 | // Version returns version information from the FakeRuntimeService. 173 | func (r *FakeRuntimeService) Version(_ context.Context, apiVersion string) (*runtimeapi.VersionResponse, error) { 174 | r.Lock() 175 | defer r.Unlock() 176 | 177 | r.Called = append(r.Called, "Version") 178 | if err := r.popError("Version"); err != nil { 179 | return nil, err 180 | } 181 | 182 | return &runtimeapi.VersionResponse{ 183 | Version: FakeVersion, 184 | RuntimeName: FakeRuntimeName, 185 | RuntimeVersion: FakeVersion, 186 | RuntimeApiVersion: FakeVersion, 187 | }, nil 188 | } 189 | 190 | // Status returns runtime status of the FakeRuntimeService. 191 | func (r *FakeRuntimeService) Status(_ context.Context, verbose bool) (*runtimeapi.StatusResponse, error) { 192 | r.Lock() 193 | defer r.Unlock() 194 | 195 | r.Called = append(r.Called, "Status") 196 | if err := r.popError("Status"); err != nil { 197 | return nil, err 198 | } 199 | 200 | return &runtimeapi.StatusResponse{Status: r.FakeStatus}, nil 201 | } 202 | 203 | // RunPodSandbox emulates the run of the pod sandbox in the FakeRuntimeService. 204 | func (r *FakeRuntimeService) RunPodSandbox(_ context.Context, config *runtimeapi.PodSandboxConfig, runtimeHandler string) (string, error) { 205 | r.Lock() 206 | defer r.Unlock() 207 | 208 | r.Called = append(r.Called, "RunPodSandbox") 209 | if err := r.popError("RunPodSandbox"); err != nil { 210 | return "", err 211 | } 212 | 213 | if r.ErrorOnSandboxCreate { 214 | return "", fmt.Errorf("error on sandbox create") 215 | } 216 | 217 | // PodSandboxID should be randomized for real container runtime, but here just use 218 | // fixed name from BuildSandboxName() for easily making fake sandboxes. 219 | podSandboxID := BuildSandboxName(config.Metadata) 220 | createdAt := time.Now().UnixNano() 221 | r.Sandboxes[podSandboxID] = &FakePodSandbox{ 222 | PodSandboxStatus: runtimeapi.PodSandboxStatus{ 223 | Id: podSandboxID, 224 | Metadata: config.Metadata, 225 | State: runtimeapi.PodSandboxState_SANDBOX_READY, 226 | CreatedAt: createdAt, 227 | Network: &runtimeapi.PodSandboxNetworkStatus{ 228 | Ip: FakePodSandboxIPs[0], 229 | }, 230 | // Without setting sandboxStatus's Linux.Namespaces.Options, kubeGenericRuntimeManager's podSandboxChanged will consider it as network 231 | // namespace changed and always recreate sandbox which causes pod creation failed. 232 | // Ref `sandboxStatus.GetLinux().GetNamespaces().GetOptions().GetNetwork() != networkNamespaceForPod(pod)` in podSandboxChanged function. 233 | Linux: &runtimeapi.LinuxPodSandboxStatus{ 234 | Namespaces: &runtimeapi.Namespace{ 235 | Options: config.GetLinux().GetSecurityContext().GetNamespaceOptions(), 236 | }, 237 | }, 238 | Labels: config.Labels, 239 | Annotations: config.Annotations, 240 | RuntimeHandler: runtimeHandler, 241 | }, 242 | RuntimeHandler: runtimeHandler, 243 | } 244 | // assign additional IPs 245 | additionalIPs := FakePodSandboxIPs[1:] 246 | additionalPodIPs := make([]*runtimeapi.PodIP, 0, len(additionalIPs)) 247 | for _, ip := range additionalIPs { 248 | additionalPodIPs = append(additionalPodIPs, &runtimeapi.PodIP{ 249 | Ip: ip, 250 | }) 251 | } 252 | r.Sandboxes[podSandboxID].PodSandboxStatus.Network.AdditionalIps = additionalPodIPs 253 | return podSandboxID, nil 254 | } 255 | 256 | // StopPodSandbox emulates the stop of pod sandbox in the FakeRuntimeService. 257 | func (r *FakeRuntimeService) StopPodSandbox(_ context.Context, podSandboxID string) error { 258 | r.Lock() 259 | defer r.Unlock() 260 | 261 | r.Called = append(r.Called, "StopPodSandbox") 262 | if err := r.popError("StopPodSandbox"); err != nil { 263 | return err 264 | } 265 | 266 | if s, ok := r.Sandboxes[podSandboxID]; ok { 267 | s.State = runtimeapi.PodSandboxState_SANDBOX_NOTREADY 268 | } else { 269 | return fmt.Errorf("pod sandbox %s not found", podSandboxID) 270 | } 271 | 272 | return nil 273 | } 274 | 275 | // RemovePodSandbox emulates removal of the pod sadbox in the FakeRuntimeService. 276 | func (r *FakeRuntimeService) RemovePodSandbox(_ context.Context, podSandboxID string) error { 277 | r.Lock() 278 | defer r.Unlock() 279 | 280 | r.Called = append(r.Called, "RemovePodSandbox") 281 | if err := r.popError("RemovePodSandbox"); err != nil { 282 | return err 283 | } 284 | 285 | // Remove the pod sandbox 286 | delete(r.Sandboxes, podSandboxID) 287 | 288 | return nil 289 | } 290 | 291 | // PodSandboxStatus returns pod sandbox status from the FakeRuntimeService. 292 | func (r *FakeRuntimeService) PodSandboxStatus(_ context.Context, podSandboxID string, verbose bool) (*runtimeapi.PodSandboxStatusResponse, error) { 293 | r.Lock() 294 | defer r.Unlock() 295 | 296 | r.Called = append(r.Called, "PodSandboxStatus") 297 | if err := r.popError("PodSandboxStatus"); err != nil { 298 | return nil, err 299 | } 300 | 301 | s, ok := r.Sandboxes[podSandboxID] 302 | if !ok { 303 | return nil, fmt.Errorf("pod sandbox %q not found", podSandboxID) 304 | } 305 | 306 | status := proto.Clone(&s.PodSandboxStatus).(*runtimeapi.PodSandboxStatus) 307 | return &runtimeapi.PodSandboxStatusResponse{Status: status}, nil 308 | } 309 | 310 | // ListPodSandbox returns the list of pod sandboxes in the FakeRuntimeService. 311 | func (r *FakeRuntimeService) ListPodSandbox(_ context.Context, filter *runtimeapi.PodSandboxFilter) ([]*runtimeapi.PodSandbox, error) { 312 | r.Lock() 313 | defer r.Unlock() 314 | 315 | r.Called = append(r.Called, "ListPodSandbox") 316 | if err := r.popError("ListPodSandbox"); err != nil { 317 | return nil, err 318 | } 319 | 320 | result := make([]*runtimeapi.PodSandbox, 0) 321 | for id, s := range r.Sandboxes { 322 | if filter != nil { 323 | if filter.Id != "" && filter.Id != id { 324 | continue 325 | } 326 | if filter.State != nil && filter.GetState().State != s.State { 327 | continue 328 | } 329 | if filter.LabelSelector != nil && !filterInLabels(filter.LabelSelector, s.GetLabels()) { 330 | continue 331 | } 332 | } 333 | 334 | result = append(result, &runtimeapi.PodSandbox{ 335 | Id: s.Id, 336 | Metadata: s.Metadata, 337 | State: s.State, 338 | CreatedAt: s.CreatedAt, 339 | Labels: s.Labels, 340 | Annotations: s.Annotations, 341 | RuntimeHandler: s.RuntimeHandler, 342 | }) 343 | } 344 | 345 | return result, nil 346 | } 347 | 348 | // PortForward emulates the set up of port forward in the FakeRuntimeService. 349 | func (r *FakeRuntimeService) PortForward(context.Context, *runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error) { 350 | r.Lock() 351 | defer r.Unlock() 352 | 353 | r.Called = append(r.Called, "PortForward") 354 | if err := r.popError("PortForward"); err != nil { 355 | return nil, err 356 | } 357 | 358 | return &runtimeapi.PortForwardResponse{}, nil 359 | } 360 | 361 | // CreateContainer emulates container creation in the FakeRuntimeService. 362 | func (r *FakeRuntimeService) CreateContainer(_ context.Context, podSandboxID string, config *runtimeapi.ContainerConfig, sandboxConfig *runtimeapi.PodSandboxConfig) (string, error) { 363 | r.Lock() 364 | defer r.Unlock() 365 | 366 | r.Called = append(r.Called, "CreateContainer") 367 | if err := r.popError("CreateContainer"); err != nil { 368 | return "", err 369 | } 370 | 371 | // ContainerID should be randomized for real container runtime, but here just use 372 | // fixed BuildContainerName() for easily making fake containers. 373 | containerID := BuildContainerName(config.Metadata, podSandboxID) 374 | createdAt := time.Now().UnixNano() 375 | createdState := runtimeapi.ContainerState_CONTAINER_CREATED 376 | imageRef := config.Image.Image 377 | r.Containers[containerID] = &FakeContainer{ 378 | ContainerStatus: runtimeapi.ContainerStatus{ 379 | Id: containerID, 380 | Metadata: config.Metadata, 381 | Image: config.Image, 382 | ImageRef: imageRef, 383 | CreatedAt: createdAt, 384 | State: createdState, 385 | Labels: config.Labels, 386 | Annotations: config.Annotations, 387 | }, 388 | SandboxID: podSandboxID, 389 | LinuxResources: config.GetLinux().GetResources(), 390 | } 391 | 392 | return containerID, nil 393 | } 394 | 395 | // StartContainer emulates start of a container in the FakeRuntimeService. 396 | func (r *FakeRuntimeService) StartContainer(_ context.Context, containerID string) error { 397 | r.Lock() 398 | defer r.Unlock() 399 | 400 | r.Called = append(r.Called, "StartContainer") 401 | if err := r.popError("StartContainer"); err != nil { 402 | return err 403 | } 404 | 405 | c, ok := r.Containers[containerID] 406 | if !ok { 407 | return fmt.Errorf("container %s not found", containerID) 408 | } 409 | 410 | // Set container to running. 411 | c.State = runtimeapi.ContainerState_CONTAINER_RUNNING 412 | c.StartedAt = time.Now().UnixNano() 413 | 414 | return nil 415 | } 416 | 417 | // StopContainer emulates stop of a container in the FakeRuntimeService. 418 | func (r *FakeRuntimeService) StopContainer(_ context.Context, containerID string, timeout int64) error { 419 | r.Lock() 420 | defer r.Unlock() 421 | 422 | r.Called = append(r.Called, "StopContainer") 423 | if err := r.popError("StopContainer"); err != nil { 424 | return err 425 | } 426 | 427 | c, ok := r.Containers[containerID] 428 | if !ok { 429 | return fmt.Errorf("container %q not found", containerID) 430 | } 431 | 432 | // Set container to exited state. 433 | finishedAt := time.Now().UnixNano() 434 | exitedState := runtimeapi.ContainerState_CONTAINER_EXITED 435 | c.State = exitedState 436 | c.FinishedAt = finishedAt 437 | 438 | return nil 439 | } 440 | 441 | // RemoveContainer emulates remove of a container in the FakeRuntimeService. 442 | func (r *FakeRuntimeService) RemoveContainer(_ context.Context, containerID string) error { 443 | r.Lock() 444 | defer r.Unlock() 445 | 446 | r.Called = append(r.Called, "RemoveContainer") 447 | if err := r.popError("RemoveContainer"); err != nil { 448 | return err 449 | } 450 | 451 | // Remove the container 452 | delete(r.Containers, containerID) 453 | 454 | return nil 455 | } 456 | 457 | // ListContainers returns the list of containers in the FakeRuntimeService. 458 | func (r *FakeRuntimeService) ListContainers(_ context.Context, filter *runtimeapi.ContainerFilter) ([]*runtimeapi.Container, error) { 459 | r.Lock() 460 | defer r.Unlock() 461 | 462 | r.Called = append(r.Called, "ListContainers") 463 | if err := r.popError("ListContainers"); err != nil { 464 | return nil, err 465 | } 466 | 467 | result := make([]*runtimeapi.Container, 0) 468 | for _, s := range r.Containers { 469 | if filter != nil { 470 | if filter.Id != "" && filter.Id != s.Id { 471 | continue 472 | } 473 | if filter.PodSandboxId != "" && filter.PodSandboxId != s.SandboxID { 474 | continue 475 | } 476 | if filter.State != nil && filter.GetState().State != s.State { 477 | continue 478 | } 479 | if filter.LabelSelector != nil && !filterInLabels(filter.LabelSelector, s.GetLabels()) { 480 | continue 481 | } 482 | } 483 | 484 | result = append(result, &runtimeapi.Container{ 485 | Id: s.Id, 486 | CreatedAt: s.CreatedAt, 487 | PodSandboxId: s.SandboxID, 488 | Metadata: s.Metadata, 489 | State: s.State, 490 | Image: s.Image, 491 | ImageRef: s.ImageRef, 492 | Labels: s.Labels, 493 | Annotations: s.Annotations, 494 | }) 495 | } 496 | 497 | return result, nil 498 | } 499 | 500 | // ContainerStatus returns the container status given the container ID in FakeRuntimeService. 501 | func (r *FakeRuntimeService) ContainerStatus(_ context.Context, containerID string, verbose bool) (*runtimeapi.ContainerStatusResponse, error) { 502 | r.Lock() 503 | defer r.Unlock() 504 | 505 | r.Called = append(r.Called, "ContainerStatus") 506 | if err := r.popError("ContainerStatus"); err != nil { 507 | return nil, err 508 | } 509 | 510 | c, ok := r.Containers[containerID] 511 | if !ok { 512 | return nil, fmt.Errorf("container %q not found", containerID) 513 | } 514 | 515 | status := proto.Clone(&c.ContainerStatus).(*runtimeapi.ContainerStatus) 516 | return &runtimeapi.ContainerStatusResponse{Status: status}, nil 517 | } 518 | 519 | // UpdateContainerResources returns the container resource in the FakeRuntimeService. 520 | func (r *FakeRuntimeService) UpdateContainerResources(context.Context, string, *runtimeapi.ContainerResources) error { 521 | r.Lock() 522 | defer r.Unlock() 523 | 524 | r.Called = append(r.Called, "UpdateContainerResources") 525 | return r.popError("UpdateContainerResources") 526 | } 527 | 528 | // ExecSync emulates the sync execution of a command in a container in the FakeRuntimeService. 529 | func (r *FakeRuntimeService) ExecSync(_ context.Context, containerID string, cmd []string, timeout time.Duration) (stdout []byte, stderr []byte, err error) { 530 | r.Lock() 531 | defer r.Unlock() 532 | 533 | r.Called = append(r.Called, "ExecSync") 534 | err = r.popError("ExecSync") 535 | return 536 | } 537 | 538 | // Exec emulates the execution of a command in a container in the FakeRuntimeService. 539 | func (r *FakeRuntimeService) Exec(context.Context, *runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error) { 540 | r.Lock() 541 | defer r.Unlock() 542 | 543 | r.Called = append(r.Called, "Exec") 544 | if err := r.popError("Exec"); err != nil { 545 | return nil, err 546 | } 547 | 548 | return &runtimeapi.ExecResponse{}, nil 549 | } 550 | 551 | // Attach emulates the attach request in the FakeRuntimeService. 552 | func (r *FakeRuntimeService) Attach(_ context.Context, req *runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error) { 553 | r.Lock() 554 | defer r.Unlock() 555 | 556 | r.Called = append(r.Called, "Attach") 557 | if err := r.popError("Attach"); err != nil { 558 | return nil, err 559 | } 560 | 561 | return &runtimeapi.AttachResponse{}, nil 562 | } 563 | 564 | // UpdateRuntimeConfig emulates the update of a runtime config for the FakeRuntimeService. 565 | func (r *FakeRuntimeService) UpdateRuntimeConfig(_ context.Context, runtimeCOnfig *runtimeapi.RuntimeConfig) error { 566 | r.Lock() 567 | defer r.Unlock() 568 | 569 | r.Called = append(r.Called, "UpdateRuntimeConfig") 570 | return r.popError("UpdateRuntimeConfig") 571 | } 572 | 573 | // SetFakeContainerStats sets the fake container stats in the FakeRuntimeService. 574 | func (r *FakeRuntimeService) SetFakeContainerStats(containerStats []*runtimeapi.ContainerStats) { 575 | r.Lock() 576 | defer r.Unlock() 577 | 578 | r.FakeContainerStats = make(map[string]*runtimeapi.ContainerStats) 579 | for _, s := range containerStats { 580 | r.FakeContainerStats[s.Attributes.Id] = s 581 | } 582 | } 583 | 584 | // ContainerStats returns the container stats in the FakeRuntimeService. 585 | func (r *FakeRuntimeService) ContainerStats(_ context.Context, containerID string) (*runtimeapi.ContainerStats, error) { 586 | r.Lock() 587 | defer r.Unlock() 588 | 589 | r.Called = append(r.Called, "ContainerStats") 590 | if err := r.popError("ContainerStats"); err != nil { 591 | return nil, err 592 | } 593 | 594 | s, found := r.FakeContainerStats[containerID] 595 | if !found { 596 | return nil, fmt.Errorf("no stats for container %q", containerID) 597 | } 598 | return s, nil 599 | } 600 | 601 | // ListContainerStats returns the list of all container stats given the filter in the FakeRuntimeService. 602 | func (r *FakeRuntimeService) ListContainerStats(_ context.Context, filter *runtimeapi.ContainerStatsFilter) ([]*runtimeapi.ContainerStats, error) { 603 | r.Lock() 604 | defer r.Unlock() 605 | 606 | r.Called = append(r.Called, "ListContainerStats") 607 | if err := r.popError("ListContainerStats"); err != nil { 608 | return nil, err 609 | } 610 | 611 | var result []*runtimeapi.ContainerStats 612 | for _, c := range r.Containers { 613 | if filter != nil { 614 | if filter.Id != "" && filter.Id != c.Id { 615 | continue 616 | } 617 | if filter.PodSandboxId != "" && filter.PodSandboxId != c.SandboxID { 618 | continue 619 | } 620 | if filter.LabelSelector != nil && !filterInLabels(filter.LabelSelector, c.GetLabels()) { 621 | continue 622 | } 623 | } 624 | s, found := r.FakeContainerStats[c.Id] 625 | if !found { 626 | continue 627 | } 628 | result = append(result, s) 629 | } 630 | 631 | return result, nil 632 | } 633 | 634 | // SetFakePodSandboxStats sets the fake pod sandbox stats in the FakeRuntimeService. 635 | func (r *FakeRuntimeService) SetFakePodSandboxStats(podStats []*runtimeapi.PodSandboxStats) { 636 | r.Lock() 637 | defer r.Unlock() 638 | 639 | r.FakePodSandboxStats = make(map[string]*runtimeapi.PodSandboxStats) 640 | for _, s := range podStats { 641 | r.FakePodSandboxStats[s.Attributes.Id] = s 642 | } 643 | } 644 | 645 | // PodSandboxStats returns the sandbox stats in the FakeRuntimeService. 646 | func (r *FakeRuntimeService) PodSandboxStats(_ context.Context, podSandboxID string) (*runtimeapi.PodSandboxStats, error) { 647 | r.Lock() 648 | defer r.Unlock() 649 | 650 | r.Called = append(r.Called, "PodSandboxStats") 651 | if err := r.popError("PodSandboxStats"); err != nil { 652 | return nil, err 653 | } 654 | 655 | s, found := r.FakePodSandboxStats[podSandboxID] 656 | if !found { 657 | return nil, fmt.Errorf("no stats for pod sandbox %q", podSandboxID) 658 | } 659 | return s, nil 660 | } 661 | 662 | // ListPodSandboxStats returns the list of all pod sandbox stats given the filter in the FakeRuntimeService. 663 | func (r *FakeRuntimeService) ListPodSandboxStats(_ context.Context, filter *runtimeapi.PodSandboxStatsFilter) ([]*runtimeapi.PodSandboxStats, error) { 664 | r.Lock() 665 | defer r.Unlock() 666 | 667 | r.Called = append(r.Called, "ListPodSandboxStats") 668 | if err := r.popError("ListPodSandboxStats"); err != nil { 669 | return nil, err 670 | } 671 | 672 | var result []*runtimeapi.PodSandboxStats 673 | for _, sb := range r.Sandboxes { 674 | if filter != nil { 675 | if filter.Id != "" && filter.Id != sb.Id { 676 | continue 677 | } 678 | if filter.LabelSelector != nil && !filterInLabels(filter.LabelSelector, sb.GetLabels()) { 679 | continue 680 | } 681 | } 682 | s, found := r.FakePodSandboxStats[sb.Id] 683 | if !found { 684 | continue 685 | } 686 | result = append(result, s) 687 | } 688 | 689 | return result, nil 690 | } 691 | 692 | // ReopenContainerLog emulates call to the reopen container log in the FakeRuntimeService. 693 | func (r *FakeRuntimeService) ReopenContainerLog(_ context.Context, containerID string) error { 694 | r.Lock() 695 | defer r.Unlock() 696 | 697 | r.Called = append(r.Called, "ReopenContainerLog") 698 | 699 | if err := r.popError("ReopenContainerLog"); err != nil { 700 | return err 701 | } 702 | 703 | return nil 704 | } 705 | 706 | // CheckpointContainer emulates call to checkpoint a container in the FakeRuntimeService. 707 | func (r *FakeRuntimeService) CheckpointContainer(_ context.Context, options *runtimeapi.CheckpointContainerRequest) error { 708 | r.Lock() 709 | defer r.Unlock() 710 | 711 | r.Called = append(r.Called, "CheckpointContainer") 712 | 713 | if err := r.popError("CheckpointContainer"); err != nil { 714 | return err 715 | } 716 | 717 | return nil 718 | } 719 | 720 | func (f *FakeRuntimeService) GetContainerEvents(ctx context.Context, containerEventsCh chan *runtimeapi.ContainerEventResponse, connectionEstablishedCallback func(runtimeapi.RuntimeService_GetContainerEventsClient)) error { 721 | return nil 722 | } 723 | 724 | // SetFakeMetricDescriptors sets the fake metrics descriptors in the FakeRuntimeService. 725 | func (r *FakeRuntimeService) SetFakeMetricDescriptors(descs []*runtimeapi.MetricDescriptor) { 726 | r.Lock() 727 | defer r.Unlock() 728 | 729 | r.FakeMetricDescriptors = make(map[string]*runtimeapi.MetricDescriptor) 730 | for _, d := range descs { 731 | r.FakeMetricDescriptors[d.Name] = d 732 | } 733 | } 734 | 735 | // ListMetricDescriptors gets the descriptors for the metrics that will be returned in ListPodSandboxMetrics. 736 | func (r *FakeRuntimeService) ListMetricDescriptors(_ context.Context) ([]*runtimeapi.MetricDescriptor, error) { 737 | r.Lock() 738 | defer r.Unlock() 739 | 740 | r.Called = append(r.Called, "ListMetricDescriptors") 741 | if err := r.popError("ListMetricDescriptors"); err != nil { 742 | return nil, err 743 | } 744 | 745 | descs := make([]*runtimeapi.MetricDescriptor, 0, len(r.FakeMetricDescriptors)) 746 | for _, d := range r.FakeMetricDescriptors { 747 | descs = append(descs, d) 748 | } 749 | 750 | return descs, nil 751 | } 752 | 753 | // SetFakePodSandboxMetrics sets the fake pod sandbox metrics in the FakeRuntimeService. 754 | func (r *FakeRuntimeService) SetFakePodSandboxMetrics(podStats []*runtimeapi.PodSandboxMetrics) { 755 | r.Lock() 756 | defer r.Unlock() 757 | 758 | r.FakePodSandboxMetrics = make(map[string]*runtimeapi.PodSandboxMetrics) 759 | for _, s := range podStats { 760 | r.FakePodSandboxMetrics[s.PodSandboxId] = s 761 | } 762 | } 763 | 764 | // ListPodSandboxMetrics returns the list of all pod sandbox metrics in the FakeRuntimeService. 765 | func (r *FakeRuntimeService) ListPodSandboxMetrics(_ context.Context) ([]*runtimeapi.PodSandboxMetrics, error) { 766 | r.Lock() 767 | defer r.Unlock() 768 | 769 | r.Called = append(r.Called, "ListPodSandboxMetrics") 770 | if err := r.popError("ListPodSandboxMetrics"); err != nil { 771 | return nil, err 772 | } 773 | 774 | var result []*runtimeapi.PodSandboxMetrics 775 | for _, sb := range r.Sandboxes { 776 | s, found := r.FakePodSandboxMetrics[sb.Id] 777 | if !found { 778 | continue 779 | } 780 | result = append(result, s) 781 | } 782 | 783 | return result, nil 784 | } 785 | 786 | // RuntimeConfig returns runtime configuration of the FakeRuntimeService. 787 | func (r *FakeRuntimeService) RuntimeConfig(_ context.Context) (*runtimeapi.RuntimeConfigResponse, error) { 788 | r.Lock() 789 | defer r.Unlock() 790 | 791 | r.Called = append(r.Called, "RuntimeConfig") 792 | if err := r.popError("RuntimeConfig"); err != nil { 793 | return nil, err 794 | } 795 | 796 | return &runtimeapi.RuntimeConfigResponse{Linux: r.FakeLinuxConfiguration}, nil 797 | } 798 | 799 | // UpdatePodSandboxResources returns the container resource in the FakeRuntimeService. 800 | func (r *FakeRuntimeService) UpdatePodSandboxResources(context.Context, *runtimeapi.UpdatePodSandboxResourcesRequest) (*runtimeapi.UpdatePodSandboxResourcesResponse, error) { 801 | r.Lock() 802 | defer r.Unlock() 803 | 804 | r.Called = append(r.Called, "UpdatePodSandboxResources") 805 | if err := r.popError("UpdatePodSandboxResources"); err != nil { 806 | return nil, err 807 | } 808 | 809 | return &runtimeapi.UpdatePodSandboxResourcesResponse{}, nil 810 | } 811 | 812 | // Close will shutdown the internal gRPC client connection. 813 | func (r *FakeRuntimeService) Close() error { 814 | r.Lock() 815 | defer r.Unlock() 816 | 817 | r.Called = append(r.Called, "Close") 818 | if err := r.popError("Close"); err != nil { 819 | return err 820 | } 821 | 822 | return nil 823 | } 824 | -------------------------------------------------------------------------------- /pkg/apis/runtime/v1/api_grpc.pb.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The Kubernetes Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // 18 | //Copyright 2020 The Kubernetes Authors. 19 | // 20 | //Licensed under the Apache License, Version 2.0 (the "License"); 21 | //you may not use this file except in compliance with the License. 22 | //You may obtain a copy of the License at 23 | // 24 | //http://www.apache.org/licenses/LICENSE-2.0 25 | // 26 | //Unless required by applicable law or agreed to in writing, software 27 | //distributed under the License is distributed on an "AS IS" BASIS, 28 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | //See the License for the specific language governing permissions and 30 | //limitations under the License. 31 | 32 | // To regenerate api.pb.go run `hack/update-codegen.sh protobindings` 33 | 34 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 35 | // versions: 36 | // - protoc-gen-go-grpc v1.5.1 37 | // - protoc v4.23.4 38 | // source: staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto 39 | 40 | package v1 41 | 42 | import ( 43 | context "context" 44 | grpc "google.golang.org/grpc" 45 | codes "google.golang.org/grpc/codes" 46 | status "google.golang.org/grpc/status" 47 | ) 48 | 49 | // This is a compile-time assertion to ensure that this generated file 50 | // is compatible with the grpc package it is being compiled against. 51 | // Requires gRPC-Go v1.64.0 or later. 52 | const _ = grpc.SupportPackageIsVersion9 53 | 54 | const ( 55 | RuntimeService_Version_FullMethodName = "/runtime.v1.RuntimeService/Version" 56 | RuntimeService_RunPodSandbox_FullMethodName = "/runtime.v1.RuntimeService/RunPodSandbox" 57 | RuntimeService_StopPodSandbox_FullMethodName = "/runtime.v1.RuntimeService/StopPodSandbox" 58 | RuntimeService_RemovePodSandbox_FullMethodName = "/runtime.v1.RuntimeService/RemovePodSandbox" 59 | RuntimeService_PodSandboxStatus_FullMethodName = "/runtime.v1.RuntimeService/PodSandboxStatus" 60 | RuntimeService_ListPodSandbox_FullMethodName = "/runtime.v1.RuntimeService/ListPodSandbox" 61 | RuntimeService_CreateContainer_FullMethodName = "/runtime.v1.RuntimeService/CreateContainer" 62 | RuntimeService_StartContainer_FullMethodName = "/runtime.v1.RuntimeService/StartContainer" 63 | RuntimeService_StopContainer_FullMethodName = "/runtime.v1.RuntimeService/StopContainer" 64 | RuntimeService_RemoveContainer_FullMethodName = "/runtime.v1.RuntimeService/RemoveContainer" 65 | RuntimeService_ListContainers_FullMethodName = "/runtime.v1.RuntimeService/ListContainers" 66 | RuntimeService_ContainerStatus_FullMethodName = "/runtime.v1.RuntimeService/ContainerStatus" 67 | RuntimeService_UpdateContainerResources_FullMethodName = "/runtime.v1.RuntimeService/UpdateContainerResources" 68 | RuntimeService_ReopenContainerLog_FullMethodName = "/runtime.v1.RuntimeService/ReopenContainerLog" 69 | RuntimeService_ExecSync_FullMethodName = "/runtime.v1.RuntimeService/ExecSync" 70 | RuntimeService_Exec_FullMethodName = "/runtime.v1.RuntimeService/Exec" 71 | RuntimeService_Attach_FullMethodName = "/runtime.v1.RuntimeService/Attach" 72 | RuntimeService_PortForward_FullMethodName = "/runtime.v1.RuntimeService/PortForward" 73 | RuntimeService_ContainerStats_FullMethodName = "/runtime.v1.RuntimeService/ContainerStats" 74 | RuntimeService_ListContainerStats_FullMethodName = "/runtime.v1.RuntimeService/ListContainerStats" 75 | RuntimeService_PodSandboxStats_FullMethodName = "/runtime.v1.RuntimeService/PodSandboxStats" 76 | RuntimeService_ListPodSandboxStats_FullMethodName = "/runtime.v1.RuntimeService/ListPodSandboxStats" 77 | RuntimeService_UpdateRuntimeConfig_FullMethodName = "/runtime.v1.RuntimeService/UpdateRuntimeConfig" 78 | RuntimeService_Status_FullMethodName = "/runtime.v1.RuntimeService/Status" 79 | RuntimeService_CheckpointContainer_FullMethodName = "/runtime.v1.RuntimeService/CheckpointContainer" 80 | RuntimeService_GetContainerEvents_FullMethodName = "/runtime.v1.RuntimeService/GetContainerEvents" 81 | RuntimeService_ListMetricDescriptors_FullMethodName = "/runtime.v1.RuntimeService/ListMetricDescriptors" 82 | RuntimeService_ListPodSandboxMetrics_FullMethodName = "/runtime.v1.RuntimeService/ListPodSandboxMetrics" 83 | RuntimeService_RuntimeConfig_FullMethodName = "/runtime.v1.RuntimeService/RuntimeConfig" 84 | RuntimeService_UpdatePodSandboxResources_FullMethodName = "/runtime.v1.RuntimeService/UpdatePodSandboxResources" 85 | ) 86 | 87 | // RuntimeServiceClient is the client API for RuntimeService service. 88 | // 89 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 90 | // 91 | // Runtime service defines the public APIs for remote container runtimes 92 | type RuntimeServiceClient interface { 93 | // Version returns the runtime name, runtime version, and runtime API version. 94 | Version(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*VersionResponse, error) 95 | // RunPodSandbox creates and starts a pod-level sandbox. Runtimes must ensure 96 | // the sandbox is in the ready state on success. 97 | RunPodSandbox(ctx context.Context, in *RunPodSandboxRequest, opts ...grpc.CallOption) (*RunPodSandboxResponse, error) 98 | // StopPodSandbox stops any running process that is part of the sandbox and 99 | // reclaims network resources (e.g., IP addresses) allocated to the sandbox. 100 | // If there are any running containers in the sandbox, they must be forcibly 101 | // terminated. 102 | // This call is idempotent, and must not return an error if all relevant 103 | // resources have already been reclaimed. kubelet will call StopPodSandbox 104 | // at least once before calling RemovePodSandbox. It will also attempt to 105 | // reclaim resources eagerly, as soon as a sandbox is not needed. Hence, 106 | // multiple StopPodSandbox calls are expected. 107 | StopPodSandbox(ctx context.Context, in *StopPodSandboxRequest, opts ...grpc.CallOption) (*StopPodSandboxResponse, error) 108 | // RemovePodSandbox removes the sandbox. If there are any running containers 109 | // in the sandbox, they must be forcibly terminated and removed. 110 | // This call is idempotent, and must not return an error if the sandbox has 111 | // already been removed. 112 | RemovePodSandbox(ctx context.Context, in *RemovePodSandboxRequest, opts ...grpc.CallOption) (*RemovePodSandboxResponse, error) 113 | // PodSandboxStatus returns the status of the PodSandbox. If the PodSandbox is not 114 | // present, returns an error. 115 | PodSandboxStatus(ctx context.Context, in *PodSandboxStatusRequest, opts ...grpc.CallOption) (*PodSandboxStatusResponse, error) 116 | // ListPodSandbox returns a list of PodSandboxes. 117 | ListPodSandbox(ctx context.Context, in *ListPodSandboxRequest, opts ...grpc.CallOption) (*ListPodSandboxResponse, error) 118 | // CreateContainer creates a new container in specified PodSandbox 119 | CreateContainer(ctx context.Context, in *CreateContainerRequest, opts ...grpc.CallOption) (*CreateContainerResponse, error) 120 | // StartContainer starts the container. 121 | StartContainer(ctx context.Context, in *StartContainerRequest, opts ...grpc.CallOption) (*StartContainerResponse, error) 122 | // StopContainer stops a running container with a grace period (i.e., timeout). 123 | // This call is idempotent, and must not return an error if the container has 124 | // already been stopped. 125 | // The runtime must forcibly kill the container after the grace period is 126 | // reached. 127 | StopContainer(ctx context.Context, in *StopContainerRequest, opts ...grpc.CallOption) (*StopContainerResponse, error) 128 | // RemoveContainer removes the container. If the container is running, the 129 | // container must be forcibly removed. 130 | // This call is idempotent, and must not return an error if the container has 131 | // already been removed. 132 | RemoveContainer(ctx context.Context, in *RemoveContainerRequest, opts ...grpc.CallOption) (*RemoveContainerResponse, error) 133 | // ListContainers lists all containers by filters. 134 | ListContainers(ctx context.Context, in *ListContainersRequest, opts ...grpc.CallOption) (*ListContainersResponse, error) 135 | // ContainerStatus returns status of the container. If the container is not 136 | // present, returns an error. 137 | ContainerStatus(ctx context.Context, in *ContainerStatusRequest, opts ...grpc.CallOption) (*ContainerStatusResponse, error) 138 | // UpdateContainerResources updates ContainerConfig of the container synchronously. 139 | // If runtime fails to transactionally update the requested resources, an error is returned. 140 | UpdateContainerResources(ctx context.Context, in *UpdateContainerResourcesRequest, opts ...grpc.CallOption) (*UpdateContainerResourcesResponse, error) 141 | // ReopenContainerLog asks runtime to reopen the stdout/stderr log file 142 | // for the container. This is often called after the log file has been 143 | // rotated. If the container is not running, container runtime can choose 144 | // to either create a new log file and return nil, or return an error. 145 | // Once it returns error, new container log file MUST NOT be created. 146 | ReopenContainerLog(ctx context.Context, in *ReopenContainerLogRequest, opts ...grpc.CallOption) (*ReopenContainerLogResponse, error) 147 | // ExecSync runs a command in a container synchronously. 148 | ExecSync(ctx context.Context, in *ExecSyncRequest, opts ...grpc.CallOption) (*ExecSyncResponse, error) 149 | // Exec prepares a streaming endpoint to execute a command in the container. 150 | Exec(ctx context.Context, in *ExecRequest, opts ...grpc.CallOption) (*ExecResponse, error) 151 | // Attach prepares a streaming endpoint to attach to a running container. 152 | Attach(ctx context.Context, in *AttachRequest, opts ...grpc.CallOption) (*AttachResponse, error) 153 | // PortForward prepares a streaming endpoint to forward ports from a PodSandbox. 154 | PortForward(ctx context.Context, in *PortForwardRequest, opts ...grpc.CallOption) (*PortForwardResponse, error) 155 | // ContainerStats returns stats of the container. If the container does not 156 | // exist, the call returns an error. 157 | ContainerStats(ctx context.Context, in *ContainerStatsRequest, opts ...grpc.CallOption) (*ContainerStatsResponse, error) 158 | // ListContainerStats returns stats of all running containers. 159 | ListContainerStats(ctx context.Context, in *ListContainerStatsRequest, opts ...grpc.CallOption) (*ListContainerStatsResponse, error) 160 | // PodSandboxStats returns stats of the pod sandbox. If the pod sandbox does not 161 | // exist, the call returns an error. 162 | PodSandboxStats(ctx context.Context, in *PodSandboxStatsRequest, opts ...grpc.CallOption) (*PodSandboxStatsResponse, error) 163 | // ListPodSandboxStats returns stats of the pod sandboxes matching a filter. 164 | ListPodSandboxStats(ctx context.Context, in *ListPodSandboxStatsRequest, opts ...grpc.CallOption) (*ListPodSandboxStatsResponse, error) 165 | // UpdateRuntimeConfig updates the runtime configuration based on the given request. 166 | UpdateRuntimeConfig(ctx context.Context, in *UpdateRuntimeConfigRequest, opts ...grpc.CallOption) (*UpdateRuntimeConfigResponse, error) 167 | // Status returns the status of the runtime. 168 | Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) 169 | // CheckpointContainer checkpoints a container 170 | CheckpointContainer(ctx context.Context, in *CheckpointContainerRequest, opts ...grpc.CallOption) (*CheckpointContainerResponse, error) 171 | // GetContainerEvents gets container events from the CRI runtime 172 | GetContainerEvents(ctx context.Context, in *GetEventsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ContainerEventResponse], error) 173 | // ListMetricDescriptors gets the descriptors for the metrics that will be returned in ListPodSandboxMetrics. 174 | // This list should be static at startup: either the client and server restart together when 175 | // adding or removing metrics descriptors, or they should not change. 176 | // Put differently, if ListPodSandboxMetrics references a name that is not described in the initial 177 | // ListMetricDescriptors call, then the metric will not be broadcasted. 178 | ListMetricDescriptors(ctx context.Context, in *ListMetricDescriptorsRequest, opts ...grpc.CallOption) (*ListMetricDescriptorsResponse, error) 179 | // ListPodSandboxMetrics gets pod sandbox metrics from CRI Runtime 180 | ListPodSandboxMetrics(ctx context.Context, in *ListPodSandboxMetricsRequest, opts ...grpc.CallOption) (*ListPodSandboxMetricsResponse, error) 181 | // RuntimeConfig returns configuration information of the runtime. 182 | // A couple of notes: 183 | // - The RuntimeConfigRequest object is not to be confused with the contents of UpdateRuntimeConfigRequest. 184 | // The former is for having runtime tell Kubelet what to do, the latter vice versa. 185 | // - It is the expectation of the Kubelet that these fields are static for the lifecycle of the Kubelet. 186 | // The Kubelet will not re-request the RuntimeConfiguration after startup, and CRI implementations should 187 | // avoid updating them without a full node reboot. 188 | RuntimeConfig(ctx context.Context, in *RuntimeConfigRequest, opts ...grpc.CallOption) (*RuntimeConfigResponse, error) 189 | // UpdatePodSandboxResources synchronously updates the PodSandboxConfig with 190 | // the pod-level resource configuration. This method is called _after_ the 191 | // Kubelet reconfigures the pod-level cgroups. 192 | // This request is treated as best effort, and failure will not block the 193 | // Kubelet with proceeding with a resize. 194 | UpdatePodSandboxResources(ctx context.Context, in *UpdatePodSandboxResourcesRequest, opts ...grpc.CallOption) (*UpdatePodSandboxResourcesResponse, error) 195 | } 196 | 197 | type runtimeServiceClient struct { 198 | cc grpc.ClientConnInterface 199 | } 200 | 201 | func NewRuntimeServiceClient(cc grpc.ClientConnInterface) RuntimeServiceClient { 202 | return &runtimeServiceClient{cc} 203 | } 204 | 205 | func (c *runtimeServiceClient) Version(ctx context.Context, in *VersionRequest, opts ...grpc.CallOption) (*VersionResponse, error) { 206 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 207 | out := new(VersionResponse) 208 | err := c.cc.Invoke(ctx, RuntimeService_Version_FullMethodName, in, out, cOpts...) 209 | if err != nil { 210 | return nil, err 211 | } 212 | return out, nil 213 | } 214 | 215 | func (c *runtimeServiceClient) RunPodSandbox(ctx context.Context, in *RunPodSandboxRequest, opts ...grpc.CallOption) (*RunPodSandboxResponse, error) { 216 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 217 | out := new(RunPodSandboxResponse) 218 | err := c.cc.Invoke(ctx, RuntimeService_RunPodSandbox_FullMethodName, in, out, cOpts...) 219 | if err != nil { 220 | return nil, err 221 | } 222 | return out, nil 223 | } 224 | 225 | func (c *runtimeServiceClient) StopPodSandbox(ctx context.Context, in *StopPodSandboxRequest, opts ...grpc.CallOption) (*StopPodSandboxResponse, error) { 226 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 227 | out := new(StopPodSandboxResponse) 228 | err := c.cc.Invoke(ctx, RuntimeService_StopPodSandbox_FullMethodName, in, out, cOpts...) 229 | if err != nil { 230 | return nil, err 231 | } 232 | return out, nil 233 | } 234 | 235 | func (c *runtimeServiceClient) RemovePodSandbox(ctx context.Context, in *RemovePodSandboxRequest, opts ...grpc.CallOption) (*RemovePodSandboxResponse, error) { 236 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 237 | out := new(RemovePodSandboxResponse) 238 | err := c.cc.Invoke(ctx, RuntimeService_RemovePodSandbox_FullMethodName, in, out, cOpts...) 239 | if err != nil { 240 | return nil, err 241 | } 242 | return out, nil 243 | } 244 | 245 | func (c *runtimeServiceClient) PodSandboxStatus(ctx context.Context, in *PodSandboxStatusRequest, opts ...grpc.CallOption) (*PodSandboxStatusResponse, error) { 246 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 247 | out := new(PodSandboxStatusResponse) 248 | err := c.cc.Invoke(ctx, RuntimeService_PodSandboxStatus_FullMethodName, in, out, cOpts...) 249 | if err != nil { 250 | return nil, err 251 | } 252 | return out, nil 253 | } 254 | 255 | func (c *runtimeServiceClient) ListPodSandbox(ctx context.Context, in *ListPodSandboxRequest, opts ...grpc.CallOption) (*ListPodSandboxResponse, error) { 256 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 257 | out := new(ListPodSandboxResponse) 258 | err := c.cc.Invoke(ctx, RuntimeService_ListPodSandbox_FullMethodName, in, out, cOpts...) 259 | if err != nil { 260 | return nil, err 261 | } 262 | return out, nil 263 | } 264 | 265 | func (c *runtimeServiceClient) CreateContainer(ctx context.Context, in *CreateContainerRequest, opts ...grpc.CallOption) (*CreateContainerResponse, error) { 266 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 267 | out := new(CreateContainerResponse) 268 | err := c.cc.Invoke(ctx, RuntimeService_CreateContainer_FullMethodName, in, out, cOpts...) 269 | if err != nil { 270 | return nil, err 271 | } 272 | return out, nil 273 | } 274 | 275 | func (c *runtimeServiceClient) StartContainer(ctx context.Context, in *StartContainerRequest, opts ...grpc.CallOption) (*StartContainerResponse, error) { 276 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 277 | out := new(StartContainerResponse) 278 | err := c.cc.Invoke(ctx, RuntimeService_StartContainer_FullMethodName, in, out, cOpts...) 279 | if err != nil { 280 | return nil, err 281 | } 282 | return out, nil 283 | } 284 | 285 | func (c *runtimeServiceClient) StopContainer(ctx context.Context, in *StopContainerRequest, opts ...grpc.CallOption) (*StopContainerResponse, error) { 286 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 287 | out := new(StopContainerResponse) 288 | err := c.cc.Invoke(ctx, RuntimeService_StopContainer_FullMethodName, in, out, cOpts...) 289 | if err != nil { 290 | return nil, err 291 | } 292 | return out, nil 293 | } 294 | 295 | func (c *runtimeServiceClient) RemoveContainer(ctx context.Context, in *RemoveContainerRequest, opts ...grpc.CallOption) (*RemoveContainerResponse, error) { 296 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 297 | out := new(RemoveContainerResponse) 298 | err := c.cc.Invoke(ctx, RuntimeService_RemoveContainer_FullMethodName, in, out, cOpts...) 299 | if err != nil { 300 | return nil, err 301 | } 302 | return out, nil 303 | } 304 | 305 | func (c *runtimeServiceClient) ListContainers(ctx context.Context, in *ListContainersRequest, opts ...grpc.CallOption) (*ListContainersResponse, error) { 306 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 307 | out := new(ListContainersResponse) 308 | err := c.cc.Invoke(ctx, RuntimeService_ListContainers_FullMethodName, in, out, cOpts...) 309 | if err != nil { 310 | return nil, err 311 | } 312 | return out, nil 313 | } 314 | 315 | func (c *runtimeServiceClient) ContainerStatus(ctx context.Context, in *ContainerStatusRequest, opts ...grpc.CallOption) (*ContainerStatusResponse, error) { 316 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 317 | out := new(ContainerStatusResponse) 318 | err := c.cc.Invoke(ctx, RuntimeService_ContainerStatus_FullMethodName, in, out, cOpts...) 319 | if err != nil { 320 | return nil, err 321 | } 322 | return out, nil 323 | } 324 | 325 | func (c *runtimeServiceClient) UpdateContainerResources(ctx context.Context, in *UpdateContainerResourcesRequest, opts ...grpc.CallOption) (*UpdateContainerResourcesResponse, error) { 326 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 327 | out := new(UpdateContainerResourcesResponse) 328 | err := c.cc.Invoke(ctx, RuntimeService_UpdateContainerResources_FullMethodName, in, out, cOpts...) 329 | if err != nil { 330 | return nil, err 331 | } 332 | return out, nil 333 | } 334 | 335 | func (c *runtimeServiceClient) ReopenContainerLog(ctx context.Context, in *ReopenContainerLogRequest, opts ...grpc.CallOption) (*ReopenContainerLogResponse, error) { 336 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 337 | out := new(ReopenContainerLogResponse) 338 | err := c.cc.Invoke(ctx, RuntimeService_ReopenContainerLog_FullMethodName, in, out, cOpts...) 339 | if err != nil { 340 | return nil, err 341 | } 342 | return out, nil 343 | } 344 | 345 | func (c *runtimeServiceClient) ExecSync(ctx context.Context, in *ExecSyncRequest, opts ...grpc.CallOption) (*ExecSyncResponse, error) { 346 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 347 | out := new(ExecSyncResponse) 348 | err := c.cc.Invoke(ctx, RuntimeService_ExecSync_FullMethodName, in, out, cOpts...) 349 | if err != nil { 350 | return nil, err 351 | } 352 | return out, nil 353 | } 354 | 355 | func (c *runtimeServiceClient) Exec(ctx context.Context, in *ExecRequest, opts ...grpc.CallOption) (*ExecResponse, error) { 356 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 357 | out := new(ExecResponse) 358 | err := c.cc.Invoke(ctx, RuntimeService_Exec_FullMethodName, in, out, cOpts...) 359 | if err != nil { 360 | return nil, err 361 | } 362 | return out, nil 363 | } 364 | 365 | func (c *runtimeServiceClient) Attach(ctx context.Context, in *AttachRequest, opts ...grpc.CallOption) (*AttachResponse, error) { 366 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 367 | out := new(AttachResponse) 368 | err := c.cc.Invoke(ctx, RuntimeService_Attach_FullMethodName, in, out, cOpts...) 369 | if err != nil { 370 | return nil, err 371 | } 372 | return out, nil 373 | } 374 | 375 | func (c *runtimeServiceClient) PortForward(ctx context.Context, in *PortForwardRequest, opts ...grpc.CallOption) (*PortForwardResponse, error) { 376 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 377 | out := new(PortForwardResponse) 378 | err := c.cc.Invoke(ctx, RuntimeService_PortForward_FullMethodName, in, out, cOpts...) 379 | if err != nil { 380 | return nil, err 381 | } 382 | return out, nil 383 | } 384 | 385 | func (c *runtimeServiceClient) ContainerStats(ctx context.Context, in *ContainerStatsRequest, opts ...grpc.CallOption) (*ContainerStatsResponse, error) { 386 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 387 | out := new(ContainerStatsResponse) 388 | err := c.cc.Invoke(ctx, RuntimeService_ContainerStats_FullMethodName, in, out, cOpts...) 389 | if err != nil { 390 | return nil, err 391 | } 392 | return out, nil 393 | } 394 | 395 | func (c *runtimeServiceClient) ListContainerStats(ctx context.Context, in *ListContainerStatsRequest, opts ...grpc.CallOption) (*ListContainerStatsResponse, error) { 396 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 397 | out := new(ListContainerStatsResponse) 398 | err := c.cc.Invoke(ctx, RuntimeService_ListContainerStats_FullMethodName, in, out, cOpts...) 399 | if err != nil { 400 | return nil, err 401 | } 402 | return out, nil 403 | } 404 | 405 | func (c *runtimeServiceClient) PodSandboxStats(ctx context.Context, in *PodSandboxStatsRequest, opts ...grpc.CallOption) (*PodSandboxStatsResponse, error) { 406 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 407 | out := new(PodSandboxStatsResponse) 408 | err := c.cc.Invoke(ctx, RuntimeService_PodSandboxStats_FullMethodName, in, out, cOpts...) 409 | if err != nil { 410 | return nil, err 411 | } 412 | return out, nil 413 | } 414 | 415 | func (c *runtimeServiceClient) ListPodSandboxStats(ctx context.Context, in *ListPodSandboxStatsRequest, opts ...grpc.CallOption) (*ListPodSandboxStatsResponse, error) { 416 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 417 | out := new(ListPodSandboxStatsResponse) 418 | err := c.cc.Invoke(ctx, RuntimeService_ListPodSandboxStats_FullMethodName, in, out, cOpts...) 419 | if err != nil { 420 | return nil, err 421 | } 422 | return out, nil 423 | } 424 | 425 | func (c *runtimeServiceClient) UpdateRuntimeConfig(ctx context.Context, in *UpdateRuntimeConfigRequest, opts ...grpc.CallOption) (*UpdateRuntimeConfigResponse, error) { 426 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 427 | out := new(UpdateRuntimeConfigResponse) 428 | err := c.cc.Invoke(ctx, RuntimeService_UpdateRuntimeConfig_FullMethodName, in, out, cOpts...) 429 | if err != nil { 430 | return nil, err 431 | } 432 | return out, nil 433 | } 434 | 435 | func (c *runtimeServiceClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) { 436 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 437 | out := new(StatusResponse) 438 | err := c.cc.Invoke(ctx, RuntimeService_Status_FullMethodName, in, out, cOpts...) 439 | if err != nil { 440 | return nil, err 441 | } 442 | return out, nil 443 | } 444 | 445 | func (c *runtimeServiceClient) CheckpointContainer(ctx context.Context, in *CheckpointContainerRequest, opts ...grpc.CallOption) (*CheckpointContainerResponse, error) { 446 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 447 | out := new(CheckpointContainerResponse) 448 | err := c.cc.Invoke(ctx, RuntimeService_CheckpointContainer_FullMethodName, in, out, cOpts...) 449 | if err != nil { 450 | return nil, err 451 | } 452 | return out, nil 453 | } 454 | 455 | func (c *runtimeServiceClient) GetContainerEvents(ctx context.Context, in *GetEventsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ContainerEventResponse], error) { 456 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 457 | stream, err := c.cc.NewStream(ctx, &RuntimeService_ServiceDesc.Streams[0], RuntimeService_GetContainerEvents_FullMethodName, cOpts...) 458 | if err != nil { 459 | return nil, err 460 | } 461 | x := &grpc.GenericClientStream[GetEventsRequest, ContainerEventResponse]{ClientStream: stream} 462 | if err := x.ClientStream.SendMsg(in); err != nil { 463 | return nil, err 464 | } 465 | if err := x.ClientStream.CloseSend(); err != nil { 466 | return nil, err 467 | } 468 | return x, nil 469 | } 470 | 471 | // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. 472 | type RuntimeService_GetContainerEventsClient = grpc.ServerStreamingClient[ContainerEventResponse] 473 | 474 | func (c *runtimeServiceClient) ListMetricDescriptors(ctx context.Context, in *ListMetricDescriptorsRequest, opts ...grpc.CallOption) (*ListMetricDescriptorsResponse, error) { 475 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 476 | out := new(ListMetricDescriptorsResponse) 477 | err := c.cc.Invoke(ctx, RuntimeService_ListMetricDescriptors_FullMethodName, in, out, cOpts...) 478 | if err != nil { 479 | return nil, err 480 | } 481 | return out, nil 482 | } 483 | 484 | func (c *runtimeServiceClient) ListPodSandboxMetrics(ctx context.Context, in *ListPodSandboxMetricsRequest, opts ...grpc.CallOption) (*ListPodSandboxMetricsResponse, error) { 485 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 486 | out := new(ListPodSandboxMetricsResponse) 487 | err := c.cc.Invoke(ctx, RuntimeService_ListPodSandboxMetrics_FullMethodName, in, out, cOpts...) 488 | if err != nil { 489 | return nil, err 490 | } 491 | return out, nil 492 | } 493 | 494 | func (c *runtimeServiceClient) RuntimeConfig(ctx context.Context, in *RuntimeConfigRequest, opts ...grpc.CallOption) (*RuntimeConfigResponse, error) { 495 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 496 | out := new(RuntimeConfigResponse) 497 | err := c.cc.Invoke(ctx, RuntimeService_RuntimeConfig_FullMethodName, in, out, cOpts...) 498 | if err != nil { 499 | return nil, err 500 | } 501 | return out, nil 502 | } 503 | 504 | func (c *runtimeServiceClient) UpdatePodSandboxResources(ctx context.Context, in *UpdatePodSandboxResourcesRequest, opts ...grpc.CallOption) (*UpdatePodSandboxResourcesResponse, error) { 505 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 506 | out := new(UpdatePodSandboxResourcesResponse) 507 | err := c.cc.Invoke(ctx, RuntimeService_UpdatePodSandboxResources_FullMethodName, in, out, cOpts...) 508 | if err != nil { 509 | return nil, err 510 | } 511 | return out, nil 512 | } 513 | 514 | // RuntimeServiceServer is the server API for RuntimeService service. 515 | // All implementations must embed UnimplementedRuntimeServiceServer 516 | // for forward compatibility. 517 | // 518 | // Runtime service defines the public APIs for remote container runtimes 519 | type RuntimeServiceServer interface { 520 | // Version returns the runtime name, runtime version, and runtime API version. 521 | Version(context.Context, *VersionRequest) (*VersionResponse, error) 522 | // RunPodSandbox creates and starts a pod-level sandbox. Runtimes must ensure 523 | // the sandbox is in the ready state on success. 524 | RunPodSandbox(context.Context, *RunPodSandboxRequest) (*RunPodSandboxResponse, error) 525 | // StopPodSandbox stops any running process that is part of the sandbox and 526 | // reclaims network resources (e.g., IP addresses) allocated to the sandbox. 527 | // If there are any running containers in the sandbox, they must be forcibly 528 | // terminated. 529 | // This call is idempotent, and must not return an error if all relevant 530 | // resources have already been reclaimed. kubelet will call StopPodSandbox 531 | // at least once before calling RemovePodSandbox. It will also attempt to 532 | // reclaim resources eagerly, as soon as a sandbox is not needed. Hence, 533 | // multiple StopPodSandbox calls are expected. 534 | StopPodSandbox(context.Context, *StopPodSandboxRequest) (*StopPodSandboxResponse, error) 535 | // RemovePodSandbox removes the sandbox. If there are any running containers 536 | // in the sandbox, they must be forcibly terminated and removed. 537 | // This call is idempotent, and must not return an error if the sandbox has 538 | // already been removed. 539 | RemovePodSandbox(context.Context, *RemovePodSandboxRequest) (*RemovePodSandboxResponse, error) 540 | // PodSandboxStatus returns the status of the PodSandbox. If the PodSandbox is not 541 | // present, returns an error. 542 | PodSandboxStatus(context.Context, *PodSandboxStatusRequest) (*PodSandboxStatusResponse, error) 543 | // ListPodSandbox returns a list of PodSandboxes. 544 | ListPodSandbox(context.Context, *ListPodSandboxRequest) (*ListPodSandboxResponse, error) 545 | // CreateContainer creates a new container in specified PodSandbox 546 | CreateContainer(context.Context, *CreateContainerRequest) (*CreateContainerResponse, error) 547 | // StartContainer starts the container. 548 | StartContainer(context.Context, *StartContainerRequest) (*StartContainerResponse, error) 549 | // StopContainer stops a running container with a grace period (i.e., timeout). 550 | // This call is idempotent, and must not return an error if the container has 551 | // already been stopped. 552 | // The runtime must forcibly kill the container after the grace period is 553 | // reached. 554 | StopContainer(context.Context, *StopContainerRequest) (*StopContainerResponse, error) 555 | // RemoveContainer removes the container. If the container is running, the 556 | // container must be forcibly removed. 557 | // This call is idempotent, and must not return an error if the container has 558 | // already been removed. 559 | RemoveContainer(context.Context, *RemoveContainerRequest) (*RemoveContainerResponse, error) 560 | // ListContainers lists all containers by filters. 561 | ListContainers(context.Context, *ListContainersRequest) (*ListContainersResponse, error) 562 | // ContainerStatus returns status of the container. If the container is not 563 | // present, returns an error. 564 | ContainerStatus(context.Context, *ContainerStatusRequest) (*ContainerStatusResponse, error) 565 | // UpdateContainerResources updates ContainerConfig of the container synchronously. 566 | // If runtime fails to transactionally update the requested resources, an error is returned. 567 | UpdateContainerResources(context.Context, *UpdateContainerResourcesRequest) (*UpdateContainerResourcesResponse, error) 568 | // ReopenContainerLog asks runtime to reopen the stdout/stderr log file 569 | // for the container. This is often called after the log file has been 570 | // rotated. If the container is not running, container runtime can choose 571 | // to either create a new log file and return nil, or return an error. 572 | // Once it returns error, new container log file MUST NOT be created. 573 | ReopenContainerLog(context.Context, *ReopenContainerLogRequest) (*ReopenContainerLogResponse, error) 574 | // ExecSync runs a command in a container synchronously. 575 | ExecSync(context.Context, *ExecSyncRequest) (*ExecSyncResponse, error) 576 | // Exec prepares a streaming endpoint to execute a command in the container. 577 | Exec(context.Context, *ExecRequest) (*ExecResponse, error) 578 | // Attach prepares a streaming endpoint to attach to a running container. 579 | Attach(context.Context, *AttachRequest) (*AttachResponse, error) 580 | // PortForward prepares a streaming endpoint to forward ports from a PodSandbox. 581 | PortForward(context.Context, *PortForwardRequest) (*PortForwardResponse, error) 582 | // ContainerStats returns stats of the container. If the container does not 583 | // exist, the call returns an error. 584 | ContainerStats(context.Context, *ContainerStatsRequest) (*ContainerStatsResponse, error) 585 | // ListContainerStats returns stats of all running containers. 586 | ListContainerStats(context.Context, *ListContainerStatsRequest) (*ListContainerStatsResponse, error) 587 | // PodSandboxStats returns stats of the pod sandbox. If the pod sandbox does not 588 | // exist, the call returns an error. 589 | PodSandboxStats(context.Context, *PodSandboxStatsRequest) (*PodSandboxStatsResponse, error) 590 | // ListPodSandboxStats returns stats of the pod sandboxes matching a filter. 591 | ListPodSandboxStats(context.Context, *ListPodSandboxStatsRequest) (*ListPodSandboxStatsResponse, error) 592 | // UpdateRuntimeConfig updates the runtime configuration based on the given request. 593 | UpdateRuntimeConfig(context.Context, *UpdateRuntimeConfigRequest) (*UpdateRuntimeConfigResponse, error) 594 | // Status returns the status of the runtime. 595 | Status(context.Context, *StatusRequest) (*StatusResponse, error) 596 | // CheckpointContainer checkpoints a container 597 | CheckpointContainer(context.Context, *CheckpointContainerRequest) (*CheckpointContainerResponse, error) 598 | // GetContainerEvents gets container events from the CRI runtime 599 | GetContainerEvents(*GetEventsRequest, grpc.ServerStreamingServer[ContainerEventResponse]) error 600 | // ListMetricDescriptors gets the descriptors for the metrics that will be returned in ListPodSandboxMetrics. 601 | // This list should be static at startup: either the client and server restart together when 602 | // adding or removing metrics descriptors, or they should not change. 603 | // Put differently, if ListPodSandboxMetrics references a name that is not described in the initial 604 | // ListMetricDescriptors call, then the metric will not be broadcasted. 605 | ListMetricDescriptors(context.Context, *ListMetricDescriptorsRequest) (*ListMetricDescriptorsResponse, error) 606 | // ListPodSandboxMetrics gets pod sandbox metrics from CRI Runtime 607 | ListPodSandboxMetrics(context.Context, *ListPodSandboxMetricsRequest) (*ListPodSandboxMetricsResponse, error) 608 | // RuntimeConfig returns configuration information of the runtime. 609 | // A couple of notes: 610 | // - The RuntimeConfigRequest object is not to be confused with the contents of UpdateRuntimeConfigRequest. 611 | // The former is for having runtime tell Kubelet what to do, the latter vice versa. 612 | // - It is the expectation of the Kubelet that these fields are static for the lifecycle of the Kubelet. 613 | // The Kubelet will not re-request the RuntimeConfiguration after startup, and CRI implementations should 614 | // avoid updating them without a full node reboot. 615 | RuntimeConfig(context.Context, *RuntimeConfigRequest) (*RuntimeConfigResponse, error) 616 | // UpdatePodSandboxResources synchronously updates the PodSandboxConfig with 617 | // the pod-level resource configuration. This method is called _after_ the 618 | // Kubelet reconfigures the pod-level cgroups. 619 | // This request is treated as best effort, and failure will not block the 620 | // Kubelet with proceeding with a resize. 621 | UpdatePodSandboxResources(context.Context, *UpdatePodSandboxResourcesRequest) (*UpdatePodSandboxResourcesResponse, error) 622 | mustEmbedUnimplementedRuntimeServiceServer() 623 | } 624 | 625 | // UnimplementedRuntimeServiceServer must be embedded to have 626 | // forward compatible implementations. 627 | // 628 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 629 | // pointer dereference when methods are called. 630 | type UnimplementedRuntimeServiceServer struct{} 631 | 632 | func (UnimplementedRuntimeServiceServer) Version(context.Context, *VersionRequest) (*VersionResponse, error) { 633 | return nil, status.Errorf(codes.Unimplemented, "method Version not implemented") 634 | } 635 | func (UnimplementedRuntimeServiceServer) RunPodSandbox(context.Context, *RunPodSandboxRequest) (*RunPodSandboxResponse, error) { 636 | return nil, status.Errorf(codes.Unimplemented, "method RunPodSandbox not implemented") 637 | } 638 | func (UnimplementedRuntimeServiceServer) StopPodSandbox(context.Context, *StopPodSandboxRequest) (*StopPodSandboxResponse, error) { 639 | return nil, status.Errorf(codes.Unimplemented, "method StopPodSandbox not implemented") 640 | } 641 | func (UnimplementedRuntimeServiceServer) RemovePodSandbox(context.Context, *RemovePodSandboxRequest) (*RemovePodSandboxResponse, error) { 642 | return nil, status.Errorf(codes.Unimplemented, "method RemovePodSandbox not implemented") 643 | } 644 | func (UnimplementedRuntimeServiceServer) PodSandboxStatus(context.Context, *PodSandboxStatusRequest) (*PodSandboxStatusResponse, error) { 645 | return nil, status.Errorf(codes.Unimplemented, "method PodSandboxStatus not implemented") 646 | } 647 | func (UnimplementedRuntimeServiceServer) ListPodSandbox(context.Context, *ListPodSandboxRequest) (*ListPodSandboxResponse, error) { 648 | return nil, status.Errorf(codes.Unimplemented, "method ListPodSandbox not implemented") 649 | } 650 | func (UnimplementedRuntimeServiceServer) CreateContainer(context.Context, *CreateContainerRequest) (*CreateContainerResponse, error) { 651 | return nil, status.Errorf(codes.Unimplemented, "method CreateContainer not implemented") 652 | } 653 | func (UnimplementedRuntimeServiceServer) StartContainer(context.Context, *StartContainerRequest) (*StartContainerResponse, error) { 654 | return nil, status.Errorf(codes.Unimplemented, "method StartContainer not implemented") 655 | } 656 | func (UnimplementedRuntimeServiceServer) StopContainer(context.Context, *StopContainerRequest) (*StopContainerResponse, error) { 657 | return nil, status.Errorf(codes.Unimplemented, "method StopContainer not implemented") 658 | } 659 | func (UnimplementedRuntimeServiceServer) RemoveContainer(context.Context, *RemoveContainerRequest) (*RemoveContainerResponse, error) { 660 | return nil, status.Errorf(codes.Unimplemented, "method RemoveContainer not implemented") 661 | } 662 | func (UnimplementedRuntimeServiceServer) ListContainers(context.Context, *ListContainersRequest) (*ListContainersResponse, error) { 663 | return nil, status.Errorf(codes.Unimplemented, "method ListContainers not implemented") 664 | } 665 | func (UnimplementedRuntimeServiceServer) ContainerStatus(context.Context, *ContainerStatusRequest) (*ContainerStatusResponse, error) { 666 | return nil, status.Errorf(codes.Unimplemented, "method ContainerStatus not implemented") 667 | } 668 | func (UnimplementedRuntimeServiceServer) UpdateContainerResources(context.Context, *UpdateContainerResourcesRequest) (*UpdateContainerResourcesResponse, error) { 669 | return nil, status.Errorf(codes.Unimplemented, "method UpdateContainerResources not implemented") 670 | } 671 | func (UnimplementedRuntimeServiceServer) ReopenContainerLog(context.Context, *ReopenContainerLogRequest) (*ReopenContainerLogResponse, error) { 672 | return nil, status.Errorf(codes.Unimplemented, "method ReopenContainerLog not implemented") 673 | } 674 | func (UnimplementedRuntimeServiceServer) ExecSync(context.Context, *ExecSyncRequest) (*ExecSyncResponse, error) { 675 | return nil, status.Errorf(codes.Unimplemented, "method ExecSync not implemented") 676 | } 677 | func (UnimplementedRuntimeServiceServer) Exec(context.Context, *ExecRequest) (*ExecResponse, error) { 678 | return nil, status.Errorf(codes.Unimplemented, "method Exec not implemented") 679 | } 680 | func (UnimplementedRuntimeServiceServer) Attach(context.Context, *AttachRequest) (*AttachResponse, error) { 681 | return nil, status.Errorf(codes.Unimplemented, "method Attach not implemented") 682 | } 683 | func (UnimplementedRuntimeServiceServer) PortForward(context.Context, *PortForwardRequest) (*PortForwardResponse, error) { 684 | return nil, status.Errorf(codes.Unimplemented, "method PortForward not implemented") 685 | } 686 | func (UnimplementedRuntimeServiceServer) ContainerStats(context.Context, *ContainerStatsRequest) (*ContainerStatsResponse, error) { 687 | return nil, status.Errorf(codes.Unimplemented, "method ContainerStats not implemented") 688 | } 689 | func (UnimplementedRuntimeServiceServer) ListContainerStats(context.Context, *ListContainerStatsRequest) (*ListContainerStatsResponse, error) { 690 | return nil, status.Errorf(codes.Unimplemented, "method ListContainerStats not implemented") 691 | } 692 | func (UnimplementedRuntimeServiceServer) PodSandboxStats(context.Context, *PodSandboxStatsRequest) (*PodSandboxStatsResponse, error) { 693 | return nil, status.Errorf(codes.Unimplemented, "method PodSandboxStats not implemented") 694 | } 695 | func (UnimplementedRuntimeServiceServer) ListPodSandboxStats(context.Context, *ListPodSandboxStatsRequest) (*ListPodSandboxStatsResponse, error) { 696 | return nil, status.Errorf(codes.Unimplemented, "method ListPodSandboxStats not implemented") 697 | } 698 | func (UnimplementedRuntimeServiceServer) UpdateRuntimeConfig(context.Context, *UpdateRuntimeConfigRequest) (*UpdateRuntimeConfigResponse, error) { 699 | return nil, status.Errorf(codes.Unimplemented, "method UpdateRuntimeConfig not implemented") 700 | } 701 | func (UnimplementedRuntimeServiceServer) Status(context.Context, *StatusRequest) (*StatusResponse, error) { 702 | return nil, status.Errorf(codes.Unimplemented, "method Status not implemented") 703 | } 704 | func (UnimplementedRuntimeServiceServer) CheckpointContainer(context.Context, *CheckpointContainerRequest) (*CheckpointContainerResponse, error) { 705 | return nil, status.Errorf(codes.Unimplemented, "method CheckpointContainer not implemented") 706 | } 707 | func (UnimplementedRuntimeServiceServer) GetContainerEvents(*GetEventsRequest, grpc.ServerStreamingServer[ContainerEventResponse]) error { 708 | return status.Errorf(codes.Unimplemented, "method GetContainerEvents not implemented") 709 | } 710 | func (UnimplementedRuntimeServiceServer) ListMetricDescriptors(context.Context, *ListMetricDescriptorsRequest) (*ListMetricDescriptorsResponse, error) { 711 | return nil, status.Errorf(codes.Unimplemented, "method ListMetricDescriptors not implemented") 712 | } 713 | func (UnimplementedRuntimeServiceServer) ListPodSandboxMetrics(context.Context, *ListPodSandboxMetricsRequest) (*ListPodSandboxMetricsResponse, error) { 714 | return nil, status.Errorf(codes.Unimplemented, "method ListPodSandboxMetrics not implemented") 715 | } 716 | func (UnimplementedRuntimeServiceServer) RuntimeConfig(context.Context, *RuntimeConfigRequest) (*RuntimeConfigResponse, error) { 717 | return nil, status.Errorf(codes.Unimplemented, "method RuntimeConfig not implemented") 718 | } 719 | func (UnimplementedRuntimeServiceServer) UpdatePodSandboxResources(context.Context, *UpdatePodSandboxResourcesRequest) (*UpdatePodSandboxResourcesResponse, error) { 720 | return nil, status.Errorf(codes.Unimplemented, "method UpdatePodSandboxResources not implemented") 721 | } 722 | func (UnimplementedRuntimeServiceServer) mustEmbedUnimplementedRuntimeServiceServer() {} 723 | func (UnimplementedRuntimeServiceServer) testEmbeddedByValue() {} 724 | 725 | // UnsafeRuntimeServiceServer may be embedded to opt out of forward compatibility for this service. 726 | // Use of this interface is not recommended, as added methods to RuntimeServiceServer will 727 | // result in compilation errors. 728 | type UnsafeRuntimeServiceServer interface { 729 | mustEmbedUnimplementedRuntimeServiceServer() 730 | } 731 | 732 | func RegisterRuntimeServiceServer(s grpc.ServiceRegistrar, srv RuntimeServiceServer) { 733 | // If the following call pancis, it indicates UnimplementedRuntimeServiceServer was 734 | // embedded by pointer and is nil. This will cause panics if an 735 | // unimplemented method is ever invoked, so we test this at initialization 736 | // time to prevent it from happening at runtime later due to I/O. 737 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 738 | t.testEmbeddedByValue() 739 | } 740 | s.RegisterService(&RuntimeService_ServiceDesc, srv) 741 | } 742 | 743 | func _RuntimeService_Version_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 744 | in := new(VersionRequest) 745 | if err := dec(in); err != nil { 746 | return nil, err 747 | } 748 | if interceptor == nil { 749 | return srv.(RuntimeServiceServer).Version(ctx, in) 750 | } 751 | info := &grpc.UnaryServerInfo{ 752 | Server: srv, 753 | FullMethod: RuntimeService_Version_FullMethodName, 754 | } 755 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 756 | return srv.(RuntimeServiceServer).Version(ctx, req.(*VersionRequest)) 757 | } 758 | return interceptor(ctx, in, info, handler) 759 | } 760 | 761 | func _RuntimeService_RunPodSandbox_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 762 | in := new(RunPodSandboxRequest) 763 | if err := dec(in); err != nil { 764 | return nil, err 765 | } 766 | if interceptor == nil { 767 | return srv.(RuntimeServiceServer).RunPodSandbox(ctx, in) 768 | } 769 | info := &grpc.UnaryServerInfo{ 770 | Server: srv, 771 | FullMethod: RuntimeService_RunPodSandbox_FullMethodName, 772 | } 773 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 774 | return srv.(RuntimeServiceServer).RunPodSandbox(ctx, req.(*RunPodSandboxRequest)) 775 | } 776 | return interceptor(ctx, in, info, handler) 777 | } 778 | 779 | func _RuntimeService_StopPodSandbox_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 780 | in := new(StopPodSandboxRequest) 781 | if err := dec(in); err != nil { 782 | return nil, err 783 | } 784 | if interceptor == nil { 785 | return srv.(RuntimeServiceServer).StopPodSandbox(ctx, in) 786 | } 787 | info := &grpc.UnaryServerInfo{ 788 | Server: srv, 789 | FullMethod: RuntimeService_StopPodSandbox_FullMethodName, 790 | } 791 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 792 | return srv.(RuntimeServiceServer).StopPodSandbox(ctx, req.(*StopPodSandboxRequest)) 793 | } 794 | return interceptor(ctx, in, info, handler) 795 | } 796 | 797 | func _RuntimeService_RemovePodSandbox_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 798 | in := new(RemovePodSandboxRequest) 799 | if err := dec(in); err != nil { 800 | return nil, err 801 | } 802 | if interceptor == nil { 803 | return srv.(RuntimeServiceServer).RemovePodSandbox(ctx, in) 804 | } 805 | info := &grpc.UnaryServerInfo{ 806 | Server: srv, 807 | FullMethod: RuntimeService_RemovePodSandbox_FullMethodName, 808 | } 809 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 810 | return srv.(RuntimeServiceServer).RemovePodSandbox(ctx, req.(*RemovePodSandboxRequest)) 811 | } 812 | return interceptor(ctx, in, info, handler) 813 | } 814 | 815 | func _RuntimeService_PodSandboxStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 816 | in := new(PodSandboxStatusRequest) 817 | if err := dec(in); err != nil { 818 | return nil, err 819 | } 820 | if interceptor == nil { 821 | return srv.(RuntimeServiceServer).PodSandboxStatus(ctx, in) 822 | } 823 | info := &grpc.UnaryServerInfo{ 824 | Server: srv, 825 | FullMethod: RuntimeService_PodSandboxStatus_FullMethodName, 826 | } 827 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 828 | return srv.(RuntimeServiceServer).PodSandboxStatus(ctx, req.(*PodSandboxStatusRequest)) 829 | } 830 | return interceptor(ctx, in, info, handler) 831 | } 832 | 833 | func _RuntimeService_ListPodSandbox_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 834 | in := new(ListPodSandboxRequest) 835 | if err := dec(in); err != nil { 836 | return nil, err 837 | } 838 | if interceptor == nil { 839 | return srv.(RuntimeServiceServer).ListPodSandbox(ctx, in) 840 | } 841 | info := &grpc.UnaryServerInfo{ 842 | Server: srv, 843 | FullMethod: RuntimeService_ListPodSandbox_FullMethodName, 844 | } 845 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 846 | return srv.(RuntimeServiceServer).ListPodSandbox(ctx, req.(*ListPodSandboxRequest)) 847 | } 848 | return interceptor(ctx, in, info, handler) 849 | } 850 | 851 | func _RuntimeService_CreateContainer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 852 | in := new(CreateContainerRequest) 853 | if err := dec(in); err != nil { 854 | return nil, err 855 | } 856 | if interceptor == nil { 857 | return srv.(RuntimeServiceServer).CreateContainer(ctx, in) 858 | } 859 | info := &grpc.UnaryServerInfo{ 860 | Server: srv, 861 | FullMethod: RuntimeService_CreateContainer_FullMethodName, 862 | } 863 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 864 | return srv.(RuntimeServiceServer).CreateContainer(ctx, req.(*CreateContainerRequest)) 865 | } 866 | return interceptor(ctx, in, info, handler) 867 | } 868 | 869 | func _RuntimeService_StartContainer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 870 | in := new(StartContainerRequest) 871 | if err := dec(in); err != nil { 872 | return nil, err 873 | } 874 | if interceptor == nil { 875 | return srv.(RuntimeServiceServer).StartContainer(ctx, in) 876 | } 877 | info := &grpc.UnaryServerInfo{ 878 | Server: srv, 879 | FullMethod: RuntimeService_StartContainer_FullMethodName, 880 | } 881 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 882 | return srv.(RuntimeServiceServer).StartContainer(ctx, req.(*StartContainerRequest)) 883 | } 884 | return interceptor(ctx, in, info, handler) 885 | } 886 | 887 | func _RuntimeService_StopContainer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 888 | in := new(StopContainerRequest) 889 | if err := dec(in); err != nil { 890 | return nil, err 891 | } 892 | if interceptor == nil { 893 | return srv.(RuntimeServiceServer).StopContainer(ctx, in) 894 | } 895 | info := &grpc.UnaryServerInfo{ 896 | Server: srv, 897 | FullMethod: RuntimeService_StopContainer_FullMethodName, 898 | } 899 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 900 | return srv.(RuntimeServiceServer).StopContainer(ctx, req.(*StopContainerRequest)) 901 | } 902 | return interceptor(ctx, in, info, handler) 903 | } 904 | 905 | func _RuntimeService_RemoveContainer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 906 | in := new(RemoveContainerRequest) 907 | if err := dec(in); err != nil { 908 | return nil, err 909 | } 910 | if interceptor == nil { 911 | return srv.(RuntimeServiceServer).RemoveContainer(ctx, in) 912 | } 913 | info := &grpc.UnaryServerInfo{ 914 | Server: srv, 915 | FullMethod: RuntimeService_RemoveContainer_FullMethodName, 916 | } 917 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 918 | return srv.(RuntimeServiceServer).RemoveContainer(ctx, req.(*RemoveContainerRequest)) 919 | } 920 | return interceptor(ctx, in, info, handler) 921 | } 922 | 923 | func _RuntimeService_ListContainers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 924 | in := new(ListContainersRequest) 925 | if err := dec(in); err != nil { 926 | return nil, err 927 | } 928 | if interceptor == nil { 929 | return srv.(RuntimeServiceServer).ListContainers(ctx, in) 930 | } 931 | info := &grpc.UnaryServerInfo{ 932 | Server: srv, 933 | FullMethod: RuntimeService_ListContainers_FullMethodName, 934 | } 935 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 936 | return srv.(RuntimeServiceServer).ListContainers(ctx, req.(*ListContainersRequest)) 937 | } 938 | return interceptor(ctx, in, info, handler) 939 | } 940 | 941 | func _RuntimeService_ContainerStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 942 | in := new(ContainerStatusRequest) 943 | if err := dec(in); err != nil { 944 | return nil, err 945 | } 946 | if interceptor == nil { 947 | return srv.(RuntimeServiceServer).ContainerStatus(ctx, in) 948 | } 949 | info := &grpc.UnaryServerInfo{ 950 | Server: srv, 951 | FullMethod: RuntimeService_ContainerStatus_FullMethodName, 952 | } 953 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 954 | return srv.(RuntimeServiceServer).ContainerStatus(ctx, req.(*ContainerStatusRequest)) 955 | } 956 | return interceptor(ctx, in, info, handler) 957 | } 958 | 959 | func _RuntimeService_UpdateContainerResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 960 | in := new(UpdateContainerResourcesRequest) 961 | if err := dec(in); err != nil { 962 | return nil, err 963 | } 964 | if interceptor == nil { 965 | return srv.(RuntimeServiceServer).UpdateContainerResources(ctx, in) 966 | } 967 | info := &grpc.UnaryServerInfo{ 968 | Server: srv, 969 | FullMethod: RuntimeService_UpdateContainerResources_FullMethodName, 970 | } 971 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 972 | return srv.(RuntimeServiceServer).UpdateContainerResources(ctx, req.(*UpdateContainerResourcesRequest)) 973 | } 974 | return interceptor(ctx, in, info, handler) 975 | } 976 | 977 | func _RuntimeService_ReopenContainerLog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 978 | in := new(ReopenContainerLogRequest) 979 | if err := dec(in); err != nil { 980 | return nil, err 981 | } 982 | if interceptor == nil { 983 | return srv.(RuntimeServiceServer).ReopenContainerLog(ctx, in) 984 | } 985 | info := &grpc.UnaryServerInfo{ 986 | Server: srv, 987 | FullMethod: RuntimeService_ReopenContainerLog_FullMethodName, 988 | } 989 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 990 | return srv.(RuntimeServiceServer).ReopenContainerLog(ctx, req.(*ReopenContainerLogRequest)) 991 | } 992 | return interceptor(ctx, in, info, handler) 993 | } 994 | 995 | func _RuntimeService_ExecSync_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 996 | in := new(ExecSyncRequest) 997 | if err := dec(in); err != nil { 998 | return nil, err 999 | } 1000 | if interceptor == nil { 1001 | return srv.(RuntimeServiceServer).ExecSync(ctx, in) 1002 | } 1003 | info := &grpc.UnaryServerInfo{ 1004 | Server: srv, 1005 | FullMethod: RuntimeService_ExecSync_FullMethodName, 1006 | } 1007 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1008 | return srv.(RuntimeServiceServer).ExecSync(ctx, req.(*ExecSyncRequest)) 1009 | } 1010 | return interceptor(ctx, in, info, handler) 1011 | } 1012 | 1013 | func _RuntimeService_Exec_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1014 | in := new(ExecRequest) 1015 | if err := dec(in); err != nil { 1016 | return nil, err 1017 | } 1018 | if interceptor == nil { 1019 | return srv.(RuntimeServiceServer).Exec(ctx, in) 1020 | } 1021 | info := &grpc.UnaryServerInfo{ 1022 | Server: srv, 1023 | FullMethod: RuntimeService_Exec_FullMethodName, 1024 | } 1025 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1026 | return srv.(RuntimeServiceServer).Exec(ctx, req.(*ExecRequest)) 1027 | } 1028 | return interceptor(ctx, in, info, handler) 1029 | } 1030 | 1031 | func _RuntimeService_Attach_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1032 | in := new(AttachRequest) 1033 | if err := dec(in); err != nil { 1034 | return nil, err 1035 | } 1036 | if interceptor == nil { 1037 | return srv.(RuntimeServiceServer).Attach(ctx, in) 1038 | } 1039 | info := &grpc.UnaryServerInfo{ 1040 | Server: srv, 1041 | FullMethod: RuntimeService_Attach_FullMethodName, 1042 | } 1043 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1044 | return srv.(RuntimeServiceServer).Attach(ctx, req.(*AttachRequest)) 1045 | } 1046 | return interceptor(ctx, in, info, handler) 1047 | } 1048 | 1049 | func _RuntimeService_PortForward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1050 | in := new(PortForwardRequest) 1051 | if err := dec(in); err != nil { 1052 | return nil, err 1053 | } 1054 | if interceptor == nil { 1055 | return srv.(RuntimeServiceServer).PortForward(ctx, in) 1056 | } 1057 | info := &grpc.UnaryServerInfo{ 1058 | Server: srv, 1059 | FullMethod: RuntimeService_PortForward_FullMethodName, 1060 | } 1061 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1062 | return srv.(RuntimeServiceServer).PortForward(ctx, req.(*PortForwardRequest)) 1063 | } 1064 | return interceptor(ctx, in, info, handler) 1065 | } 1066 | 1067 | func _RuntimeService_ContainerStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1068 | in := new(ContainerStatsRequest) 1069 | if err := dec(in); err != nil { 1070 | return nil, err 1071 | } 1072 | if interceptor == nil { 1073 | return srv.(RuntimeServiceServer).ContainerStats(ctx, in) 1074 | } 1075 | info := &grpc.UnaryServerInfo{ 1076 | Server: srv, 1077 | FullMethod: RuntimeService_ContainerStats_FullMethodName, 1078 | } 1079 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1080 | return srv.(RuntimeServiceServer).ContainerStats(ctx, req.(*ContainerStatsRequest)) 1081 | } 1082 | return interceptor(ctx, in, info, handler) 1083 | } 1084 | 1085 | func _RuntimeService_ListContainerStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1086 | in := new(ListContainerStatsRequest) 1087 | if err := dec(in); err != nil { 1088 | return nil, err 1089 | } 1090 | if interceptor == nil { 1091 | return srv.(RuntimeServiceServer).ListContainerStats(ctx, in) 1092 | } 1093 | info := &grpc.UnaryServerInfo{ 1094 | Server: srv, 1095 | FullMethod: RuntimeService_ListContainerStats_FullMethodName, 1096 | } 1097 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1098 | return srv.(RuntimeServiceServer).ListContainerStats(ctx, req.(*ListContainerStatsRequest)) 1099 | } 1100 | return interceptor(ctx, in, info, handler) 1101 | } 1102 | 1103 | func _RuntimeService_PodSandboxStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1104 | in := new(PodSandboxStatsRequest) 1105 | if err := dec(in); err != nil { 1106 | return nil, err 1107 | } 1108 | if interceptor == nil { 1109 | return srv.(RuntimeServiceServer).PodSandboxStats(ctx, in) 1110 | } 1111 | info := &grpc.UnaryServerInfo{ 1112 | Server: srv, 1113 | FullMethod: RuntimeService_PodSandboxStats_FullMethodName, 1114 | } 1115 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1116 | return srv.(RuntimeServiceServer).PodSandboxStats(ctx, req.(*PodSandboxStatsRequest)) 1117 | } 1118 | return interceptor(ctx, in, info, handler) 1119 | } 1120 | 1121 | func _RuntimeService_ListPodSandboxStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1122 | in := new(ListPodSandboxStatsRequest) 1123 | if err := dec(in); err != nil { 1124 | return nil, err 1125 | } 1126 | if interceptor == nil { 1127 | return srv.(RuntimeServiceServer).ListPodSandboxStats(ctx, in) 1128 | } 1129 | info := &grpc.UnaryServerInfo{ 1130 | Server: srv, 1131 | FullMethod: RuntimeService_ListPodSandboxStats_FullMethodName, 1132 | } 1133 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1134 | return srv.(RuntimeServiceServer).ListPodSandboxStats(ctx, req.(*ListPodSandboxStatsRequest)) 1135 | } 1136 | return interceptor(ctx, in, info, handler) 1137 | } 1138 | 1139 | func _RuntimeService_UpdateRuntimeConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1140 | in := new(UpdateRuntimeConfigRequest) 1141 | if err := dec(in); err != nil { 1142 | return nil, err 1143 | } 1144 | if interceptor == nil { 1145 | return srv.(RuntimeServiceServer).UpdateRuntimeConfig(ctx, in) 1146 | } 1147 | info := &grpc.UnaryServerInfo{ 1148 | Server: srv, 1149 | FullMethod: RuntimeService_UpdateRuntimeConfig_FullMethodName, 1150 | } 1151 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1152 | return srv.(RuntimeServiceServer).UpdateRuntimeConfig(ctx, req.(*UpdateRuntimeConfigRequest)) 1153 | } 1154 | return interceptor(ctx, in, info, handler) 1155 | } 1156 | 1157 | func _RuntimeService_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1158 | in := new(StatusRequest) 1159 | if err := dec(in); err != nil { 1160 | return nil, err 1161 | } 1162 | if interceptor == nil { 1163 | return srv.(RuntimeServiceServer).Status(ctx, in) 1164 | } 1165 | info := &grpc.UnaryServerInfo{ 1166 | Server: srv, 1167 | FullMethod: RuntimeService_Status_FullMethodName, 1168 | } 1169 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1170 | return srv.(RuntimeServiceServer).Status(ctx, req.(*StatusRequest)) 1171 | } 1172 | return interceptor(ctx, in, info, handler) 1173 | } 1174 | 1175 | func _RuntimeService_CheckpointContainer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1176 | in := new(CheckpointContainerRequest) 1177 | if err := dec(in); err != nil { 1178 | return nil, err 1179 | } 1180 | if interceptor == nil { 1181 | return srv.(RuntimeServiceServer).CheckpointContainer(ctx, in) 1182 | } 1183 | info := &grpc.UnaryServerInfo{ 1184 | Server: srv, 1185 | FullMethod: RuntimeService_CheckpointContainer_FullMethodName, 1186 | } 1187 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1188 | return srv.(RuntimeServiceServer).CheckpointContainer(ctx, req.(*CheckpointContainerRequest)) 1189 | } 1190 | return interceptor(ctx, in, info, handler) 1191 | } 1192 | 1193 | func _RuntimeService_GetContainerEvents_Handler(srv interface{}, stream grpc.ServerStream) error { 1194 | m := new(GetEventsRequest) 1195 | if err := stream.RecvMsg(m); err != nil { 1196 | return err 1197 | } 1198 | return srv.(RuntimeServiceServer).GetContainerEvents(m, &grpc.GenericServerStream[GetEventsRequest, ContainerEventResponse]{ServerStream: stream}) 1199 | } 1200 | 1201 | // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. 1202 | type RuntimeService_GetContainerEventsServer = grpc.ServerStreamingServer[ContainerEventResponse] 1203 | 1204 | func _RuntimeService_ListMetricDescriptors_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1205 | in := new(ListMetricDescriptorsRequest) 1206 | if err := dec(in); err != nil { 1207 | return nil, err 1208 | } 1209 | if interceptor == nil { 1210 | return srv.(RuntimeServiceServer).ListMetricDescriptors(ctx, in) 1211 | } 1212 | info := &grpc.UnaryServerInfo{ 1213 | Server: srv, 1214 | FullMethod: RuntimeService_ListMetricDescriptors_FullMethodName, 1215 | } 1216 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1217 | return srv.(RuntimeServiceServer).ListMetricDescriptors(ctx, req.(*ListMetricDescriptorsRequest)) 1218 | } 1219 | return interceptor(ctx, in, info, handler) 1220 | } 1221 | 1222 | func _RuntimeService_ListPodSandboxMetrics_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1223 | in := new(ListPodSandboxMetricsRequest) 1224 | if err := dec(in); err != nil { 1225 | return nil, err 1226 | } 1227 | if interceptor == nil { 1228 | return srv.(RuntimeServiceServer).ListPodSandboxMetrics(ctx, in) 1229 | } 1230 | info := &grpc.UnaryServerInfo{ 1231 | Server: srv, 1232 | FullMethod: RuntimeService_ListPodSandboxMetrics_FullMethodName, 1233 | } 1234 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1235 | return srv.(RuntimeServiceServer).ListPodSandboxMetrics(ctx, req.(*ListPodSandboxMetricsRequest)) 1236 | } 1237 | return interceptor(ctx, in, info, handler) 1238 | } 1239 | 1240 | func _RuntimeService_RuntimeConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1241 | in := new(RuntimeConfigRequest) 1242 | if err := dec(in); err != nil { 1243 | return nil, err 1244 | } 1245 | if interceptor == nil { 1246 | return srv.(RuntimeServiceServer).RuntimeConfig(ctx, in) 1247 | } 1248 | info := &grpc.UnaryServerInfo{ 1249 | Server: srv, 1250 | FullMethod: RuntimeService_RuntimeConfig_FullMethodName, 1251 | } 1252 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1253 | return srv.(RuntimeServiceServer).RuntimeConfig(ctx, req.(*RuntimeConfigRequest)) 1254 | } 1255 | return interceptor(ctx, in, info, handler) 1256 | } 1257 | 1258 | func _RuntimeService_UpdatePodSandboxResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1259 | in := new(UpdatePodSandboxResourcesRequest) 1260 | if err := dec(in); err != nil { 1261 | return nil, err 1262 | } 1263 | if interceptor == nil { 1264 | return srv.(RuntimeServiceServer).UpdatePodSandboxResources(ctx, in) 1265 | } 1266 | info := &grpc.UnaryServerInfo{ 1267 | Server: srv, 1268 | FullMethod: RuntimeService_UpdatePodSandboxResources_FullMethodName, 1269 | } 1270 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1271 | return srv.(RuntimeServiceServer).UpdatePodSandboxResources(ctx, req.(*UpdatePodSandboxResourcesRequest)) 1272 | } 1273 | return interceptor(ctx, in, info, handler) 1274 | } 1275 | 1276 | // RuntimeService_ServiceDesc is the grpc.ServiceDesc for RuntimeService service. 1277 | // It's only intended for direct use with grpc.RegisterService, 1278 | // and not to be introspected or modified (even as a copy) 1279 | var RuntimeService_ServiceDesc = grpc.ServiceDesc{ 1280 | ServiceName: "runtime.v1.RuntimeService", 1281 | HandlerType: (*RuntimeServiceServer)(nil), 1282 | Methods: []grpc.MethodDesc{ 1283 | { 1284 | MethodName: "Version", 1285 | Handler: _RuntimeService_Version_Handler, 1286 | }, 1287 | { 1288 | MethodName: "RunPodSandbox", 1289 | Handler: _RuntimeService_RunPodSandbox_Handler, 1290 | }, 1291 | { 1292 | MethodName: "StopPodSandbox", 1293 | Handler: _RuntimeService_StopPodSandbox_Handler, 1294 | }, 1295 | { 1296 | MethodName: "RemovePodSandbox", 1297 | Handler: _RuntimeService_RemovePodSandbox_Handler, 1298 | }, 1299 | { 1300 | MethodName: "PodSandboxStatus", 1301 | Handler: _RuntimeService_PodSandboxStatus_Handler, 1302 | }, 1303 | { 1304 | MethodName: "ListPodSandbox", 1305 | Handler: _RuntimeService_ListPodSandbox_Handler, 1306 | }, 1307 | { 1308 | MethodName: "CreateContainer", 1309 | Handler: _RuntimeService_CreateContainer_Handler, 1310 | }, 1311 | { 1312 | MethodName: "StartContainer", 1313 | Handler: _RuntimeService_StartContainer_Handler, 1314 | }, 1315 | { 1316 | MethodName: "StopContainer", 1317 | Handler: _RuntimeService_StopContainer_Handler, 1318 | }, 1319 | { 1320 | MethodName: "RemoveContainer", 1321 | Handler: _RuntimeService_RemoveContainer_Handler, 1322 | }, 1323 | { 1324 | MethodName: "ListContainers", 1325 | Handler: _RuntimeService_ListContainers_Handler, 1326 | }, 1327 | { 1328 | MethodName: "ContainerStatus", 1329 | Handler: _RuntimeService_ContainerStatus_Handler, 1330 | }, 1331 | { 1332 | MethodName: "UpdateContainerResources", 1333 | Handler: _RuntimeService_UpdateContainerResources_Handler, 1334 | }, 1335 | { 1336 | MethodName: "ReopenContainerLog", 1337 | Handler: _RuntimeService_ReopenContainerLog_Handler, 1338 | }, 1339 | { 1340 | MethodName: "ExecSync", 1341 | Handler: _RuntimeService_ExecSync_Handler, 1342 | }, 1343 | { 1344 | MethodName: "Exec", 1345 | Handler: _RuntimeService_Exec_Handler, 1346 | }, 1347 | { 1348 | MethodName: "Attach", 1349 | Handler: _RuntimeService_Attach_Handler, 1350 | }, 1351 | { 1352 | MethodName: "PortForward", 1353 | Handler: _RuntimeService_PortForward_Handler, 1354 | }, 1355 | { 1356 | MethodName: "ContainerStats", 1357 | Handler: _RuntimeService_ContainerStats_Handler, 1358 | }, 1359 | { 1360 | MethodName: "ListContainerStats", 1361 | Handler: _RuntimeService_ListContainerStats_Handler, 1362 | }, 1363 | { 1364 | MethodName: "PodSandboxStats", 1365 | Handler: _RuntimeService_PodSandboxStats_Handler, 1366 | }, 1367 | { 1368 | MethodName: "ListPodSandboxStats", 1369 | Handler: _RuntimeService_ListPodSandboxStats_Handler, 1370 | }, 1371 | { 1372 | MethodName: "UpdateRuntimeConfig", 1373 | Handler: _RuntimeService_UpdateRuntimeConfig_Handler, 1374 | }, 1375 | { 1376 | MethodName: "Status", 1377 | Handler: _RuntimeService_Status_Handler, 1378 | }, 1379 | { 1380 | MethodName: "CheckpointContainer", 1381 | Handler: _RuntimeService_CheckpointContainer_Handler, 1382 | }, 1383 | { 1384 | MethodName: "ListMetricDescriptors", 1385 | Handler: _RuntimeService_ListMetricDescriptors_Handler, 1386 | }, 1387 | { 1388 | MethodName: "ListPodSandboxMetrics", 1389 | Handler: _RuntimeService_ListPodSandboxMetrics_Handler, 1390 | }, 1391 | { 1392 | MethodName: "RuntimeConfig", 1393 | Handler: _RuntimeService_RuntimeConfig_Handler, 1394 | }, 1395 | { 1396 | MethodName: "UpdatePodSandboxResources", 1397 | Handler: _RuntimeService_UpdatePodSandboxResources_Handler, 1398 | }, 1399 | }, 1400 | Streams: []grpc.StreamDesc{ 1401 | { 1402 | StreamName: "GetContainerEvents", 1403 | Handler: _RuntimeService_GetContainerEvents_Handler, 1404 | ServerStreams: true, 1405 | }, 1406 | }, 1407 | Metadata: "staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto", 1408 | } 1409 | 1410 | const ( 1411 | ImageService_ListImages_FullMethodName = "/runtime.v1.ImageService/ListImages" 1412 | ImageService_ImageStatus_FullMethodName = "/runtime.v1.ImageService/ImageStatus" 1413 | ImageService_PullImage_FullMethodName = "/runtime.v1.ImageService/PullImage" 1414 | ImageService_RemoveImage_FullMethodName = "/runtime.v1.ImageService/RemoveImage" 1415 | ImageService_ImageFsInfo_FullMethodName = "/runtime.v1.ImageService/ImageFsInfo" 1416 | ) 1417 | 1418 | // ImageServiceClient is the client API for ImageService service. 1419 | // 1420 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 1421 | // 1422 | // ImageService defines the public APIs for managing images. 1423 | type ImageServiceClient interface { 1424 | // ListImages lists existing images. 1425 | ListImages(ctx context.Context, in *ListImagesRequest, opts ...grpc.CallOption) (*ListImagesResponse, error) 1426 | // ImageStatus returns the status of the image. If the image is not 1427 | // present, returns a response with ImageStatusResponse.Image set to 1428 | // nil. 1429 | ImageStatus(ctx context.Context, in *ImageStatusRequest, opts ...grpc.CallOption) (*ImageStatusResponse, error) 1430 | // PullImage pulls an image with authentication config. 1431 | PullImage(ctx context.Context, in *PullImageRequest, opts ...grpc.CallOption) (*PullImageResponse, error) 1432 | // RemoveImage removes the image. 1433 | // This call is idempotent, and must not return an error if the image has 1434 | // already been removed. 1435 | // Note that if the image is referenced by multiple tags (even across different repositories 1436 | // if they resolve to the same image digest), removing the image by a single tag 1437 | // will remove all of its tags. For example, if `repo/image:v1` and `another_repo/image:latest` 1438 | // point to the same image, removing `repo/image:v1` will also remove `another_repo/image:latest`. 1439 | // The next call to ListImages, ImageStatus, ImageFsInfo will not return this image. 1440 | // The resources (e.g. disk space) may be cleaned asynchronously 1441 | // and not guaranteed to be cleaned up by the time this method returns. 1442 | RemoveImage(ctx context.Context, in *RemoveImageRequest, opts ...grpc.CallOption) (*RemoveImageResponse, error) 1443 | // ImageFSInfo returns information of the filesystem that is used to store images. 1444 | // Usage information may include images that were removed, but are still being cleaned up. 1445 | ImageFsInfo(ctx context.Context, in *ImageFsInfoRequest, opts ...grpc.CallOption) (*ImageFsInfoResponse, error) 1446 | } 1447 | 1448 | type imageServiceClient struct { 1449 | cc grpc.ClientConnInterface 1450 | } 1451 | 1452 | func NewImageServiceClient(cc grpc.ClientConnInterface) ImageServiceClient { 1453 | return &imageServiceClient{cc} 1454 | } 1455 | 1456 | func (c *imageServiceClient) ListImages(ctx context.Context, in *ListImagesRequest, opts ...grpc.CallOption) (*ListImagesResponse, error) { 1457 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 1458 | out := new(ListImagesResponse) 1459 | err := c.cc.Invoke(ctx, ImageService_ListImages_FullMethodName, in, out, cOpts...) 1460 | if err != nil { 1461 | return nil, err 1462 | } 1463 | return out, nil 1464 | } 1465 | 1466 | func (c *imageServiceClient) ImageStatus(ctx context.Context, in *ImageStatusRequest, opts ...grpc.CallOption) (*ImageStatusResponse, error) { 1467 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 1468 | out := new(ImageStatusResponse) 1469 | err := c.cc.Invoke(ctx, ImageService_ImageStatus_FullMethodName, in, out, cOpts...) 1470 | if err != nil { 1471 | return nil, err 1472 | } 1473 | return out, nil 1474 | } 1475 | 1476 | func (c *imageServiceClient) PullImage(ctx context.Context, in *PullImageRequest, opts ...grpc.CallOption) (*PullImageResponse, error) { 1477 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 1478 | out := new(PullImageResponse) 1479 | err := c.cc.Invoke(ctx, ImageService_PullImage_FullMethodName, in, out, cOpts...) 1480 | if err != nil { 1481 | return nil, err 1482 | } 1483 | return out, nil 1484 | } 1485 | 1486 | func (c *imageServiceClient) RemoveImage(ctx context.Context, in *RemoveImageRequest, opts ...grpc.CallOption) (*RemoveImageResponse, error) { 1487 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 1488 | out := new(RemoveImageResponse) 1489 | err := c.cc.Invoke(ctx, ImageService_RemoveImage_FullMethodName, in, out, cOpts...) 1490 | if err != nil { 1491 | return nil, err 1492 | } 1493 | return out, nil 1494 | } 1495 | 1496 | func (c *imageServiceClient) ImageFsInfo(ctx context.Context, in *ImageFsInfoRequest, opts ...grpc.CallOption) (*ImageFsInfoResponse, error) { 1497 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 1498 | out := new(ImageFsInfoResponse) 1499 | err := c.cc.Invoke(ctx, ImageService_ImageFsInfo_FullMethodName, in, out, cOpts...) 1500 | if err != nil { 1501 | return nil, err 1502 | } 1503 | return out, nil 1504 | } 1505 | 1506 | // ImageServiceServer is the server API for ImageService service. 1507 | // All implementations must embed UnimplementedImageServiceServer 1508 | // for forward compatibility. 1509 | // 1510 | // ImageService defines the public APIs for managing images. 1511 | type ImageServiceServer interface { 1512 | // ListImages lists existing images. 1513 | ListImages(context.Context, *ListImagesRequest) (*ListImagesResponse, error) 1514 | // ImageStatus returns the status of the image. If the image is not 1515 | // present, returns a response with ImageStatusResponse.Image set to 1516 | // nil. 1517 | ImageStatus(context.Context, *ImageStatusRequest) (*ImageStatusResponse, error) 1518 | // PullImage pulls an image with authentication config. 1519 | PullImage(context.Context, *PullImageRequest) (*PullImageResponse, error) 1520 | // RemoveImage removes the image. 1521 | // This call is idempotent, and must not return an error if the image has 1522 | // already been removed. 1523 | // Note that if the image is referenced by multiple tags (even across different repositories 1524 | // if they resolve to the same image digest), removing the image by a single tag 1525 | // will remove all of its tags. For example, if `repo/image:v1` and `another_repo/image:latest` 1526 | // point to the same image, removing `repo/image:v1` will also remove `another_repo/image:latest`. 1527 | // The next call to ListImages, ImageStatus, ImageFsInfo will not return this image. 1528 | // The resources (e.g. disk space) may be cleaned asynchronously 1529 | // and not guaranteed to be cleaned up by the time this method returns. 1530 | RemoveImage(context.Context, *RemoveImageRequest) (*RemoveImageResponse, error) 1531 | // ImageFSInfo returns information of the filesystem that is used to store images. 1532 | // Usage information may include images that were removed, but are still being cleaned up. 1533 | ImageFsInfo(context.Context, *ImageFsInfoRequest) (*ImageFsInfoResponse, error) 1534 | mustEmbedUnimplementedImageServiceServer() 1535 | } 1536 | 1537 | // UnimplementedImageServiceServer must be embedded to have 1538 | // forward compatible implementations. 1539 | // 1540 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 1541 | // pointer dereference when methods are called. 1542 | type UnimplementedImageServiceServer struct{} 1543 | 1544 | func (UnimplementedImageServiceServer) ListImages(context.Context, *ListImagesRequest) (*ListImagesResponse, error) { 1545 | return nil, status.Errorf(codes.Unimplemented, "method ListImages not implemented") 1546 | } 1547 | func (UnimplementedImageServiceServer) ImageStatus(context.Context, *ImageStatusRequest) (*ImageStatusResponse, error) { 1548 | return nil, status.Errorf(codes.Unimplemented, "method ImageStatus not implemented") 1549 | } 1550 | func (UnimplementedImageServiceServer) PullImage(context.Context, *PullImageRequest) (*PullImageResponse, error) { 1551 | return nil, status.Errorf(codes.Unimplemented, "method PullImage not implemented") 1552 | } 1553 | func (UnimplementedImageServiceServer) RemoveImage(context.Context, *RemoveImageRequest) (*RemoveImageResponse, error) { 1554 | return nil, status.Errorf(codes.Unimplemented, "method RemoveImage not implemented") 1555 | } 1556 | func (UnimplementedImageServiceServer) ImageFsInfo(context.Context, *ImageFsInfoRequest) (*ImageFsInfoResponse, error) { 1557 | return nil, status.Errorf(codes.Unimplemented, "method ImageFsInfo not implemented") 1558 | } 1559 | func (UnimplementedImageServiceServer) mustEmbedUnimplementedImageServiceServer() {} 1560 | func (UnimplementedImageServiceServer) testEmbeddedByValue() {} 1561 | 1562 | // UnsafeImageServiceServer may be embedded to opt out of forward compatibility for this service. 1563 | // Use of this interface is not recommended, as added methods to ImageServiceServer will 1564 | // result in compilation errors. 1565 | type UnsafeImageServiceServer interface { 1566 | mustEmbedUnimplementedImageServiceServer() 1567 | } 1568 | 1569 | func RegisterImageServiceServer(s grpc.ServiceRegistrar, srv ImageServiceServer) { 1570 | // If the following call pancis, it indicates UnimplementedImageServiceServer was 1571 | // embedded by pointer and is nil. This will cause panics if an 1572 | // unimplemented method is ever invoked, so we test this at initialization 1573 | // time to prevent it from happening at runtime later due to I/O. 1574 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 1575 | t.testEmbeddedByValue() 1576 | } 1577 | s.RegisterService(&ImageService_ServiceDesc, srv) 1578 | } 1579 | 1580 | func _ImageService_ListImages_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1581 | in := new(ListImagesRequest) 1582 | if err := dec(in); err != nil { 1583 | return nil, err 1584 | } 1585 | if interceptor == nil { 1586 | return srv.(ImageServiceServer).ListImages(ctx, in) 1587 | } 1588 | info := &grpc.UnaryServerInfo{ 1589 | Server: srv, 1590 | FullMethod: ImageService_ListImages_FullMethodName, 1591 | } 1592 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1593 | return srv.(ImageServiceServer).ListImages(ctx, req.(*ListImagesRequest)) 1594 | } 1595 | return interceptor(ctx, in, info, handler) 1596 | } 1597 | 1598 | func _ImageService_ImageStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1599 | in := new(ImageStatusRequest) 1600 | if err := dec(in); err != nil { 1601 | return nil, err 1602 | } 1603 | if interceptor == nil { 1604 | return srv.(ImageServiceServer).ImageStatus(ctx, in) 1605 | } 1606 | info := &grpc.UnaryServerInfo{ 1607 | Server: srv, 1608 | FullMethod: ImageService_ImageStatus_FullMethodName, 1609 | } 1610 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1611 | return srv.(ImageServiceServer).ImageStatus(ctx, req.(*ImageStatusRequest)) 1612 | } 1613 | return interceptor(ctx, in, info, handler) 1614 | } 1615 | 1616 | func _ImageService_PullImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1617 | in := new(PullImageRequest) 1618 | if err := dec(in); err != nil { 1619 | return nil, err 1620 | } 1621 | if interceptor == nil { 1622 | return srv.(ImageServiceServer).PullImage(ctx, in) 1623 | } 1624 | info := &grpc.UnaryServerInfo{ 1625 | Server: srv, 1626 | FullMethod: ImageService_PullImage_FullMethodName, 1627 | } 1628 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1629 | return srv.(ImageServiceServer).PullImage(ctx, req.(*PullImageRequest)) 1630 | } 1631 | return interceptor(ctx, in, info, handler) 1632 | } 1633 | 1634 | func _ImageService_RemoveImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1635 | in := new(RemoveImageRequest) 1636 | if err := dec(in); err != nil { 1637 | return nil, err 1638 | } 1639 | if interceptor == nil { 1640 | return srv.(ImageServiceServer).RemoveImage(ctx, in) 1641 | } 1642 | info := &grpc.UnaryServerInfo{ 1643 | Server: srv, 1644 | FullMethod: ImageService_RemoveImage_FullMethodName, 1645 | } 1646 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1647 | return srv.(ImageServiceServer).RemoveImage(ctx, req.(*RemoveImageRequest)) 1648 | } 1649 | return interceptor(ctx, in, info, handler) 1650 | } 1651 | 1652 | func _ImageService_ImageFsInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 1653 | in := new(ImageFsInfoRequest) 1654 | if err := dec(in); err != nil { 1655 | return nil, err 1656 | } 1657 | if interceptor == nil { 1658 | return srv.(ImageServiceServer).ImageFsInfo(ctx, in) 1659 | } 1660 | info := &grpc.UnaryServerInfo{ 1661 | Server: srv, 1662 | FullMethod: ImageService_ImageFsInfo_FullMethodName, 1663 | } 1664 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 1665 | return srv.(ImageServiceServer).ImageFsInfo(ctx, req.(*ImageFsInfoRequest)) 1666 | } 1667 | return interceptor(ctx, in, info, handler) 1668 | } 1669 | 1670 | // ImageService_ServiceDesc is the grpc.ServiceDesc for ImageService service. 1671 | // It's only intended for direct use with grpc.RegisterService, 1672 | // and not to be introspected or modified (even as a copy) 1673 | var ImageService_ServiceDesc = grpc.ServiceDesc{ 1674 | ServiceName: "runtime.v1.ImageService", 1675 | HandlerType: (*ImageServiceServer)(nil), 1676 | Methods: []grpc.MethodDesc{ 1677 | { 1678 | MethodName: "ListImages", 1679 | Handler: _ImageService_ListImages_Handler, 1680 | }, 1681 | { 1682 | MethodName: "ImageStatus", 1683 | Handler: _ImageService_ImageStatus_Handler, 1684 | }, 1685 | { 1686 | MethodName: "PullImage", 1687 | Handler: _ImageService_PullImage_Handler, 1688 | }, 1689 | { 1690 | MethodName: "RemoveImage", 1691 | Handler: _ImageService_RemoveImage_Handler, 1692 | }, 1693 | { 1694 | MethodName: "ImageFsInfo", 1695 | Handler: _ImageService_ImageFsInfo_Handler, 1696 | }, 1697 | }, 1698 | Streams: []grpc.StreamDesc{}, 1699 | Metadata: "staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto", 1700 | } 1701 | --------------------------------------------------------------------------------