Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the exit code a required process through roslaunch #2082

Open
wants to merge 4 commits into
base: noetic-devel
Choose a base branch
from

Conversation

lucasw
Copy link
Contributor

@lucasw lucasw commented Oct 19, 2020

Return the exit code to the caller of a required process at least for a regular parent launch process, child and remote processes need looking at.

May solve #919

Copy link
Contributor

@sloretz sloretz left a comment

Choose a reason for hiding this comment

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

May solve #919

Please add a test :)

It looks like CI is failing. Please resolve the existing test failures.

tools/roslaunch/src/roslaunch/__init__.py Outdated Show resolved Hide resolved
tools/roslaunch/src/roslaunch/__init__.py Outdated Show resolved Hide resolved
@lucasw
Copy link
Contributor Author

lucasw commented Nov 6, 2020

Made some cleanup and existing tests pass.

A new test that launches a node with required=true then forces it to exit non-zero, then inspects roslaunch exit code is the next step. Any pointers to an existing roslaunch test that would be a good template for this would be very welcome, otherwise I'll figure it out eventually.

I'll hold on to the remaining extra prints until I'm done with that, a few I think it makes sense to keep.

@xkortex
Copy link

xkortex commented Feb 1, 2021

Just tested this patch ported to melodic. Works for me!

I did notice that the roslaunch xml node has to be marked as required="true", which is logical. Just wanted to point that out, as it threw me for a loop for a second.

1612214530.892673: Code shutdown requested: 37
================================================================================REQUIRED process [host/exit_code_node-1] has died!
process has died [pid 24194, exit code 37, cmd /root/src/core/nodes/exit_code_node.py __name:=exit_code_node __log:=/root/.ros/log/906b1440-649f-11eb-8a83-78d00426c726/-exit_code_node-1.log].
log file: /root/.ros/log/906b1440-649f-11eb-8a83-78d00426c726/-exit_code_node-1*.log
Initiating shutdown!
================================================================================
Going to exit due to code 37
[host/exit_code_node-1] killing on exit
shutting down processing monitor...
... shutting down processing monitor complete
roslaunch runner done
ending server mode 37
exiting from main() 37
root@remote:~# echo $?
37

@LukeAI
Copy link

LukeAI commented Feb 23, 2021

would love to see this in melodic. Is there something I can do to help get this merged?

… a regular parent launch process, child and remote processes need looking at.

May solve ros#919
@lucasw
Copy link
Contributor Author

lucasw commented Mar 21, 2021

Added a unit test, can run manually with

catkin run_tests
rostest test_roslaunch roslaunch.test

@lucasw lucasw requested a review from sloretz March 30, 2021 17:34
lucasw added a commit to lucasw/ros1_lifecycle that referenced this pull request May 8, 2021
Try running lifecycle_test.launch - fails but doesn't result in a non-zero exit code (see ros/ros_comm#2082).  Fix the test in a separate PR.
lucasw added a commit to lucasw/ros1_lifecycle that referenced this pull request May 8, 2021
Try running lifecycle_test.launch (after adding a needed node to it) - works but doesn't result in a non-zero exit code if it does fail (see ros/ros_comm#2082).  Turn it into a rostest in separate PR.
lucasw added a commit to lucasw/ros1_lifecycle that referenced this pull request May 9, 2021
Try running lifecycle_test.launch (after adding a needed node to it) - works but doesn't result in a non-zero exit code if it does fail (see ros/ros_comm#2082).  Turn it into a rostest in separate PR.
@lucasw
Copy link
Contributor Author

lucasw commented Sep 26, 2021

Can the requires-changes label be removed if there are no more changes needed?

Copy link
Contributor

@MichaelGrupp MichaelGrupp left a comment

Choose a reason for hiding this comment

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

I left some review comments from my side, because I would also like to get the correct exit code from roslaunch. But I'm not a maintainer.

@sloretz Can you please also check the PR again?

@@ -363,6 +368,8 @@ def main(argv=sys.argv):
try: os.unlink(options.pid_fn)
except os.error: pass

print('exiting from main() {}'.format(exit_code))
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a debug print that can be removed - people who are interested in the exit code of the executable can get this from the shell.

@@ -313,6 +314,8 @@ def main(argv=sys.argv):
sigint_timeout=options.sigint_timeout,
sigterm_timeout=options.sigterm_timeout)
c.run()
exit_code = c.exit_code
logger.warn('child node {} done {}'.format(options.child_name, exit_code))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this a warning? Looks more like a debug thing to me.

@@ -303,7 +304,7 @@ def main(argv=sys.argv):
logger.info("roslaunch env is %s"%os.environ)

if options.child_name:
logger.info('starting in child mode')
logger.info('starting in child mode {}'.format(options.child_name))
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't starting {} in child mode make more sense?

import sys
# import time
import unittest
# import yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

remove unnecessary imports

# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Revision $Id: test_roslaunch_command_line_online.py 6411 2009-10-02 21:32:01Z kwc $
Copy link
Contributor

Choose a reason for hiding this comment

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

this revision string looks like a copied thing that can be removed

#!/usr/bin/env python
# Software License Agreement (BSD License)
#
# Copyright (c) 2014, The Johns Hopkins University
Copy link
Contributor

Choose a reason for hiding this comment

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

The copyright notices look like they were pasted from somewhere else (2014 JHU, 2009 Willow) - do they make sense? I guess here the maintainers need to tell how this should be handled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like I copied it from test_roslaunch_ros_args.py.

Copyright (c) 2008, Willow Garage, Inc isn't true either, should it be Open Robotics 2021, or my name?

@@ -618,7 +619,7 @@ def spin(self):
#self.pm.join()
self.logger.info("process monitor is done spinning, initiating full shutdown")
self.stop()
printlog_bold("done")
printlog_bold("roslaunch runner done")
Copy link
Contributor

Choose a reason for hiding this comment

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

I would leave this as it is, it's unrelated to the feature.

@@ -566,6 +567,10 @@ def _run(self):
if p.required:
printerrlog('='*80+"REQUIRED process [%s] has died!\n%s\nInitiating shutdown!\n"%(p.name, exit_code_str)+'='*80)
self.is_shutdown = True
if p.exit_code != 0:
msg = 'Going to exit due to code {}'.format(p.exit_code)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should also include the p.name of the dead process:

msg = 'Going to exit due to non-zero exit code ({}) of required process {}'.format(p.exit_code, p.name)

@@ -346,6 +349,8 @@ def main(argv=sys.argv):
sigterm_timeout=options.sigterm_timeout)
p.start()
p.spin()
exit_code = p.exit_code
print('ending server mode {}'.format(exit_code))
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here, is this print needed?

lucasw added a commit to lucasw/ros1_lifecycle that referenced this pull request Dec 6, 2021
Try running lifecycle_test.launch (after adding a needed node to it) - works but doesn't result in a non-zero exit code if it does fail (see ros/ros_comm#2082).  Turn it into a rostest in separate PR.
rhaschke pushed a commit to ubi-agni/ros_comm that referenced this pull request Aug 20, 2024
rhaschke pushed a commit to ros-o/ros_comm that referenced this pull request Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants