Signed-off-by: zhongtao <zhongtao17@huawei.com> (cherry picked from commit 2b0d5a6513507eeece64da43cde77e9e92e21b51)
81 lines
2.9 KiB
Diff
81 lines
2.9 KiB
Diff
From 08b996a54c6330e704cbc9271f348a62e24fe880 Mon Sep 17 00:00:00 2001
|
|
From: zhongtao <zhongtao17@huawei.com>
|
|
Date: Wed, 18 Dec 2024 22:43:26 +1400
|
|
Subject: [PATCH 157/158] bugfix for nri init
|
|
|
|
Signed-off-by: zhongtao <zhongtao17@huawei.com>
|
|
---
|
|
src/daemon/common/nri/nri_convert.cc | 7 ++++---
|
|
src/daemon/nri/nri_plugin_ops.cc | 28 +++++++++++++---------------
|
|
2 files changed, 17 insertions(+), 18 deletions(-)
|
|
|
|
diff --git a/src/daemon/common/nri/nri_convert.cc b/src/daemon/common/nri/nri_convert.cc
|
|
index d862d992..6e571d9a 100644
|
|
--- a/src/daemon/common/nri/nri_convert.cc
|
|
+++ b/src/daemon/common/nri/nri_convert.cc
|
|
@@ -196,7 +196,6 @@ auto PodSandboxToNRI(const std::shared_ptr<const sandbox::Sandbox> &sandbox, nri
|
|
pod._namespace = util_strdup_s(sandbox->GetSandboxConfig().metadata().namespace_().c_str());
|
|
}
|
|
|
|
-
|
|
pod.labels = Transform::ProtobufMapToJsonMapForString(sandbox->GetSandboxConfig().labels(), tmpError);
|
|
if (pod.labels == nullptr) {
|
|
ERROR("Failed to transform labels to nri for pod : %s, : %s", pod.name, tmpError.GetMessage().c_str());
|
|
@@ -971,9 +970,11 @@ auto ContainerToNRIByID(const std::string &id, nri_container &con) -> bool
|
|
goto out;
|
|
}
|
|
|
|
- con.pod_sandbox_id = util_strdup_s(cont->common_config->sandbox_info->id);
|
|
- ret = true;
|
|
+ if (cont->common_config->sandbox_info!= nullptr && cont->common_config->sandbox_info->id != nullptr) {
|
|
+ con.pod_sandbox_id = util_strdup_s(cont->common_config->sandbox_info->id);
|
|
+ }
|
|
|
|
+ ret = true;
|
|
out:
|
|
container_unref(cont);
|
|
return ret;
|
|
diff --git a/src/daemon/nri/nri_plugin_ops.cc b/src/daemon/nri/nri_plugin_ops.cc
|
|
index e2f88b63..7953f7de 100644
|
|
--- a/src/daemon/nri/nri_plugin_ops.cc
|
|
+++ b/src/daemon/nri/nri_plugin_ops.cc
|
|
@@ -42,22 +42,20 @@ bool nri_adaption_init(void)
|
|
{
|
|
Errors error;
|
|
|
|
- if (!conf_get_nri_support()) {
|
|
- return true;
|
|
- }
|
|
-
|
|
- nri_runtime_callbacks callbacks;
|
|
- callbacks.register_plugin = nri_registry_containers;
|
|
- callbacks.update_containers = nri_update_containers;
|
|
- if (nri_runtime_service_init(callbacks) != 0) {
|
|
- ERROR("Failed to init runtime service\n");
|
|
- return false;
|
|
- }
|
|
+ if (conf_get_nri_support()) {
|
|
+ nri_runtime_callbacks callbacks;
|
|
+ callbacks.register_plugin = nri_registry_containers;
|
|
+ callbacks.update_containers = nri_update_containers;
|
|
+ if (nri_runtime_service_init(callbacks) != 0) {
|
|
+ ERROR("Failed to init runtime service\n");
|
|
+ return false;
|
|
+ }
|
|
|
|
- if (conf_get_nri_external_support()) {
|
|
- if (!start_external_listener()) {
|
|
- ERROR("Failed to start external listener\n");
|
|
- goto clean_out;
|
|
+ if (conf_get_nri_external_support()) {
|
|
+ if (!start_external_listener()) {
|
|
+ ERROR("Failed to start external listener\n");
|
|
+ goto clean_out;
|
|
+ }
|
|
}
|
|
}
|
|
|
|
--
|
|
2.25.1
|
|
|