mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-18 06:44:23 +01:00
runtime-rs: add oci hook support
According to the runtime OCI Spec, there can be some hook operations in the lifecycle of the container. In these hook operations, the runtime can execute some commands. There are different points in time in the container lifecycle and different hook types can be executed. In this commit, we are now supporting 4 types of hooks(same in runtime-go): Prestart hook, CreateRuntime hook, Poststart hook and Poststop hook. Fixes: #5787 Signed-off-by: Yushuo <y-shuo@linux.alibaba.com>
This commit is contained in:
@@ -166,6 +166,9 @@ message Hooks {
|
||||
|
||||
// Poststop is a list of hooks to be run after the container process exits.
|
||||
repeated Hook Poststop = 3 [(gogoproto.nullable) = false];
|
||||
|
||||
// Createruntime is a list of hooks to be run during the creation of runtime(sandbox).
|
||||
repeated Hook CreateRuntime = 4 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
message Hook {
|
||||
|
||||
@@ -294,6 +294,7 @@ impl From<oci::Hooks> for crate::oci::Hooks {
|
||||
fn from(from: Hooks) -> Self {
|
||||
crate::oci::Hooks {
|
||||
Prestart: from_vec(from.prestart),
|
||||
CreateRuntime: from_vec(from.create_runtime),
|
||||
Poststart: from_vec(from.poststart),
|
||||
Poststop: from_vec(from.poststop),
|
||||
unknown_fields: Default::default(),
|
||||
@@ -974,6 +975,10 @@ impl From<crate::oci::Hooks> for oci::Hooks {
|
||||
for hook in from.take_Prestart().to_vec() {
|
||||
prestart.push(hook.into())
|
||||
}
|
||||
let mut create_runtime = Vec::new();
|
||||
for hook in from.take_CreateRuntime().to_vec() {
|
||||
create_runtime.push(hook.into())
|
||||
}
|
||||
let mut poststart = Vec::new();
|
||||
for hook in from.take_Poststart().to_vec() {
|
||||
poststart.push(hook.into());
|
||||
@@ -984,6 +989,7 @@ impl From<crate::oci::Hooks> for oci::Hooks {
|
||||
}
|
||||
oci::Hooks {
|
||||
prestart,
|
||||
create_runtime,
|
||||
poststart,
|
||||
poststop,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user