From 416bb1ac98c9afc8f5b726a35f5b392f45e9f213 Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Mon, 27 Apr 2026 14:06:11 +0800 Subject: [PATCH] update sandbox api proto Update sandbox API protocols based on the latest containerd Signed-off-by: Alex Lyn --- crates/shim-protos/build.rs | 11 +- crates/shim-protos/src/sandbox.rs | 4 + .../api/runtime/sandbox/v1/sandbox.proto | 129 ++++++++++-------- 3 files changed, 84 insertions(+), 60 deletions(-) diff --git a/crates/shim-protos/build.rs b/crates/shim-protos/build.rs index d5e1c006..5f7148dd 100644 --- a/crates/shim-protos/build.rs +++ b/crates/shim-protos/build.rs @@ -33,6 +33,7 @@ fn main() { "vendor/github.com/containerd/containerd/api/types/mount.proto", "vendor/github.com/containerd/containerd/api/types/task/task.proto", "vendor/github.com/containerd/containerd/api/types/introspection.proto", + "vendor/github.com/containerd/containerd/api/types/metrics.proto", #[cfg(feature = "sandbox")] "vendor/github.com/containerd/containerd/api/types/platform.proto", ], @@ -92,14 +93,20 @@ fn main() { { genmodule( "sandbox", - &["vendor/github.com/containerd/containerd/api/runtime/sandbox/v1/sandbox.proto"], + &[ + "vendor/github.com/containerd/containerd/api/types/metrics.proto", + "vendor/github.com/containerd/containerd/api/runtime/sandbox/v1/sandbox.proto", + ], false, ); #[cfg(feature = "async")] genmodule( "sandbox_async", - &["vendor/github.com/containerd/containerd/api/runtime/sandbox/v1/sandbox.proto"], + &[ + "vendor/github.com/containerd/containerd/api/types/metrics.proto", + "vendor/github.com/containerd/containerd/api/runtime/sandbox/v1/sandbox.proto", + ], true, ); } diff --git a/crates/shim-protos/src/sandbox.rs b/crates/shim-protos/src/sandbox.rs index 1423061d..5289f503 100644 --- a/crates/shim-protos/src/sandbox.rs +++ b/crates/shim-protos/src/sandbox.rs @@ -14,6 +14,10 @@ limitations under the License. */ +pub mod metrics { + include!(concat!(env!("OUT_DIR"), "/sandbox/metrics.rs")); +} + pub mod sandbox { include!(concat!(env!("OUT_DIR"), "/sandbox/sandbox.rs")); } diff --git a/crates/shim-protos/vendor/github.com/containerd/containerd/api/runtime/sandbox/v1/sandbox.proto b/crates/shim-protos/vendor/github.com/containerd/containerd/api/runtime/sandbox/v1/sandbox.proto index a051f3ea..1dfadc4c 100644 --- a/crates/shim-protos/vendor/github.com/containerd/containerd/api/runtime/sandbox/v1/sandbox.proto +++ b/crates/shim-protos/vendor/github.com/containerd/containerd/api/runtime/sandbox/v1/sandbox.proto @@ -1,17 +1,17 @@ /* - Copyright The containerd Authors. + Copyright The containerd Authors. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ syntax = "proto3"; @@ -20,7 +20,7 @@ package containerd.runtime.sandbox.v1; import "google/protobuf/any.proto"; import "google/protobuf/timestamp.proto"; - +import "github.com/containerd/containerd/api/types/metrics.proto"; import "github.com/containerd/containerd/api/types/mount.proto"; import "github.com/containerd/containerd/api/types/platform.proto"; @@ -30,107 +30,120 @@ option go_package = "github.com/containerd/containerd/api/runtime/sandbox/v1;san // A typical example of sandbox is microVM or pause container - an entity that groups containers and/or // holds resources relevant for this group. service Sandbox { - // CreateSandbox will be called right after sandbox shim instance launched. - // It is a good place to initialize sandbox environment. - rpc CreateSandbox(CreateSandboxRequest) returns (CreateSandboxResponse); + // CreateSandbox will be called right after sandbox shim instance launched. + // It is a good place to initialize sandbox environment. + rpc CreateSandbox(CreateSandboxRequest) returns (CreateSandboxResponse); + + // StartSandbox will start a previously created sandbox. + rpc StartSandbox(StartSandboxRequest) returns (StartSandboxResponse); - // StartSandbox will start previsouly created sandbox. - rpc StartSandbox(StartSandboxRequest) returns (StartSandboxResponse); + // Platform queries the platform the sandbox is going to run containers on. + // containerd will use this to generate a proper OCI spec. + rpc Platform(PlatformRequest) returns (PlatformResponse); - // Platform queries the platform the sandbox is going to run containers on. - // containerd will use this to generate a proper OCI spec. - rpc Platform(PlatformRequest) returns (PlatformResponse); + // StopSandbox will stop existing sandbox instance + rpc StopSandbox(StopSandboxRequest) returns (StopSandboxResponse); - // StopSandbox will stop existing sandbox instance - rpc StopSandbox(StopSandboxRequest) returns (StopSandboxResponse); + // WaitSandbox blocks until sandbox exits. + rpc WaitSandbox(WaitSandboxRequest) returns (WaitSandboxResponse); - // WaitSandbox blocks until sanbox exits. - rpc WaitSandbox(WaitSandboxRequest) returns (WaitSandboxResponse); + // SandboxStatus will return current status of the running sandbox instance + rpc SandboxStatus(SandboxStatusRequest) returns (SandboxStatusResponse); - // SandboxStatus will return current status of the running sandbox instance - rpc SandboxStatus(SandboxStatusRequest) returns (SandboxStatusResponse); + // PingSandbox is a lightweight API call to check whether sandbox alive. + rpc PingSandbox(PingRequest) returns (PingResponse); - // PingSandbox is a lightweight API call to check whether sandbox alive. - rpc PingSandbox(PingRequest) returns (PingResponse); + // ShutdownSandbox must shutdown shim instance. + rpc ShutdownSandbox(ShutdownSandboxRequest) returns (ShutdownSandboxResponse); - // ShutdownSandbox must shutdown shim instance. - rpc ShutdownSandbox(ShutdownSandboxRequest) returns (ShutdownSandboxResponse); + // SandboxMetrics retrieves metrics about a sandbox instance. + rpc SandboxMetrics(SandboxMetricsRequest) returns (SandboxMetricsResponse); } message CreateSandboxRequest { - string sandbox_id = 1; - string bundle_path = 2; - repeated containerd.types.Mount rootfs = 3; - google.protobuf.Any options = 4; - string netns_path = 5; + string sandbox_id = 1; + string bundle_path = 2; + repeated containerd.types.Mount rootfs = 3; + google.protobuf.Any options = 4; + string netns_path = 5; + map annotations = 6; } message CreateSandboxResponse {} message StartSandboxRequest { - string sandbox_id = 1; + string sandbox_id = 1; } message StartSandboxResponse { - uint32 pid = 1; - google.protobuf.Timestamp created_at = 2; + uint32 pid = 1; + google.protobuf.Timestamp created_at = 2; + google.protobuf.Any spec = 3; } message PlatformRequest { - string sandbox_id = 1; + string sandbox_id = 1; } message PlatformResponse { - containerd.types.Platform platform = 1; + containerd.types.Platform platform = 1; } message StopSandboxRequest { - string sandbox_id = 1; - uint32 timeout_secs = 2; + string sandbox_id = 1; + uint32 timeout_secs = 2; } message StopSandboxResponse {} message UpdateSandboxRequest { - string sandbox_id = 1; - google.protobuf.Any resources = 2; - map annotations = 3; + string sandbox_id = 1; + google.protobuf.Any resources = 2; + map annotations = 3; } message WaitSandboxRequest { - string sandbox_id = 1; + string sandbox_id = 1; } message WaitSandboxResponse { - uint32 exit_status = 1; - google.protobuf.Timestamp exited_at = 2; + uint32 exit_status = 1; + google.protobuf.Timestamp exited_at = 2; } message UpdateSandboxResponse {} message SandboxStatusRequest { - string sandbox_id = 1; - bool verbose = 2; + string sandbox_id = 1; + bool verbose = 2; } message SandboxStatusResponse { - string sandbox_id = 1; - uint32 pid = 2; - string state = 3; - map info = 4; - google.protobuf.Timestamp created_at = 5; - google.protobuf.Timestamp exited_at = 6; - google.protobuf.Any extra = 7; + string sandbox_id = 1; + uint32 pid = 2; + string state = 3; + map info = 4; + google.protobuf.Timestamp created_at = 5; + google.protobuf.Timestamp exited_at = 6; + google.protobuf.Any extra = 7; } message PingRequest { - string sandbox_id = 1; + string sandbox_id = 1; } message PingResponse {} message ShutdownSandboxRequest { - string sandbox_id = 1; + string sandbox_id = 1; } message ShutdownSandboxResponse {} + +message SandboxMetricsRequest { + string sandbox_id = 1; +} + +message SandboxMetricsResponse { + containerd.types.Metric metrics = 1; +}