Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
feat(proto): add vcs version to pb
  • Loading branch information
hanhxiao committed Sep 26, 2019
1 parent 285d9dd commit 086a73cb0adf1042d5e0de0058a3715ff26e305a
Showing with 58 additions and 36 deletions.
  1. +13 −0 gnes/proto/__init__.py
  2. +2 −0 gnes/proto/gnes.proto
  3. +43 −36 gnes/proto/gnes_pb2.py
@@ -14,6 +14,7 @@
# limitations under the License.

import ctypes
import os
import random
from typing import List, Iterator, Tuple
from typing import Optional
@@ -119,6 +120,7 @@ def add_version(evlp: 'gnes_pb2.Envelope'):
from .. import __version__, __proto_version__
evlp.gnes_version = __version__
evlp.proto_version = __proto_version__
evlp.vcs_version = os.environ.get('GNES_VCS_VERSION', '')


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

if hasattr(msg.envelope, 'vcs_version'):
if not msg.envelope.vcs_version or not os.environ.get('GNES_VCS_VERSION', ''):
default_logger.warning('incoming message contains empty "vcs_version", '
'you may ignore it in debug/unittest mode, '
'or if you run gnes OUTSIDE docker container where GNES_VCS_VERSION is unset'
'otherwise please check if frontend service set correct version')
elif os.environ.get('GNES_VCS_VERSION') != msg.envelope.vcs_version:
raise AttributeError('mismatched vcs version! '
'incoming message has protobuf version %s, whereas local protobuf version %s' % (
msg.envelope.vcs_version, os.environ.get('GNES_VCS_VERSION')))

if not hasattr(msg.envelope, 'proto_version') and not hasattr(msg.envelope, 'gnes_version'):
raise AttributeError('version_check=True locally, '
'but incoming message contains no version info in its envelope. '
@@ -100,6 +100,8 @@ message Envelope {
string gnes_version = 7;

string proto_version = 8;

string vcs_version = 9;
}

message Message {

Some generated files are not rendered by default. Learn more.

0 comments on commit 086a73c

Please sign in to comment.