Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.

Commit 086a73c

Browse files
author
hanhxiao
committed
feat(proto): add vcs version to pb
1 parent 285d9dd commit 086a73c

File tree

3 files changed

+58
-36
lines changed

3 files changed

+58
-36
lines changed

gnes/proto/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515

1616
import ctypes
17+
import os
1718
import random
1819
from typing import List, Iterator, Tuple
1920
from typing import Optional
@@ -119,6 +120,7 @@ def add_version(evlp: 'gnes_pb2.Envelope'):
119120
from .. import __version__, __proto_version__
120121
evlp.gnes_version = __version__
121122
evlp.proto_version = __proto_version__
123+
evlp.vcs_version = os.environ.get('GNES_VCS_VERSION', '')
122124

123125

124126
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'):
152154
'incoming message has protobuf version %s, whereas local protobuf version %s' % (
153155
msg.envelope.proto_version, __proto_version__))
154156

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+
155168
if not hasattr(msg.envelope, 'proto_version') and not hasattr(msg.envelope, 'gnes_version'):
156169
raise AttributeError('version_check=True locally, '
157170
'but incoming message contains no version info in its envelope. '

gnes/proto/gnes.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ message Envelope {
100100
string gnes_version = 7;
101101

102102
string proto_version = 8;
103+
104+
string vcs_version = 9;
103105
}
104106

105107
message Message {

gnes/proto/gnes_pb2.py

Lines changed: 43 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)