Conversation
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //:license-checkStatus: Click to expand output |
WilliamRoebuck
left a comment
There was a problem hiding this comment.
A really great implementation, I have some small cleanup suggestions. I also rambled a bit about the API but I understand I may be a bit late on this so apologies if it's not relevant. As I'll be away from tomorrow, just comment and resolve if you disagree or I've misunderstood
This works around the `Graph` class not being thread safe.
This resolves several edge cases which the new version did not handle properly.
|
|
||
| ~ControlProvider() = default; | ||
|
|
||
| // Cannot be moved because callbacks capture the ControlProvider by reference. |
There was a problem hiding this comment.
I am not sure if the comment in the code is quite correct. Previously, launch manager would segfault after the ControlProvider was moved. I am only assuming that this is the explanation.
Because of this restriction, ControlProvider::Create has to allocate and return a reference. It would be good to avoid it if anyone knows how...
| case fb::ApplicationType::State_Manager: | ||
| return ApplicationType::StateManager; | ||
| // These are now equivalent as access control is done via mw::com | ||
| return ApplicationType::ReportingAndSupervised; |
There was a problem hiding this comment.
I wonder if it would still make sense to keep all of this to somehow limit who can change run targets?
There was a problem hiding this comment.
This needs to be done through mw::com access control.
| namespace score::mw::lifecycle::internal | ||
| { | ||
|
|
||
| class IControllableGraph |
There was a problem hiding this comment.
Not sure about this name, Maybe something like IComponentController? Probably should also be in process_group_manager
| namespace score::mw::lifecycle::internal | ||
| { | ||
|
|
||
| class ControlProvider |
There was a problem hiding this comment.
Would be good to also add a brief for what the class does
| } | ||
| LmControlSkeleton skeleton = std::move(skeleton_result).value(); | ||
|
|
||
| auto* control_provider = new ControlProvider{std::move(skeleton), graph}; |
There was a problem hiding this comment.
why allocate this? could just create and move into Result
|
|
||
| const std::optional<IdentifierHash> new_state = IdentifierHash::if_exists(request.run_target_name.data()); | ||
| if (!new_state.has_value()) | ||
| { |
There was a problem hiding this comment.
Think logging errors would also be a good idea here.
| } | ||
|
|
||
| const std::lock_guard<std::mutex> lock(IdentifierHash::get_registry_mutex()); | ||
| const std::string& name = IdentifierHash::get_registry()[result.value().data()]; |
There was a problem hiding this comment.
could you make a Result<std::string_view> IdentifierHash::get_name(IdentifierHash) method as this can throw? originally I think the registry was made just for logging but since its becoming needed for the internal logic I think making it safer would be a good idea.
| ControlProvider& operator=(const ControlProvider&) = delete; | ||
| ControlProvider operator=(ControlProvider&&) = delete; | ||
|
|
||
| private: |
There was a problem hiding this comment.
Can you go through and check which methods can be marked as noexcept? I think probably all methods here should be?
| IdentifierHash process_identifier; | ||
| }; | ||
|
|
||
| struct [[nodiscard]] GetActiveRunTarget |
| const IdentifierHash state = getProcessGroupState(); | ||
|
|
||
| RunTargetActivationSource source; | ||
| if (is_initial_state_transition_) |
There was a problem hiding this comment.
think this is clang-tidy warning to not have braces around the if
| { | ||
| // This verifies that a fallback process was actually started - the launch manager | ||
| // did not just send an event without taking the action. | ||
| EXPECT_TRUE(std::filesystem::exists(fallback_file)) << "Fallback run target should have been activated"; |
There was a problem hiding this comment.
Some test drivers verify activation via a marker file on disk (e.g. EXPECT_TRUE(std::filesystem::exists(fallback_file))). Now that get_active_run_target() exists, could tests assert against client->get_active_run_target() instead — checking the daemon's own state rather than a side effect? Not a blocker, could be a fast-follow.
There was a problem hiding this comment.
Yes, this can be cleaned up as a follow-up.
This pull request adapts the launch manager (and tests) to use the new control API based on
mw::com, and removes the old API.Notable points
The
State_Managerapplication type is now aliased toReporting_and_Supervised.Instead,
mw::comaccess control must be used to prevent unwanted processes acting as state managers.There is a workaround to make the
process_fd_leaktest pass, because there is no possibility to setO_CLOEXEConmw::com's file descriptors when they are created.I've opened an issue to fix this upstream: Set
CLOEXECon file descriptors communication#1064External documentation needs to be updated before this is released.
Relevant issues