Skip to content

Shut down context during init if logging config fails#2594

Merged
christophebedard merged 2 commits intorollingfrom
christophebedard/shut-down-context-during-init-if-logging-init-fails
Aug 5, 2024
Merged

Shut down context during init if logging config fails#2594
christophebedard merged 2 commits intorollingfrom
christophebedard/shut-down-context-during-init-if-logging-init-fails

Conversation

@christophebedard
Copy link
Copy Markdown
Member

We already do this clean-up if some other tasks below fail.

Before:

  [ RUN      ] TestUtilities.test_context_init_shutdown_fails
  [ERROR] [1722555370.075637014] [rclcpp]: rcl context unexpectedly not shutdown during cleanup
  [WARN] [1722555370.077175569] [rclcpp]: logging was initialized more than once
  [       OK ] TestUtilities.test_context_init_shutdown_fails (3 ms)

After:

  [ RUN      ] TestUtilities.test_context_init_shutdown_fails
  [WARN] [1722555108.693207861] [rclcpp]: logging was initialized more than once
  [       OK ] TestUtilities.test_context_init_shutdown_fails (3 ms)

@christophebedard christophebedard self-assigned this Aug 1, 2024
@christophebedard
Copy link
Copy Markdown
Member Author

Not 100% sure if this is something we want to do, so I made this a draft, but it made sense to me.

@Barry-Xu-2018
Copy link
Copy Markdown
Collaborator

ret = rcl_logging_configure_with_output_handler(
&rcl_context_->global_arguments,
rcl_init_options_get_allocator(init_options.get_rcl_init_options()),
rclcpp_logging_output_handler);
if (RCL_RET_OK != ret) {
rcl_context_.reset();
rclcpp::exceptions::throw_from_rcl_error(ret, "failed to configure logging");
}

Before rcl_context_.reset(); , rcl_shutdown() should be called.

So I think your modification is reasonable.

@christophebedard christophebedard marked this pull request as ready for review August 2, 2024 04:10
Signed-off-by: Christophe Bedard <christophe.bedard@apex.ai>
@christophebedard
Copy link
Copy Markdown
Member Author

Alright then, this is ready for review.

I couldn't find a way to properly test this. I'm open to suggestions.

Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

makes sense to me.

btw, i happened to find the following context is not used for the test, maybe we should remove it?

auto context = std::make_shared<rclcpp::contexts::DefaultContext>();

We already do this clean-up if some other tasks below fail.

Before:

  [ RUN      ] TestUtilities.test_context_init_shutdown_fails
  [ERROR] [1722555370.075637014] [rclcpp]: rcl context unexpectedly not shutdown during cleanup
  [WARN] [1722555370.077175569] [rclcpp]: logging was initialized more than once
  [       OK ] TestUtilities.test_context_init_shutdown_fails (3 ms)

After:

  [ RUN      ] TestUtilities.test_context_init_shutdown_fails
  [WARN] [1722555108.693207861] [rclcpp]: logging was initialized more than once
  [       OK ] TestUtilities.test_context_init_shutdown_fails (3 ms)

Also, remove an unnecessary line in `test_utilities`.

Signed-off-by: Christophe Bedard <christophe.bedard@apex.ai>
@christophebedard christophebedard force-pushed the christophebedard/shut-down-context-during-init-if-logging-init-fails branch from 922e999 to 1a91601 Compare August 4, 2024 19:30
@christophebedard
Copy link
Copy Markdown
Member Author

Yeah, I don't think it's necessary. Removed.

@christophebedard
Copy link
Copy Markdown
Member Author

christophebedard commented Aug 4, 2024

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

@christophebedard christophebedard merged commit 4e4f0cf into rolling Aug 5, 2024
@christophebedard christophebedard deleted the christophebedard/shut-down-context-during-init-if-logging-init-fails branch August 5, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants