-
Notifications
You must be signed in to change notification settings - Fork 248
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
Gracefully handle CTRL+C and CTR+Break events on Windows #1342
base: rolling
Are you sure you want to change the base?
Gracefully handle CTRL+C and CTR+Break events on Windows #1342
Conversation
2399f9a
to
28c7bb2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is something that we should put into rclcpp
rather than here. That is, it seems to me that all ROS 2 binaries would benefit from this kind of fix.
@MichaelOrlov @mjcarroll what do you think?
I think it makes sense to put a version of this in ROS 2, but I think @MichaelOrlov wants to get this fix in for Iron's version of rosbag2, so it seems reasonable to do it here as well for now. Maybe in the longer term if we get something landed in rolling, he can deprecate it here to reduce redundancy? |
@clalancette, I agree with @mjcarroll and yes I would like to keep it in rosbag2 to be able to backport it to the iron branch. And will get rid of redundancy when it will be available in the |
@MichaelOrlov would you be willing to make the patch to add the helpers to |
@emersonknapp Yes. I can try to make the changes in |
28c7bb2
to
c30a2d7
Compare
c30a2d7
to
abff40d
Compare
|
Gist: https://gist.githubusercontent.com/MichaelOrlov/55adb4c4d5dac5435adace5c095d45b2/raw/09cc03757951ddc3c5ec8885a4d766a84f26207f/ros2.repos |
Returning back to draft due to some unexpected test failures on CI which are not reproduced locally and need to be investigated. |
428da78
to
b9f8031
Compare
Re-run CI after rebase and adjusting expectations in flaky ros2bag record tests |
It seems that CI failure on windows in rosbag2_tests.TestPlayEndToEnd/PlayEndToEndTestFixture. relates to the way how we are running tests on Windows CI.
The error code is very weird and I can't reproduce this failure on my local Windows + ROS2 Rolling setup.
It seems this issue has been fixed on the |
Hi @claraberendsen, The tests which are failing on the CI are passes on my local Windows setup without docker container. It seems someone needs to contact Microsoft Support for this issue. Since I have no more ideas on how to fix this issue. |
@MichaelOrlov Thanks for pinging me I'm going to take a look at this and see what I find and if needed be forward it. |
@MichaelOrlov I can confirm that we are using the new WS2022 image. In the logs of the build you referenced above you can see the change on the url for the windows image to point to |
@claraberendsen As regards
I know. I have seen it from logs. The problem is that issue reproduces even on the new WS2022 image.
|
@MichaelOrlov We do not currently have the bandwidth to investigate this further. I see you pointed that in your local machine you are not seeing this error only when running the CI because we utilize docker. I don't have clarity that the issue comes from using docker or the docker image of our setup. To verify that the issue comes from it being ran inside docker further testing should be conducted by running this on a WS2019 image and a WS2022 image. I'm pinging @clalancette to see if he can help unblock this. |
@claraberendsen I don't see a rationale in trying to run the test on the different WS2019 and a WS2022 images under the docker. |
I don't have any particular knowledge about what is going on with Windows. Maybe @ooeygui can help get us in touch with the right people? |
@clalancette I'm looking into it. |
Thank you, much appreciated! |
@ooeygui Friendly ping. Any thoughts here? |
@clalancette I've been trying to track this down internally - it looks like there was a fix, but it was backed out due to compatibility issues. I am trying to find an alternative method, but there does not appear to be a supported graceful solution. |
@clalancette I found the owner of the API. It looks like my statement about a reverted fix was incorrect, that this should work. I'm working on a small repro to root cause. |
Both the owner of the Windows API and I have been attempting to reproduce this, but haven't been able to. |
@ooeygui Originally this issue was not reproducible on my local setup. But as you can see CI jobs fail. |
Thanks @MichaelOrlov. @clalancette Do you know where I can find the windows container spec? I'd like to try building it locally. |
Our Windows containers are currently running on Windows Server 2022 hosts running in AWS EC2. We're using the Docker engine for Windows in the non-virtualized mode so we can take advantage of shared mounts between the container and host system (this forces our containers and the host Windows version to be the same, unlike the virtualized container engine which does not support shared filesystem mounts between host and container) on ci.ros2.org you can see our dockerfile template here: https://github.com/ros2/ci/blob/master/windows_docker_resources/Dockerfile and you can inspect the logs to see the build arguments that a given job is run with. Within the container most of the heavy lifting for setup and configuration is managed by this chef cookbook https://github.com/ros-infrastructure/ros2-cookbooks/tree/latest/cookbooks/ros2_windows |
0bcf904
to
250c228
Compare
@ooeygui @nuclearsandwich-ai Any updates on this issue? cc: @clalancette |
Hi @MichaelOrlov, In a future version of Windows, the API has been refactored so it should not exhibit this problem, but this depends on migrating the host and clients CI to a more current version of Windows. I'd recommend disabling the test on Windows until this migration takes place. |
@ooeygui Do we have an issue to track when the migration of the host and clients CI to a more current version of Windows is going to happen? I need to refer to something in the code when will be disabling tests for Windows. BTW can we disable tests for CI and keep them running by default for the local setup? |
@ooeygui @nuclearsandwich-ai @clalancette May I have an issue number to track when the migration of the host and clients CI to a more current version of Windows is going to happen? As from discussion above ^^^. If we will not have a follow-up issue for infrastructure - the fix will never happen. Also please note that disabling tests will defeat the purpose and fixes in this PR. |
- Add handler for the native Windows CTRL_C_EVENT, CTRL_BREAK_EVENT and CTRL_CLOSE_EVENT in rosbag2 recorder and player. - Map SIGINT signal to the native Windows CTRL_C_EVENT in the stop_execution(handle, signum) version for Windows. To be able correctly use start and stop execution routines from unit tests. - Enable integration tests which was disabled for Windows due to the incorrect sending and handling of the SIGINT event. - Got rid of the `finalize_metadata_kludge(..)` helper function. Signed-off-by: Michael Orlov <[email protected]>
Signed-off-by: Michael Orlov <[email protected]>
- Replace waiting for the `/rosout` topic on waiting for the rosbag2 internal `/events/write_split`. Rationale: The `/rosout` topic may not be enabled on the CI. - Replace expectation for the `Listening for topics...` on `Recording...` which is appearing at the very end of the Recorder::record(). Rationale: It was possible a race condition when test was sending the SIGINT while we haven't yet finished call for Recorder::record(). Signed-off-by: Michael Orlov <[email protected]>
Signed-off-by: Michael Orlov <[email protected]>
250c228
to
cb7b410
Compare
@MichaelOrlov @ooeygui do we know from what version this should be resolved? I cannot assess or give timing of a potential migration without this information. |
@claraberendsen I don't know. It seems only @ooeygui knows. |
Add handler for the native Windows
CTRL_C_EVENT
,CTRL_BREAK_EVENT
andCTRL_CLOSE_EVENT
in rosbag2 recorder and player.Map SIGINT signal to the native Windows
CTRL_C_EVENT
in thestop_execution(handle, signum)
version for Windows to be able correctly use start and stop execution routines from unit tests.Uses
CREATE_NEW_PROCESS_GROUP
when creating new process in process execution helper functions to be able to properly send native WindowsCTRL_C_EVENT
to the newly spawned child process.Creates new process suspended and resumes it after adding to the newly created job. To avoid a potential race condition where a newly created process starts a subprocess before we've called
AssignProcessToJobObject();
Enable integration tests that were disabled for Windows due to the incorrect sending and handling of the SIGINT event.
Got rid of the
finalize_metadata_kludge(..)
helper function.Depends from Gracefully handle SIGINT and SIGTERM in rosbag2 recorder #1301Relates
.db3
file access error in windows CI #927Closes Windows CI can't find
metadata.yaml
file when usingros2 bag record
#926Closes Windows Signal Handling #1326
Closes Consistently failing test in nightly_win_xfail: rosbag2_tests.TestRecordEndToEnd/RecordFixture #1270
Note:
According to the https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/signal?view=msvc-170
The
CTRL_CLOSE_EVENT
is an analog of theSIGTERM
from POSIX. Windows sendsCTRL_CLOSE_EVENT
to all processes attached to a console when the user closes the console (either by clicking Close on the console window's window menu, or by clicking the End Task button command from Task Manager).
Although according to the https://learn.microsoft.com/en-us/windows/console/generateconsolectrlevent the
GenerateConsoleCtrlEvent(..)
doesn't support sendingCTRL_CLOSE_EVENT
. There is no way to directly sendCTRL_CLOSE_EVENT
to the process in the same console application.Therefore, added
SIGTERM
to the unsupported events in thestop_execution(process_handle, signum)
API.