!5 [sync] PR-4: Update to v0.0.2

From: @openeuler-sync-bot 
Reviewed-by: @taotao-sauce 
Signed-off-by: @taotao-sauce
This commit is contained in:
openeuler-ci-bot 2024-11-26 02:24:38 +00:00 committed by Gitee
commit 45528763f0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 88 additions and 63 deletions

View File

@ -1,59 +0,0 @@
From 8f18f3be75b1631d259c0a296cbf79df0cecd17a Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Sat, 17 Aug 2024 17:02:02 +0000
Subject: [PATCH] add some missing c-rust struct transfer
Signed-off-by: jikai <jikai11@huawei.com>
---
nri/src/nri/c_transfer.rs | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/nri/src/nri/c_transfer.rs b/nri/src/nri/c_transfer.rs
index 7c67e01..913fab9 100644
--- a/nri/src/nri/c_transfer.rs
+++ b/nri/src/nri/c_transfer.rs
@@ -218,6 +218,11 @@ impl From<&NriLinuxMemory> for nri::LinuxMemory {
disable_oom_killer.value = unsafe { *req.disable_oom_killer } != 0;
r_rq.disable_oom_killer = MessageField::some(disable_oom_killer);
}
+ if !req.use_hierarchy.is_null() {
+ let mut use_hierarchy = OptionalBool::new();
+ use_hierarchy.value = unsafe { *req.use_hierarchy } != 0;
+ r_rq.use_hierarchy = MessageField::some(use_hierarchy);
+ }
r_rq
}
@@ -619,8 +624,9 @@ impl From<&NriPodSandbox> for nri::PodSandbox {
r_req.id = to_string(req.id);
r_req.name = to_string(req.name);
r_req.uid = to_string(req.uid);
- r_req.labels = to_hash_map(req.labels);
r_req.namespace = to_string(req.namespace);
+ r_req.labels = to_hash_map(req.labels);
+ r_req.annotations = to_hash_map(req.annotations);
r_req.runtime_handler =to_string(req.runtime_handler);
if !req.linux.is_null() {
r_req.linux = MessageField::some(nri::LinuxPodSandbox::from(unsafe { req.linux.as_ref() }.unwrap()));
@@ -645,7 +651,7 @@ impl From<&NriMount> for nri::Mount {
let mut r_req = nri::Mount::new();
r_req.destination = to_string(req.destination);
r_req.type_ = to_string(req.type_);
- r_req.source =to_string(req.source);
+ r_req.source = to_string(req.source);
r_req.options = c_char_ptr_ptr_to_vec(req.options, req.options_len);
r_req
}
@@ -929,6 +935,9 @@ impl From<&NriContainerUpdate> for nri::ContainerUpdate {
fn from(req: &NriContainerUpdate) -> Self {
let mut r_req = nri::ContainerUpdate::new();
r_req.container_id = to_string(req.container_id);
+ if !req.linux.is_null() {
+ r_req.linux = MessageField::some(nri::LinuxContainerUpdate::from(unsafe { req.linux.as_ref() }.unwrap()));
+ }
r_req.ignore_failure = (req.ignore_failure != 0) as bool;
r_req
}
--
2.34.1

View File

@ -0,0 +1,63 @@
From 1044093af3d4e1db0ffa695bfaf5124f7589fa15 Mon Sep 17 00:00:00 2001
From: xuxuepeng <xuxuepeng1@huawei.com>
Date: Fri, 22 Nov 2024 02:51:29 +0800
Subject: [PATCH] change wait callback argument from u8 to c_char fix couples
of warnings as well
Signed-off-by: xuxuepeng <xuxuepeng1@huawei.com>
---
sandbox/src/controller/client.rs | 1 -
sandbox/src/lib.rs | 11 +++++------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/sandbox/src/controller/client.rs b/sandbox/src/controller/client.rs
index c02954b..25377fd 100644
--- a/sandbox/src/controller/client.rs
+++ b/sandbox/src/controller/client.rs
@@ -32,7 +32,6 @@ use sandbox::containerd::services::sandbox::v1::ControllerUpdateRequest;
use sandbox::containerd::services::sandbox::v1::ControllerUpdateResponse;
use tonic::transport::Channel;
-use tower::ServiceExt;
#[derive(Debug, Clone)]
pub struct Client {
pub channel: Channel,
diff --git a/sandbox/src/lib.rs b/sandbox/src/lib.rs
index ac24c7d..1d2626c 100644
--- a/sandbox/src/lib.rs
+++ b/sandbox/src/lib.rs
@@ -16,8 +16,7 @@ mod datatype;
use controller::client;
use datatype::sandbox_types;
use tokio::time::{ sleep, Duration };
-use std::os::raw::{c_char, c_int, c_void};
-use std::sync::{ Arc, Mutex };
+use std::os::raw::{c_char, c_int};
use lazy_static::lazy_static;
use tokio::runtime::Runtime;
use async_recursion::async_recursion;
@@ -228,9 +227,9 @@ pub unsafe extern "C" fn sandbox_api_update(
sandbox_api_execute!(controller_context, r_req, update)
}
-pub type SandboxReadyCallback = extern "C" fn(*const u8);
-pub type SandboxPendingCallback = extern "C" fn(*const u8);
-pub type SandboxExitCallback = extern "C" fn(*const u8, *const sandbox_types::SandboxWaitResponse);
+pub type SandboxReadyCallback = extern "C" fn(*const c_char);
+pub type SandboxPendingCallback = extern "C" fn(*const c_char);
+pub type SandboxExitCallback = extern "C" fn(*const c_char, *const sandbox_types::SandboxWaitResponse);
#[repr(C)]
pub struct SandboxWaitCallback {
@@ -269,7 +268,7 @@ pub async fn is_connection_alive(
match (*client).platform(r_req).await {
Ok(_) => true,
Err(e) => {
- println!("Sandbox API: Failed to connect to client, {:?}", sandbox_id);
+ println!("Sandbox API: Failed to connect to client, {:?}, {:?}", sandbox_id, e);
false
}
}
--
2.33.0

Binary file not shown.

Binary file not shown.

View File

@ -6,7 +6,7 @@
%define debug_package %{nil}
Name: isula-rust-extensions
Version: 0.0.1
Version: 0.0.2
Release: 1
URL: https://gitee.com/openeuler/isula-rust-extensions
Source: %{name}-%{version}.tar.gz
@ -16,12 +16,12 @@ License: Mulan PSL v2
ExclusiveArch: x86_64 aarch64
Patch0001: 0001-add-some-missing-c-rust-struct-transfer.patch
Patch0001: 0001-change-wait-callback-argument-from-u8-to-c_char.patch
BuildRequires: rust
BuildRequires: cargo
BuildRequires: rust-packaging
BuildRequires: gcc
BuildRequires: cmake gcc
%description
Based on Rust programming language, rust-extension library for iSulad.
@ -41,9 +41,13 @@ pushd nri
%cargo_prep
%cargo_generate_buildrequires
popd
pushd sandbox
%cargo_prep
%cargo_generate_buildrequires
popd
%build
cd nri
pushd nri
sed -i '/\[source.crates-io\]/{n;d}' ./.cargo/config
sed -i '/\[source.local-registry\]/{n;d}' ./.cargo/config
sed -i '/\[source.local-registry\]/a directory = "vendor"' ./.cargo/config
@ -51,12 +55,25 @@ sed -i '/\[source.local-registry\]/a directory = "vendor"' ./.cargo/config
sed -i 's/rustflags = \[/rustflags = \["-Clink-arg=-lgcc", "-Clink-arg=-lfdt", /g' ./.cargo/config
%endif
%cargo_build -a
popd
pushd sandbox
sed -i '/\[source.crates-io\]/{n;d}' ./.cargo/config
sed -i '/\[source.local-registry\]/{n;d}' ./.cargo/config
sed -i '/\[source.local-registry\]/a directory = "vendor"' ./.cargo/config
%ifarch aarch64
sed -i 's/rustflags = \[/rustflags = \["-Clink-arg=-lgcc", "-Clink-arg=-lfdt", /g' ./.cargo/config
%endif
%cargo_build -a
popd
%install
mkdir -p ${RPM_BUILD_ROOT}/{%{_libdir},%{_includedir}}
install -m 0644 nri/nri_plugin.h ${RPM_BUILD_ROOT}/%{_includedir}/nri_plugin.h
strip nri/target/release/libisula_nri.so
install -m 0755 nri/target/release/libisula_nri.so ${RPM_BUILD_ROOT}/%{_libdir}/libisula_nri.so
install -m 0644 sandbox/isula_sandbox_api.h ${RPM_BUILD_ROOT}/%{_includedir}/isula_sandbox_api.h
strip sandbox/target/release/libisula_sandbox.so
install -m 0755 sandbox/target/release/libisula_sandbox.so ${RPM_BUILD_ROOT}/%{_libdir}/libisula_sandbox.so
%files
%defattr(-,root, root,-)
@ -65,7 +82,11 @@ install -m 0755 nri/target/release/libisula_nri.so ${RPM_BUILD_ROOT}/%{_libdir}/
%files devel
%defattr(-,root, root,-)
%{_includedir}/nri_plugin.h
%{_includedir}/isula_sandbox_api.h
%changelog
* Fri Nov 22 2024 xuxuepeng <xuxuepeng1@huawei.com> - 0.0.2-1
- Update to 0.0.2, add support for sandbox API
* Fri Aug 09 2024 jikai <jikai11@huawei.com> - 0.0.1-1
- Initial RPM release