fix dependency disabled failed, dependency error and pre-enable illegal plugin
(cherry picked from commit 7050336b5637ec8c058c19506da0ef128a6771ad)
This commit is contained in:
parent
ce6d0bfd95
commit
52431a838a
115
0007-fix-dependency-disabled-failed-and-pre-enable-illega.patch
Normal file
115
0007-fix-dependency-disabled-failed-and-pre-enable-illega.patch
Normal file
@ -0,0 +1,115 @@
|
||||
From 2a6837386db74d59e35f2ff54499d79904ae1501 Mon Sep 17 00:00:00 2001
|
||||
From: fly_1997 <flylove7@outlook.com>
|
||||
Date: Thu, 13 Jun 2024 10:06:04 +0800
|
||||
Subject: [PATCH 1/2] fix dependency disabled failed and pre-enable illegal
|
||||
plugin
|
||||
|
||||
---
|
||||
src/plugin_mgr/instance_run_handler.cpp | 17 ++++++++++-------
|
||||
src/plugin_mgr/instance_run_handler.h | 4 +++-
|
||||
src/plugin_mgr/plugin_manager.cpp | 12 ++++++------
|
||||
3 files changed, 19 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/src/plugin_mgr/instance_run_handler.cpp b/src/plugin_mgr/instance_run_handler.cpp
|
||||
index 496166b..928b555 100644
|
||||
--- a/src/plugin_mgr/instance_run_handler.cpp
|
||||
+++ b/src/plugin_mgr/instance_run_handler.cpp
|
||||
@@ -79,10 +79,11 @@ void InstanceRunHandler::enable_instance(const std::string &name) {
|
||||
}
|
||||
}
|
||||
|
||||
-void InstanceRunHandler::disable_instance(const std::string &name) {
|
||||
- if (in_degree[name] != 0) {
|
||||
+void InstanceRunHandler::disable_instance(const std::string &name, RunType type) {
|
||||
+ if (type == RunType::INTERNAL_DISABLED && in_degree[name] != 0) {
|
||||
return;
|
||||
}
|
||||
+ in_degree[name] = 0;
|
||||
std::queue<std::shared_ptr<Node>> instance_node_queue;
|
||||
auto dep_handler = memory_store.get_dep_handler();
|
||||
instance_node_queue.push(dep_handler.get_node(name));
|
||||
@@ -111,12 +112,14 @@ void InstanceRunHandler::handle_instance() {
|
||||
while(this->recv_queue_try_pop(msg)){
|
||||
std::shared_ptr<Instance> instance = msg->get_instance();
|
||||
switch (msg->get_type()){
|
||||
- case RunType::ENABLED: {
|
||||
+ case RunType::ENABLED:
|
||||
+ case RunType::INTERNAL_ENABLED: {
|
||||
enable_instance(instance->get_name());
|
||||
break;
|
||||
}
|
||||
- case RunType::DISABLED: {
|
||||
- disable_instance(instance->get_name());
|
||||
+ case RunType::DISABLED:
|
||||
+ case RunType::INTERNAL_DISABLED: {
|
||||
+ disable_instance(instance->get_name(), msg->get_type());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -139,7 +142,7 @@ void InstanceRunHandler::change_instance_state(const std::string &name, std::vec
|
||||
if (instance->get_enabled()) {
|
||||
memory_store.delete_edge(name, instance->get_name());
|
||||
in_degree[instance->get_name()]--;
|
||||
- auto msg = std::make_shared<InstanceRunMessage>(RunType::DISABLED, instance);
|
||||
+ auto msg = std::make_shared<InstanceRunMessage>(RunType::INTERNAL_DISABLED, instance);
|
||||
recv_queue_push(std::move(msg));
|
||||
}
|
||||
}
|
||||
@@ -156,7 +159,7 @@ void InstanceRunHandler::change_instance_state(const std::string &name, std::vec
|
||||
if (!instance->get_enabled()) {
|
||||
in_degree[instance->get_name()]++;
|
||||
memory_store.add_edge(name, instance->get_name());
|
||||
- auto msg = std::make_shared<InstanceRunMessage>(RunType::ENABLED, instance);
|
||||
+ auto msg = std::make_shared<InstanceRunMessage>(RunType::INTERNAL_ENABLED, instance);
|
||||
recv_queue_push(std::move(msg));
|
||||
}
|
||||
}
|
||||
diff --git a/src/plugin_mgr/instance_run_handler.h b/src/plugin_mgr/instance_run_handler.h
|
||||
index 980fd98..682510b 100644
|
||||
--- a/src/plugin_mgr/instance_run_handler.h
|
||||
+++ b/src/plugin_mgr/instance_run_handler.h
|
||||
@@ -21,6 +21,8 @@
|
||||
enum class RunType {
|
||||
ENABLED,
|
||||
DISABLED,
|
||||
+ INTERNAL_ENABLED,
|
||||
+ INTERNAL_DISABLED,
|
||||
};
|
||||
|
||||
/* Message for communication between plugin manager and instance scheduling */
|
||||
@@ -89,7 +91,7 @@ private:
|
||||
void run_instance(std::vector<std::string> &deps, InstanceRun run);
|
||||
void change_instance_state(const std::string &name, std::vector<std::string> &deps, std::vector<std::string> &after_deps);
|
||||
void enable_instance(const std::string &name);
|
||||
- void disable_instance(const std::string &name);
|
||||
+ void disable_instance(const std::string &name, RunType type);
|
||||
private:
|
||||
/* Instance execution queue. */
|
||||
std::priority_queue<ScheduleInstance> schedule_queue;
|
||||
diff --git a/src/plugin_mgr/plugin_manager.cpp b/src/plugin_mgr/plugin_manager.cpp
|
||||
index 9ecaa6d..7220f48 100644
|
||||
--- a/src/plugin_mgr/plugin_manager.cpp
|
||||
+++ b/src/plugin_mgr/plugin_manager.cpp
|
||||
@@ -282,13 +282,13 @@ ErrorCode PluginManager::download(const std::string &name, std::string &res) {
|
||||
void PluginManager::pre_enable() {
|
||||
for (size_t i = 0; i < config->get_enable_list_size(); ++i) {
|
||||
EnableItem item = config->get_enable_list(i);
|
||||
+ std::string plugin_name = item.get_name();
|
||||
+ if (!memory_store.is_plugin_exist(plugin_name)) {
|
||||
+ WARN("[PluginManager] plugin " << plugin_name << " cannot be enabled, because it does not exist.");
|
||||
+ continue;
|
||||
+ }
|
||||
if (item.get_enabled()) {
|
||||
- std::string name = item.get_name();
|
||||
- if (!memory_store.is_plugin_exist(name)) {
|
||||
- WARN("[PluginManager] plugin " << name << " cannot be enabled, because it does not exist.");
|
||||
- continue;
|
||||
- }
|
||||
- std::shared_ptr<Plugin> plugin = memory_store.get_plugin(name);
|
||||
+ std::shared_ptr<Plugin> plugin = memory_store.get_plugin(plugin_name);
|
||||
for (size_t j = 0; j < plugin->get_instance_len(); ++j) {
|
||||
instance_enabled(plugin->get_instance(j)->get_name());
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
138
0008-fix-dependency-error-and-add-enable-failed-logs.patch
Normal file
138
0008-fix-dependency-error-and-add-enable-failed-logs.patch
Normal file
@ -0,0 +1,138 @@
|
||||
From 918ef95a2e5f9de71efa55beee35eaa083c31b7d Mon Sep 17 00:00:00 2001
|
||||
From: fly_1997 <flylove7@outlook.com>
|
||||
Date: Thu, 13 Jun 2024 16:28:19 +0800
|
||||
Subject: [PATCH 2/2] fix dependency error and add enable failed logs
|
||||
|
||||
---
|
||||
src/plugin_mgr/dep_handler.cpp | 22 +++++++++++++---------
|
||||
src/plugin_mgr/instance_run_handler.h | 2 ++
|
||||
src/plugin_mgr/plugin_manager.cpp | 17 ++++++++++++-----
|
||||
3 files changed, 27 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/src/plugin_mgr/dep_handler.cpp b/src/plugin_mgr/dep_handler.cpp
|
||||
index 227ee2f..2b20e7e 100644
|
||||
--- a/src/plugin_mgr/dep_handler.cpp
|
||||
+++ b/src/plugin_mgr/dep_handler.cpp
|
||||
@@ -28,22 +28,26 @@ void DepHandler::add_arc_node(std::shared_ptr<Node> node, const std::vector<std:
|
||||
std::shared_ptr<ArcNode> arc_head = node->head;
|
||||
node->cnt = dep_nodes.size();
|
||||
int real_cnt = 0;
|
||||
+ bool state = true;
|
||||
for (auto name : dep_nodes) {
|
||||
std::string from = node->instance->get_name();
|
||||
std::shared_ptr<ArcNode> tmp = std::make_shared<ArcNode>(from, name);
|
||||
tmp->next = arc_head->next;
|
||||
arc_head->next = tmp;
|
||||
-
|
||||
+ tmp->init = true;
|
||||
if (nodes.count(name)) {
|
||||
tmp->is_exist = true;
|
||||
- tmp->init = true;
|
||||
real_cnt++;
|
||||
+ if (!nodes[name]->instance->get_state()) {
|
||||
+ state = false;
|
||||
+ }
|
||||
}
|
||||
in_edges[name].insert(from);
|
||||
arc_nodes[std::make_pair(from, name)] = tmp;
|
||||
}
|
||||
+ /* node->instance->state = true, only all dependencies meet the conditions. */
|
||||
if (real_cnt == node->cnt) {
|
||||
- node->instance->set_state(true);
|
||||
+ node->instance->set_state(state);
|
||||
}
|
||||
node->real_cnt = real_cnt;
|
||||
}
|
||||
@@ -115,18 +119,17 @@ void DepHandler::del_node_and_arc_nodes(std::shared_ptr<Node> node) {
|
||||
}
|
||||
|
||||
void DepHandler::update_instance_state(const std::string &name) {
|
||||
- if (!nodes[name]->instance->get_state() || !in_edges.count(name)) return;
|
||||
+ if (!in_edges.count(name)) return;
|
||||
std::unordered_set<std::string> &arcs = in_edges[name];
|
||||
for (auto &from : arcs) {
|
||||
auto arc_node = arc_nodes[std::make_pair(from, name)];
|
||||
if (nodes.count(from)) {
|
||||
auto tmp = nodes[from];
|
||||
tmp->real_cnt++;
|
||||
- if (tmp->real_cnt == tmp->cnt) {
|
||||
+ if (tmp->real_cnt == tmp->cnt && nodes[name]->instance->get_state()) {
|
||||
tmp->instance->set_state(true);
|
||||
}
|
||||
arc_node->is_exist = true;
|
||||
- arc_node->init = true;
|
||||
update_instance_state(tmp->instance->get_name());
|
||||
}
|
||||
}
|
||||
@@ -144,8 +147,9 @@ void DepHandler::query_node_top(const std::string &name, std::vector<std::vector
|
||||
query.emplace_back(std::vector<std::string>{name});
|
||||
return;
|
||||
}
|
||||
- while (arc_node->next != nullptr) {
|
||||
- if (arc_node->next->is_exist) {
|
||||
+ while (arc_node->next != nullptr) {
|
||||
+ /* Display the edges that exist and the points that do not. */
|
||||
+ if (arc_node->next->is_exist || !nodes.count(arc_node->next->to)) {
|
||||
query.emplace_back(std::vector<std::string>{name, arc_node->next->to});
|
||||
}
|
||||
arc_node = arc_node->next;
|
||||
@@ -164,7 +168,7 @@ void DepHandler::query_node_dependency(const std::string &name, std::vector<std:
|
||||
std::string node_name = node->instance->get_name();
|
||||
query.emplace_back(std::vector<std::string>{node_name});
|
||||
for (auto cur = node->head->next; cur != nullptr; cur = cur->next) {
|
||||
- if (cur->is_exist) {
|
||||
+ if (cur->is_exist || !nodes.count(cur->to)) {
|
||||
query.emplace_back(std::vector<std::string>{node_name, cur->to});
|
||||
}
|
||||
if (!vis.count(cur->to) && nodes.count(cur->to)) {
|
||||
diff --git a/src/plugin_mgr/instance_run_handler.h b/src/plugin_mgr/instance_run_handler.h
|
||||
index 682510b..3804a49 100644
|
||||
--- a/src/plugin_mgr/instance_run_handler.h
|
||||
+++ b/src/plugin_mgr/instance_run_handler.h
|
||||
@@ -19,8 +19,10 @@
|
||||
#include <queue>
|
||||
|
||||
enum class RunType {
|
||||
+ /* Message from PluginManager. */
|
||||
ENABLED,
|
||||
DISABLED,
|
||||
+ /* Message from internal. */
|
||||
INTERNAL_ENABLED,
|
||||
INTERNAL_DISABLED,
|
||||
};
|
||||
diff --git a/src/plugin_mgr/plugin_manager.cpp b/src/plugin_mgr/plugin_manager.cpp
|
||||
index 7220f48..c3ff8bf 100644
|
||||
--- a/src/plugin_mgr/plugin_manager.cpp
|
||||
+++ b/src/plugin_mgr/plugin_manager.cpp
|
||||
@@ -290,16 +290,23 @@ void PluginManager::pre_enable() {
|
||||
if (item.get_enabled()) {
|
||||
std::shared_ptr<Plugin> plugin = memory_store.get_plugin(plugin_name);
|
||||
for (size_t j = 0; j < plugin->get_instance_len(); ++j) {
|
||||
- instance_enabled(plugin->get_instance(j)->get_name());
|
||||
+ std::string name = plugin->get_instance(j)->get_name();
|
||||
+ auto ret = instance_enabled(name);
|
||||
+ if (ret != ErrorCode::OK) {
|
||||
+ WARN("[PluginManager] " << name << " instance pre-enabled failed, because " << ErrorText::get_error_text(ret) << ".");
|
||||
+ } else {
|
||||
+ INFO("[PluginManager] " << name << " instance pre-enabled.");
|
||||
+ }
|
||||
}
|
||||
} else {
|
||||
for (size_t j = 0; j < item.get_instance_size(); ++j) {
|
||||
std::string name = item.get_instance_name(j);
|
||||
- if (!memory_store.is_instance_exist(name)) {
|
||||
- WARN("[PluginManager] instance " << name << " cannot be enabled, because it does not exist.");
|
||||
- continue;
|
||||
+ auto ret = instance_enabled(name);
|
||||
+ if (ret != ErrorCode::OK) {
|
||||
+ WARN("[PluginManager] " << name << " instance pre-enabled failed, because " << ErrorText::get_error_text(ret) << ".");
|
||||
+ } else {
|
||||
+ INFO("[PluginManager] " << name << " instance pre-enabled.");
|
||||
}
|
||||
- instance_enabled(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: oeAware-manager
|
||||
Version: v1.0.1
|
||||
Release: 5
|
||||
Release: 6
|
||||
Summary: OeAware server and client
|
||||
License: MulanPSL2
|
||||
URL: https://gitee.com/openeuler/%{name}
|
||||
@ -11,6 +11,8 @@ Patch3: 0003-the-client-adapts-to-the-new-interface-and-refactor-.patch
|
||||
Patch4: 0004-modify-some-interfaces-and-add-interface-comments.patch
|
||||
Patch5: 0005-add-the-SIGINT-signal-processing-and-singleton-class.patch
|
||||
Patch6: 0006-add-dynamic-dependencncy-adjustment.patch
|
||||
Patch7: 0007-fix-dependency-disabled-failed-and-pre-enable-illega.patch
|
||||
Patch8: 0008-fix-dependency-error-and-add-enable-failed-logs.patch
|
||||
|
||||
BuildRequires: cmake make gcc-c++
|
||||
BuildRequires: boost-devel
|
||||
@ -55,6 +57,10 @@ install -D -p -m 0644 oeaware.service %{buildroot}%{_unitdir}/oeaware.service
|
||||
%attr(0644, root, root) %{_unitdir}/oeaware.service
|
||||
|
||||
%changelog
|
||||
* Fri Jun 14 2024 fly_1997 <flylove7@outlook.com> -v1.0.1-6
|
||||
- fix dependency error and add enable failed logs
|
||||
- fix dependency disabled failed and pre-enable illegal plugin
|
||||
|
||||
* Wed Jun 12 2024 fly_1997 <flylove7@outlook.com> -v1.0.1-5
|
||||
- add Requires
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user