Skip to content

Don't throw an exception if removing a node not associated with any executor#3190

Open
skyegalaxy wants to merge 8 commits into
rollingfrom
skyegalaxy/no-throw-on-nonexistent-node-removal
Open

Don't throw an exception if removing a node not associated with any executor#3190
skyegalaxy wants to merge 8 commits into
rollingfrom
skyegalaxy/no-throw-on-nonexistent-node-removal

Conversation

@skyegalaxy

@skyegalaxy skyegalaxy commented Jul 10, 2026

Copy link
Copy Markdown
Member

Description

This PR changes remove_node in both executor_entities_collector and events_cbg_executor to warn the user that the node they're trying to remove isn't associated with the executor, instead of throwing an exception, as well as updating the existing tests.

An exception will still be thrown if the user tries to remove a node associated with a DIFFERENT executor, as that would be an obvious programmer error. The behavior of remove_node in EventsCBGExecutor has been updated to mirror this behavior from the other executors.

A regression test has also been added to test_component_manager_api in rclcpp_components, which asserts that an exception isn't thrown during the double-removal case as outlined in #3186

Fixes #3186

Is this user-facing behavior change?

  • Users will no longer get an exception on shutdown when using component managers with the callback group events executor
  • Users will now get a WARNING instead of an exception throw when trying to remove a node not associated with any executor
  • Users will now get an exception if they try to add a node already associated with another executor to the callback group events executor

Did you use Generative AI?

Claude Opus 4.8

Additional Information

Skyler Medeiros added 6 commits July 10, 2026 10:55
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
@skyegalaxy skyegalaxy requested a review from jmachowinski July 10, 2026 19:40
@skyegalaxy skyegalaxy self-assigned this Jul 10, 2026
@skyegalaxy skyegalaxy added the bug Something isn't working label Jul 10, 2026
@mergify

mergify Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@ahcorde

ahcorde commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Pulls: #3190
Gist: https://gist.githubusercontent.com/ahcorde/0921923647104ed12128ae08da3c7b80/raw/62b669e2d3ce5aba62ac68d53a57e0c095eb3cfa/ros2.repos
BUILD args: --packages-above-and-dependencies rclcpp rclcpp_components
TEST args: --packages-above rclcpp rclcpp_components
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/19824

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@fujitatomoya fujitatomoya left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have 2 comments.

  • * \throw std::runtime_error if the node is not associated with an executor.
    should be also updated align with implementation.
  • normal Ctrl+C shutdown will now WARN-spam once per node, every time. the double-remove sequence is still deterministic though. either the coordination should also be fixed (e.g., ~ComponentManager skips nodes whose association flag is already clear, or EventsCBGExecutor's shutdown notifies/clears differently)? warning on every clean shutdown trains users to ignore warnings?

Skyler Medeiros added 2 commits July 13, 2026 14:01
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
Signed-off-by: Skyler Medeiros <skye@polymathrobotics.com>
@skyegalaxy

Copy link
Copy Markdown
Member Author

I appreciate your review and feedback @fujitatomoya ! I updated the docstrings here and also added a check in the component manager destructor for if the node's already associated with an executor before removing. That gets rid of the warning for the test case I added on my end.

@skyegalaxy skyegalaxy requested a review from fujitatomoya July 13, 2026 21:14
@skyegalaxy

Copy link
Copy Markdown
Member Author
  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EventsCBGExecutor shutdown + ComponentManager destructor cause double remove and runtime_error on shutdown

3 participants