Skip to content

Commit 363d692

Browse files
committed
api/services: define the introspection API
After several requests for information about platform support, configuration introspection and feature switches, we now have a solution that should work in all these use cases. The Introspection API hooks into the plugin subsystem registration process. During registration, plugins declare several pieces of information, allowing clients to discover the cababilities and support that a containerd instance provides, including whether or not it loaded with an error. To allow symmetrical error reporting, the `google/rpc.Status` protobuf definitions have been brought in from the googleapis project. Unfortunately, we had to generate these in place to match our protobuf system. Once we like this design, we can add an implementation to integrate it directly with the plugin system. Enjoy! Signed-off-by: Stephen J Day <stephen.day@docker.com>
1 parent 12c79cc commit 363d692

File tree

18 files changed

+5678
-5
lines changed

18 files changed

+5678
-5
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ check-protos: protos ## check if protobufs needs to be generated again
8787
@echo "$(WHALE) $@"
8888
@test -z "$$(git status --short | grep ".pb.go" | tee /dev/stderr)" || \
8989
((git diff | cat) && \
90-
(echo "$(ONI) please run 'make generate' when making changes to proto files" && false))
90+
(echo "$(ONI) please run 'make protos' when making changes to proto files" && false))
9191

9292
check-api-descriptors: protos ## check that protobuf changes aren't present.
9393
@echo "$(WHALE) $@"
@@ -105,7 +105,7 @@ fmt: ## run go fmt
105105
@echo "$(WHALE) $@"
106106
@test -z "$$(gofmt -s -l . | grep -Fv $(call FIX_PATH,'vendor/') | grep -v ".pb.go$$" | tee /dev/stderr)" || \
107107
(echo "$(ONI) please format Go code with 'gofmt -s -w'" && false)
108-
@test -z "$$(find . -path ./vendor -prune -o ! -name timestamp.proto ! -name duration.proto -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
108+
@test -z "$$(find . -path ./vendor -prune -o -path ./protobuf/google/rpc -prune -o -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
109109
(echo "$(ONI) please indent proto files with tabs only" && false)
110110
@test -z "$$(find . -path ./vendor -prune -o -name '*.proto' -type f -exec grep -Hn "Meta meta = " {} \; | grep -v '(gogoproto.nullable) = false' | tee /dev/stderr)" || \
111111
(echo "$(ONI) meta fields in proto files must have option (gogoproto.nullable) = false" && false)

Protobuild.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ plugins = ["grpc", "fieldpath"]
77
[includes]
88
# Include paths that will be added before all others. Typically, you want to
99
# treat the root of the project as an include, but this may not be necessary.
10-
# before = ["."]
10+
before = ["./protobuf"]
1111

1212
# Paths that should be treated as include roots in relation to the vendor
1313
# directory. These will be calculated with the vendor directory nearest the
1414
# target package.
15-
vendored = ["github.com/gogo/protobuf"]
15+
packages = ["github.com/gogo/protobuf"]
1616

1717
# Paths that will be added untouched to the end of the includes. We use
1818
# `/usr/local/include` to pickup the common install location of protobuf.
@@ -27,6 +27,8 @@ plugins = ["grpc", "fieldpath"]
2727
"google/protobuf/descriptor.proto" = "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
2828
"google/protobuf/field_mask.proto" = "github.com/gogo/protobuf/types"
2929
"google/protobuf/timestamp.proto" = "github.com/gogo/protobuf/types"
30+
"google/protobuf/duration.proto" = "github.com/gogo/protobuf/types"
31+
"google/rpc/status.proto" = "github.com/containerd/containerd/protobuf/google/rpc"
3032

3133
# Aggregrate the API descriptors to lock down API changes.
3234
[[descriptors]]

api/next.pb.txt

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,6 +2182,201 @@ file {
21822182
}
21832183
syntax: "proto3"
21842184
}
2185+
file {
2186+
name: "github.com/containerd/containerd/api/types/platform.proto"
2187+
package: "containerd.types"
2188+
dependency: "gogoproto/gogo.proto"
2189+
message_type {
2190+
name: "Platform"
2191+
field {
2192+
name: "os"
2193+
number: 1
2194+
label: LABEL_OPTIONAL
2195+
type: TYPE_STRING
2196+
options {
2197+
65004: "OS"
2198+
}
2199+
json_name: "os"
2200+
}
2201+
field {
2202+
name: "architecture"
2203+
number: 2
2204+
label: LABEL_OPTIONAL
2205+
type: TYPE_STRING
2206+
json_name: "architecture"
2207+
}
2208+
field {
2209+
name: "variant"
2210+
number: 3
2211+
label: LABEL_OPTIONAL
2212+
type: TYPE_STRING
2213+
json_name: "variant"
2214+
}
2215+
}
2216+
options {
2217+
go_package: "github.com/containerd/containerd/api/types;types"
2218+
}
2219+
syntax: "proto3"
2220+
}
2221+
file {
2222+
name: "google/rpc/status.proto"
2223+
package: "google.rpc"
2224+
dependency: "google/protobuf/any.proto"
2225+
message_type {
2226+
name: "Status"
2227+
field {
2228+
name: "code"
2229+
number: 1
2230+
label: LABEL_OPTIONAL
2231+
type: TYPE_INT32
2232+
json_name: "code"
2233+
}
2234+
field {
2235+
name: "message"
2236+
number: 2
2237+
label: LABEL_OPTIONAL
2238+
type: TYPE_STRING
2239+
json_name: "message"
2240+
}
2241+
field {
2242+
name: "details"
2243+
number: 3
2244+
label: LABEL_REPEATED
2245+
type: TYPE_MESSAGE
2246+
type_name: ".google.protobuf.Any"
2247+
json_name: "details"
2248+
}
2249+
}
2250+
options {
2251+
java_package: "com.google.rpc"
2252+
java_outer_classname: "StatusProto"
2253+
java_multiple_files: true
2254+
go_package: "github.com/containerd/containerd/protobuf/google/rpc;rpc"
2255+
objc_class_prefix: "RPC"
2256+
}
2257+
syntax: "proto3"
2258+
}
2259+
file {
2260+
name: "github.com/containerd/containerd/api/services/introspection/v1/introspection.proto"
2261+
package: "containerd.services.introspection.v1"
2262+
dependency: "github.com/containerd/containerd/api/types/platform.proto"
2263+
dependency: "google/rpc/status.proto"
2264+
dependency: "gogoproto/gogo.proto"
2265+
message_type {
2266+
name: "Plugin"
2267+
field {
2268+
name: "type"
2269+
number: 1
2270+
label: LABEL_OPTIONAL
2271+
type: TYPE_STRING
2272+
json_name: "type"
2273+
}
2274+
field {
2275+
name: "id"
2276+
number: 2
2277+
label: LABEL_OPTIONAL
2278+
type: TYPE_STRING
2279+
json_name: "id"
2280+
}
2281+
field {
2282+
name: "requires"
2283+
number: 3
2284+
label: LABEL_REPEATED
2285+
type: TYPE_STRING
2286+
json_name: "requires"
2287+
}
2288+
field {
2289+
name: "platforms"
2290+
number: 4
2291+
label: LABEL_REPEATED
2292+
type: TYPE_MESSAGE
2293+
type_name: ".containerd.types.Platform"
2294+
options {
2295+
65001: 0
2296+
}
2297+
json_name: "platforms"
2298+
}
2299+
field {
2300+
name: "exports"
2301+
number: 5
2302+
label: LABEL_REPEATED
2303+
type: TYPE_MESSAGE
2304+
type_name: ".containerd.services.introspection.v1.Plugin.ExportsEntry"
2305+
json_name: "exports"
2306+
}
2307+
field {
2308+
name: "capabilities"
2309+
number: 6
2310+
label: LABEL_REPEATED
2311+
type: TYPE_STRING
2312+
json_name: "capabilities"
2313+
}
2314+
field {
2315+
name: "init_err"
2316+
number: 7
2317+
label: LABEL_OPTIONAL
2318+
type: TYPE_MESSAGE
2319+
type_name: ".google.rpc.Status"
2320+
json_name: "initErr"
2321+
}
2322+
nested_type {
2323+
name: "ExportsEntry"
2324+
field {
2325+
name: "key"
2326+
number: 1
2327+
label: LABEL_OPTIONAL
2328+
type: TYPE_STRING
2329+
json_name: "key"
2330+
}
2331+
field {
2332+
name: "value"
2333+
number: 2
2334+
label: LABEL_OPTIONAL
2335+
type: TYPE_STRING
2336+
json_name: "value"
2337+
}
2338+
options {
2339+
map_entry: true
2340+
}
2341+
}
2342+
}
2343+
message_type {
2344+
name: "PluginsRequest"
2345+
field {
2346+
name: "filters"
2347+
number: 1
2348+
label: LABEL_REPEATED
2349+
type: TYPE_STRING
2350+
json_name: "filters"
2351+
}
2352+
}
2353+
message_type {
2354+
name: "PluginsResponse"
2355+
field {
2356+
name: "plugins"
2357+
number: 1
2358+
label: LABEL_REPEATED
2359+
type: TYPE_MESSAGE
2360+
type_name: ".containerd.services.introspection.v1.Plugin"
2361+
options {
2362+
65001: 0
2363+
}
2364+
json_name: "plugins"
2365+
}
2366+
}
2367+
service {
2368+
name: "Introspection"
2369+
method {
2370+
name: "Plugins"
2371+
input_type: ".containerd.services.introspection.v1.PluginsRequest"
2372+
output_type: ".containerd.services.introspection.v1.PluginsResponse"
2373+
}
2374+
}
2375+
options {
2376+
go_package: "github.com/containerd/containerd/api/services/introspection/v1;introspection"
2377+
}
2378+
syntax: "proto3"
2379+
}
21852380
file {
21862381
name: "github.com/containerd/containerd/api/services/namespaces/v1/namespace.proto"
21872382
package: "containerd.services.namespaces.v1"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package introspection

0 commit comments

Comments
 (0)