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

Commit

Permalink
feat(proto): add vcs version to pb
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Sep 26, 2019
1 parent 285d9dd commit 086a73c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 36 deletions.
13 changes: 13 additions & 0 deletions gnes/proto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.

import ctypes
import os
import random
from typing import List, Iterator, Tuple
from typing import Optional
Expand Down Expand Up @@ -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']):
Expand Down Expand Up @@ -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. '
Expand Down
2 changes: 2 additions & 0 deletions gnes/proto/gnes.proto
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ message Envelope {
string gnes_version = 7;

string proto_version = 8;

string vcs_version = 9;
}

message Message {
Expand Down
79 changes: 43 additions & 36 deletions gnes/proto/gnes_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 086a73c

Please sign in to comment.