]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: catch protobuf error due to mismatch in version 64295/head
authorNizamudeen A <nia@redhat.com>
Thu, 26 Jun 2025 07:25:22 +0000 (12:55 +0530)
committerNizamudeen A <nia@redhat.com>
Thu, 3 Jul 2025 11:01:25 +0000 (16:31 +0530)
Signed-off-by: Nizamudeen A <nia@redhat.com>
src/pybind/mgr/dashboard/services/nvmeof_client.py

index b461755948dfe82245142be1de325ace75816b0d..46ff2493927b3aaf2aa7a13cc516893296398059 100644 (file)
@@ -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: