From: Nizamudeen A Date: Thu, 26 Jun 2025 07:25:22 +0000 (+0530) Subject: mgr/dashboard: catch protobuf error due to mismatch in version X-Git-Tag: v20.1.0~127^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F64295%2Fhead;p=ceph.git mgr/dashboard: catch protobuf error due to mismatch in version Signed-off-by: Nizamudeen A --- diff --git a/src/pybind/mgr/dashboard/services/nvmeof_client.py b/src/pybind/mgr/dashboard/services/nvmeof_client.py index b461755948df..46ff2493927b 100644 --- a/src/pybind/mgr/dashboard/services/nvmeof_client.py +++ b/src/pybind/mgr/dashboard/services/nvmeof_client.py @@ -1,3 +1,5 @@ +# pylint: disable=unexpected-keyword-arg + import functools import logging from typing import Any, Callable, Dict, Generator, List, NamedTuple, Optional, Type @@ -8,6 +10,14 @@ from .nvmeof_conf import NvmeofGatewaysConfig logger = logging.getLogger("nvmeof_client") try: + # if the protobuf version is newer than what we generated with + # proto file import will fail (because of differences between what's + # available in centos and ubuntu). + # this "hack" should be removed once we update both the + # distros; centos and ubuntu. + import os + os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python" + import grpc # type: ignore import grpc._channel # type: ignore from google.protobuf.json_format import MessageToDict # type: ignore @@ -220,7 +230,7 @@ else: def wrapper(*args, **kwargs) -> Model: message = func(*args, **kwargs) msg_dict = MessageToDict(message, including_default_value_fields=True, - preserving_proto_field_name=True) + preserving_proto_field_name=True) # type: ignore result = namedtuple_to_dict(obj_to_namedtuple(msg_dict, model)) if finalize: