p4lang / p4app

Apache License 2.0
112 stars 58 forks source link

Switch error logs destroyed upon simple-switch-grpc failure, due to sys.exit #65

Closed chenxiaoqino closed 5 years ago

chenxiaoqino commented 5 years ago

For p4app version rc-2.0.0

When I ran a weird P4 program causing some trouble for BMV2 switch, the p4app runner only reports that the switch failed to start, and I cannot debug the error. If I understand correctly, the BMV2 switch's error log reside in the /tmp/p4s.{}.log file inside the docker container, and is destroyed upon exit. All I got is:

$ ./p4app run xxx.p4app
> python /p4app/main.py
*** Error setting resource limits. Mininet's performance may be affected.
P4 switch s1 did not start correctly.
$ docker ps
(empty)

The exit is caused by the check_switch_started check, however even if I manually adjust all the exit calls within p4_mininet.py in my local p4app repo (to not exit upon check failure), the container still gets destroyed immediately. I guess it's because there's another copy of the same p4app code that actually gets run within the container.

It will provide great convenience for debugging anomalies by not calling sys.exit directly, even if just by throwing an exception (so it's possible to catch the exception and pause for debugging). Right now, I cannot easily pause after failure by writing anything in the main.py file.

chenxiaoqino commented 5 years ago

Nevermind, I realized the log is already synchronized to the host machine's /tmp.