Skip to content

Commit acb0f19

Browse files
committed
mgr/dashboard: catch protobuf error due to mismatch in version
Signed-off-by: Nizamudeen A <[email protected]>
1 parent 84922d1 commit acb0f19

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/pybind/mgr/dashboard/services/nvmeof_client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# pylint: disable=unexpected-keyword-arg
2+
13
import functools
24
import logging
35
from typing import Annotated, Any, Callable, Dict, Generator, List, \
@@ -9,6 +11,14 @@
911
logger = logging.getLogger("nvmeof_client")
1012

1113
try:
14+
# if the protobuf version is newer than what we generated with
15+
# proto file import will fail (because of differences between what's
16+
# available in centos and ubuntu).
17+
# this "hack" should be removed once we update both the
18+
# distros; centos and ubuntu.
19+
import os
20+
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
21+
1222
import grpc # type: ignore
1323
import grpc._channel # type: ignore
1424
from google.protobuf.json_format import MessageToDict # type: ignore
@@ -223,7 +233,7 @@ def decorator(func: Callable[..., Message]) -> Callable[..., Model]:
223233
def wrapper(*args, **kwargs) -> Model:
224234
message = func(*args, **kwargs)
225235
msg_dict = MessageToDict(message, including_default_value_fields=True,
226-
preserving_proto_field_name=True)
236+
preserving_proto_field_name=True) # type: ignore
227237

228238
result = namedtuple_to_dict(obj_to_namedtuple(msg_dict, model))
229239
if finalize:

0 commit comments

Comments
 (0)