Closed kevinbird61 closed 6 years ago
I think @bocon13 's diagnosis is correct: https://github.com/p4lang/tutorials/issues/109#issuecomment-353023274 Make sure that you have the grpc python plugin installed before configuring, building & installing PI (follow instructions in the grpc repo). You can look at the build logs for PI and check that the python modules for P4Runtime are generated by protoc. Here is what I have in my build logs:
/usr/local/bin/protoc /home/antonin/Documents/p4lang/PI/proto/p4/p4runtime.proto /home/antonin/Documents/p4lang/PI/proto/p4/config/p4info.proto /home/antonin/Documents/p4lang/PI/proto/google/rpc/status.proto /home/antonin/Documents/p4lang/PI/proto/google/rpc/code.proto /home/antonin/Documents/p4lang/PI/proto/p4/tmp/p4config.proto /home/antonin/Documents/p4lang/PI/proto/gnmi/gnmi.proto --python_out ./py_out -I/home/antonin/Documents/p4lang/PI/proto -I/home/antonin/Documents/p4lang/PI/proto --grpc_out ./py_out --plugin=protoc-gen-grpc=/usr/local/bin/grpc_python_plugin
@antoninbas thanks for your reply.
But after checking grpc python plugin installed (e.g. /usr/local/bin/grpc_python_plugin
) and configuring, building & installing PI, the controller python script still cannot work.
I compare with the comment in same issue #109 (comment) , and my p4runtime_pb2 dependencies look fine:
$ locate p4runtime_pb
/home/kevin/tools/PI/proto/py_out/p4/p4runtime_pb2.py
/home/kevin/tools/PI/proto/py_out/p4/p4runtime_pb2_grpc.py
/home/kevin/tools/p4c/build/control-plane/p4/p4runtime_pb2.py
/usr/local/lib/python2.7/dist-packages/p4/p4runtime_pb2.py
/usr/local/lib/python2.7/dist-packages/p4/p4runtime_pb2.pyc
/usr/local/lib/python2.7/dist-packages/p4/p4runtime_pb2.pyo
And some information @antoninbas you mentioned in your build logs , about the source generated by protoc, I checked each one and list out down below:
my protoc
/usr/local/bin/protoc
p4runtime.proto
/home/kevin/tools/PI/proto/p4/p4runtime.proto
/home/kevin/tools/p4c/control-plane/PI/proto/p4/p4runtime.proto
p4info.proto
/home/kevin/tools/PI/proto/p4/config/p4info.proto
/home/kevin/tools/p4c/control-plane/PI/proto/p4/config/p4info.proto
status.proto
/home/kevin/tools/PI/proto/googleapis/google/rpc/status.proto
/home/kevin/tools/grpc/src/proto/grpc/status/status.proto
/home/kevin/tools/p4c/control-plane/PI/proto/googleapis/google/rpc/status.proto
code.proto
/home/kevin/tools/PI/proto/googleapis/google/rpc/code.proto
/home/kevin/tools/grpc/third_party/protobuf/ruby/compatibility_tests/v3.0.0/tests/generated_code.proto
/home/kevin/tools/grpc/third_party/protobuf/ruby/tests/generated_code.proto
/home/kevin/tools/grpc/third_party/protobuf/src/google/protobuf/compiler/ruby/ruby_generated_code.proto
/home/kevin/tools/p4c/control-plane/PI/proto/googleapis/google/rpc/code.proto
p4config.proto
/home/kevin/tools/PI/proto/p4/tmp/p4config.proto
/home/kevin/tools/p4c/control-plane/PI/proto/p4/tmp/p4config.proto
gnmi.proto
/home/kevin/tools/PI/proto/openconfig/gnmi/proto/gnmi/gnmi.proto
/home/kevin/tools/p4c/control-plane/PI/proto/openconfig/reference/rpc/gnmi/gnmi.proto
Thanks.
I have done some research and I've been able to confirm that this is because you are using a more recent version of grpc than we support. grpc stubs are no longer included in p4runtime_pb2.py
and you have to use p4runtime_pb2_grpc.py
with recent versions of grpc.
If you want to keep using your version of grpc you will need to:
1) Modify this p4lang/PI makefile to install *_grpc.py
files: https://github.com/p4lang/PI/blob/master/proto/Makefile.am#L98
2) Modify the relevant Python files in this repo - tutorials - to use p4runtime_pb2_grpc.py
instead of p4runtime_pb2.py
when appropriate (i.e. for grpc stubs).
@antoninbas Thanks for your reply.
After edit Makefile.am
, add the *_grpc.py
like:
if HAVE_GRPC_PY_PLUGIN
p4pydir = $(pythondir)/p4
nodist_p4py_PYTHON = \
py_out/p4/p4runtime_pb2.py \
py_out/p4/p4runtime_pb2_grpc.py \
py_out/p4/__init__.py
p4configpydir = $(pythondir)/p4/config
nodist_p4configpy_PYTHON = \
py_out/p4/config/p4info_pb2.py \
py_out/p4/config/p4info_pb2_grpc.py \
py_out/p4/config/__init__.py
# this one is temporary
p4tmppydir = $(pythondir)/p4/tmp
nodist_p4tmppy_PYTHON = \
py_out/p4/tmp/p4config_pb2.py \
py_out/p4/tmp/p4config_pb2_grpc.py \
py_out/p4/tmp/__init__.py
And edit the controller python scripts under tutorial repository:
In switch.py
: import p4runtime_pb_grpc
...
from p4 import p4runtime_pb2_grpc as p4runtime_pb2
In helper.py
...
from p4 import p4runtime_pb2_grpc as p4runtime_pb2
And get this error message instead:
Traceback (most recent call last):
File "./mycontroller.py", line 202, in <module>
main(args.p4info, args.bmv2_json)
File "./mycontroller.py", line 152, in main
bmv2_json_file_path=bmv2_file_path)
File "/home/kevin/workspace/tutorials/P4D2_2017_Fall/exercises/p4runtime/p4runtime_lib/switch.py", line 38, in SetForwardingPipelineConfig
request = p4runtime_pb2.SetForwardingPipelineConfigRequest()
AttributeError: 'module' object has no attribute 'SetForwardingPipelineConfigRequest'
Error message about P4RuntimeStub seems to be solved, but another error "SetForwardingPipelineConfigRequest"
shown
So I trace the p4runtime_pb2.py
between current built and the other one in VM.
Therefore I found some differences, then go check the p4runtime.proto
between these 2 version. I found the attributes had been changed !
As we can see the older one (which used in VM):
message SetForwardingPipelineConfigRequest {
enum Action { ... }
Uint128 election_id = 1;
repeated ForwardingPipelineConfig configs = 2;
Action action = 3;
}
...
message ForwardingPipelineConfig {
uint64 device_id = 1;
config.P4Info p4info = 2;
bytes p4_device_config = 3;
}
And the current built:
message SetForwardingPipelineConfigRequest {
enum Action {...}
uint64 device_id = 1;
uint64 role_id = 2;
Uint128 election_id = 3;
Action action = 4;
ForwardingPipelineConfig config = 5;
}
...
message ForwardingPipelineConfig {
config.P4Info p4info = 1;
// Target-specific P4 configuration.
bytes p4_device_config = 2;
}
Which you can see the mycontroller.py
behavior match the older one !
So I think there are need an effort to revise the dependencies of mycontroller.py
to run up this exercise with latest version of PI.
This is a known issue that I already brought up in one of your previous questions...: https://github.com/p4lang/tutorials/issues/113#issuecomment-362724194
I'm personally reluctant to update the code since it would also require making sure that the dependencies are updated in the VM. If someone was using the VM from the tutorial and they pulled the latest version of this repo, they would also need to update the dependencies (bmv2, p4c) themselves. It may be better to just "freeze" the SIGCOMM tutorial and require people interested in the tutorial to use the provided VM. The key principles illustrated in the tutorial remain valid. There are other tutorials coming up in 2018 and these will use the most recent versions of the p4lang software.
@antoninbas Got it ! Thanks for your reply!
Here is the error message when I was running the exercise in P4D2_2017_Fall/exercises/p4runtime:
Also I have seen the similar issue here with the same problem, but the discussion about this issue end with the solution with using the provided virtual machine. Although there have a solution, but I still want to solve this problem to build P4 environment on my computer.
Here is the solving method I've tried:
grpc
,protobuf
to recommended version( grpc-> v1.3.2, protobuf -> v3.2.0 ), and then recompile and installPI
repository with suggestions hereBut the problem remain the same.
Does there have any suggestions about my solving method or this problem ?
Thanks.