Removing Config Adapter - #455
Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
48210c0 to
84721b9
Compare
|
The created documentation from the pull request is available at: docu-html |
| { | ||
| score::concurrency::InterruptibleFuture<void> retVal_{}; | ||
|
|
||
| std::cout << "Setting state " << pg_name << pg_state << std::endl; |
There was a problem hiding this comment.
Use LM_LOG_DEBUG, or remove this.
| ISupervisionEventPublisher& supervision_event_publisher, | ||
| osal::IProcess* process_interface, | ||
| std::shared_ptr<SafeProcessMapInserter> process_map, | ||
| std::unordered_map<std::size_t, GraphIndex>& run_target_map) |
|
|
||
| LM_LOG_DEBUG() << "Process group index" << index << "(with name" << pg_name << ") has" << num_processes | ||
| << "processes"; | ||
| DependencyGraph<Graph::Component> graph(components.size() + run_targets.size() + 1); |
There was a problem hiding this comment.
Should we add a comment explaining why the + 1 is necessary?
| component_name_to_index[component_name] = index; | ||
|
|
||
| // all of this relies on graphindex having sequential indexes | ||
| // TODO use IdHash later... |
There was a problem hiding this comment.
Maybe add a link to #463 and explain that this method will be simplified after that change.
| { | ||
| return static_cast<int32_t>(index); | ||
| auto it = component_name_to_index.find(dep_name); | ||
| LM_LOG_ERROR() << run_targets[i].name << "HAS DEP TO " << dep_name; |
There was a problem hiding this comment.
| LM_LOG_ERROR() << run_targets[i].name << "HAS DEP TO " << dep_name; | |
| LM_LOG_DEBUG() << run_targets[i].name << "HAS DEP TO " << dep_name; |
| #include <ios> | ||
| #include <iostream> |
| // Wait for process group states to change while actively draining shutdown events. | ||
| if (!graph_) | ||
| { | ||
| return; |
There was a problem hiding this comment.
Think I will actually make all graph_ checks to asserts as this shall never happen. We could actually make this not a shared_ptr and then remove the checks at all, but I will make an issue for this to do in another PR
| LM_LOG_DEBUG() << "HERER++++++++"; | ||
| // Now process the request | ||
| switch (scc->request().request_or_response_) | ||
| { | ||
| case ControlClientCode::kSetStateRequest: | ||
| LM_LOG_DEBUG() << "HERER++++++++"; |
| // TODO: Determine recovery state from configuration | ||
| recovery_state.pg_state_name_ = IdentifierHash("fallback"); // TODO: Get from configuration |
| SCORE_LANGUAGE_FUTURECPP_PRECONDITION_MESSAGE( | ||
| it != component_name_to_index.end(), "RunTarget dependency not found in component list"); | ||
|
|
||
| graph.addDependency(num_of_components + i, it->second); |
There was a problem hiding this comment.
I think this would be clearer if we had something like
for (std::size_t run_target_i = 0; run_target_i < run_targets.size(); ++run_target_i) {
std::size_t node_i = num_of_components + run_target_i;
WilliamRoebuck
left a comment
There was a problem hiding this comment.
Looks good, I have mostly small comments, one or two suggestions for code changes
| #include <sys/stat.h> | ||
| #include <cerrno> | ||
| #include <cstdint> | ||
| #include <iostream> |
| EXPECT_THAT(target.recovery_action.run_target, Eq("SafeState")); | ||
| } | ||
|
|
||
| TEST_F(FlatbufferConfigLoaderTest, ConfiguredOffRunTargetIsLoadedVerbatim) |
There was a problem hiding this comment.
Can we add or extend a test to check that an "Off" target is created if none exists?
| using namespace score::mw::lifecycle::internal; | ||
| namespace configuration = score::mw::lifecycle::internal::configuration; |
There was a problem hiding this comment.
These are probably not needed anymore
| class Graph final | ||
| { | ||
| public: | ||
| /// @brief All possible implementation of a Component. |
There was a problem hiding this comment.
| /// @brief All possible implementation of a Component. | |
| /// @brief All currently supported component implementations |
| auto it = component_name_to_index.find(dep_name); | ||
| SCORE_LANGUAGE_FUTURECPP_PRECONDITION_MESSAGE( | ||
| it != component_name_to_index.end(), "Component dependency not found in component list"); | ||
|
|
||
| SCORE_LANGUAGE_FUTURECPP_ASSERT_DBG_MESSAGE(states != nullptr, "Process group states not found for process group"); | ||
| graph.addDependency(comp_dep_i, it->second); |
There was a problem hiding this comment.
This addDependency section is repeated 3 times, can we add a helper function/lambda? Or even better maybe we can iterate through all the dependencies in one loop somehow?
There was a problem hiding this comment.
Maybe you can add everything to the graph and then iterate through graph items, accessing the config by index?
| /// @details The implementation should be async signal safe. | ||
| OsalReturnType ProcessLauncher::setSchedulingAndSecurity(const OsalConfig& config) | ||
| OsalReturnType ProcessLauncher::setSchedulingAndSecurity( | ||
| const score::mw::lifecycle::internal::configuration::ComponentConfig& config) |
There was a problem hiding this comment.
Can we pass just the deployment config here?
| alive_monitor_thread_->stop(); | ||
| configuration_.deinitialize(); | ||
| process_groups_.clear(); | ||
| // No deinitialize needed - Config destructor handles cleanup |
There was a problem hiding this comment.
I don't think we need this comment
| } | ||
| return result; | ||
| SCORE_LANGUAGE_FUTURECPP_ASSERT_MESSAGE(bool(graph_), "Graph not initialized"); | ||
| // Convert string_view to IdentifierHash |
There was a problem hiding this comment.
There's a constructor at IdentifierHash.cpp:66, doesn't it work?
| // TODO: Determine recovery state from configuration | ||
| recovery_state.pg_state_name_ = IdentifierHash("fallback"); // TODO: Get from configuration |
| recovery_state.pg_state_name_ = IdentifierHash("fallback"); // TODO: Get from configuration | ||
|
|
||
| LM_LOG_WARN() << "Problem discovered in PG" << recovery_state.pg_name_ << "Activating Recovery state."; | ||
| LM_LOG_WARN() << "Problem discovered, activating recovery state: " << recovery_state.pg_state_name_; |
There was a problem hiding this comment.
| LM_LOG_WARN() << "Problem discovered, activating recovery state: " << recovery_state.pg_state_name_; | |
| LM_LOG_WARN() << "Problem discovered, activating recovery state:" << recovery_state.pg_state_name_; |
Extra space
Fixes #420
Currently we have a lot of code to bridge the old config and new. This PR removes the bridge and changes. Process Group Manager, Graph and Alive Monitor to use the new config.
This also partially addresses some multi-og code from #413. However our IPC still has a field for the pg_name and there is still a bunch of references to it in comments and method names.
This also creates a temporary
CreateDependencyGraphfunction that takes the config and creates aDependencyGraphfrom it. This is intentionally left as not polished and un covered with UTs as it shall be more or less removed in #463.Another point to address is that the AliveMonitor copies its config as the shape of the config doesn't fit the current implementation. This will be addressed in #477.