|
14 | 14 | # limitations under the License.
|
15 | 15 |
|
16 | 16 | import ctypes
|
| 17 | +import os |
17 | 18 | import random
|
18 | 19 | from typing import List, Iterator, Tuple
|
19 | 20 | from typing import Optional
|
@@ -119,6 +120,7 @@ def add_version(evlp: 'gnes_pb2.Envelope'):
|
119 | 120 | from .. import __version__, __proto_version__
|
120 | 121 | evlp.gnes_version = __version__
|
121 | 122 | evlp.proto_version = __proto_version__
|
| 123 | + evlp.vcs_version = os.environ.get('GNES_VCS_VERSION', '') |
122 | 124 |
|
123 | 125 |
|
124 | 126 | def merge_routes(msg: 'gnes_pb2.Message', prev_msgs: List['gnes_pb2.Message']):
|
@@ -152,6 +154,17 @@ def check_msg_version(msg: 'gnes_pb2.Message'):
|
152 | 154 | 'incoming message has protobuf version %s, whereas local protobuf version %s' % (
|
153 | 155 | msg.envelope.proto_version, __proto_version__))
|
154 | 156 |
|
| 157 | + if hasattr(msg.envelope, 'vcs_version'): |
| 158 | + if not msg.envelope.vcs_version or not os.environ.get('GNES_VCS_VERSION', ''): |
| 159 | + default_logger.warning('incoming message contains empty "vcs_version", ' |
| 160 | + 'you may ignore it in debug/unittest mode, ' |
| 161 | + 'or if you run gnes OUTSIDE docker container where GNES_VCS_VERSION is unset' |
| 162 | + 'otherwise please check if frontend service set correct version') |
| 163 | + elif os.environ.get('GNES_VCS_VERSION') != msg.envelope.vcs_version: |
| 164 | + raise AttributeError('mismatched vcs version! ' |
| 165 | + 'incoming message has protobuf version %s, whereas local protobuf version %s' % ( |
| 166 | + msg.envelope.vcs_version, os.environ.get('GNES_VCS_VERSION'))) |
| 167 | + |
155 | 168 | if not hasattr(msg.envelope, 'proto_version') and not hasattr(msg.envelope, 'gnes_version'):
|
156 | 169 | raise AttributeError('version_check=True locally, '
|
157 | 170 | 'but incoming message contains no version info in its envelope. '
|
|
0 commit comments