[SEBA-494] Better handling of version numbers
Change-Id: If3a7d9c6e34dc8a9a077144d5a3eb9e6b0630460
diff --git a/VERSION b/VERSION
index ccbccc3..c043eea 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.0
+2.2.1
diff --git a/containers/chameleon/Dockerfile.chameleon b/containers/chameleon/Dockerfile.chameleon
index 6e326dc..83df7fd 100644
--- a/containers/chameleon/Dockerfile.chameleon
+++ b/containers/chameleon/Dockerfile.chameleon
@@ -14,7 +14,7 @@
# xosproject/chameleon
-FROM xosproject/xos-base:2.2.0
+FROM xosproject/xos-base:2.2.1
# xos-base already has protoc and dependencies installed
diff --git a/containers/xos/Dockerfile.client b/containers/xos/Dockerfile.client
index 083d01a..8208ec9 100644
--- a/containers/xos/Dockerfile.client
+++ b/containers/xos/Dockerfile.client
@@ -14,7 +14,7 @@
# xosproject/xos-client
-FROM xosproject/xos-libraries:2.2.0
+FROM xosproject/xos-libraries:2.2.1
# Install XOS client
COPY lib/xos-api /tmp/xos-api
diff --git a/containers/xos/Dockerfile.libraries b/containers/xos/Dockerfile.libraries
index 4171077..5a211fa 100644
--- a/containers/xos/Dockerfile.libraries
+++ b/containers/xos/Dockerfile.libraries
@@ -14,7 +14,7 @@
# xosproject/xos-libraries
-FROM xosproject/xos-base:2.2.0
+FROM xosproject/xos-base:2.2.1
# Add libraries
COPY lib /opt/xos/lib
diff --git a/containers/xos/Dockerfile.synchronizer-base b/containers/xos/Dockerfile.synchronizer-base
index 0110aca..ec745c4 100644
--- a/containers/xos/Dockerfile.synchronizer-base
+++ b/containers/xos/Dockerfile.synchronizer-base
@@ -14,7 +14,7 @@
# xosproject/xos-synchronizer-base
-FROM xosproject/xos-client:2.2.0
+FROM xosproject/xos-client:2.2.1
COPY xos/synchronizers/new_base /opt/xos/synchronizers/new_base
COPY xos/xos/logger.py /opt/xos/xos/logger.py
diff --git a/containers/xos/Dockerfile.xos-core b/containers/xos/Dockerfile.xos-core
index 6d024b9..802373b 100644
--- a/containers/xos/Dockerfile.xos-core
+++ b/containers/xos/Dockerfile.xos-core
@@ -14,7 +14,7 @@
# xosproject/xos-core
-FROM xosproject/xos-libraries:2.2.0
+FROM xosproject/xos-libraries:2.2.1
# Install XOS
ADD xos /opt/xos
diff --git a/xos/coreapi/xos_dynamicload_api.py b/xos/coreapi/xos_dynamicload_api.py
index 8a44581..fd46056 100644
--- a/xos/coreapi/xos_dynamicload_api.py
+++ b/xos/coreapi/xos_dynamicload_api.py
@@ -59,21 +59,6 @@
django_models[k] = v
self.django_app_models[app.name] = django_models
- def match_major_version(self, current, expected):
- """
- Returns true if the major version is the same
- :param current: semver string for the current version
- :param expected: semver string for the expected version
- :return: bool
- """
- current_parts = semver.parse(current)
- expected = re.sub("[><=!]", "", expected)
- expected_parts = semver.parse(expected)
- match = current_parts["major"] == expected_parts["major"]
- log.debug("Verifying major version",
- expected_major=expected_parts["major"], current_major=current_parts["major"], match=match)
- return match
-
@track_request_time("DynamicLoad", "LoadModels")
def LoadModels(self, request, context):
try:
@@ -87,28 +72,41 @@
)
if not requested_core_version:
- requested_core_version = "<3.0.0"
+ requested_core_version = ">=2.2.1"
- match_version = semver.match(core_version, requested_core_version)
- match_major = self.match_major_version(core_version, requested_core_version)
- if not match_version:
- log.error("Not loading service because of mismatching versions", service=request.name,
- core_version=core_version, requested_core_version=requested_core_version)
- context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
- msg = "Service %s is requesting core version %s but actual version is %s" % (
- request.name, requested_core_version, core_version)
- context.set_details(msg)
- raise Exception(msg)
- if not match_major:
- log.error("Not loading service because of mismatching major versions", service=request.name,
- core_version=core_version, requested_core_version=requested_core_version)
- context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
- msg = "Service %s is requesting core version %s but actual version is %s, major version is different" % (
+ if "~" in requested_core_version:
+ [min_requested, max_requested] = requested_core_version.split("~")
+
+ match_min_version = semver.match(core_version, min_requested.strip())
+ match_max_version = semver.match(core_version, max_requested.strip())
+
+ if not match_min_version or not match_max_version:
+ log.error("Not loading service because of mismatching versions",
+ service=request.name,
+ core_version=core_version,
+ requested_min_core_version=min_requested,
+ requested_max_core_version=max_requested
+ )
+ context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
+ msg = "Service %s is requesting core version between %s and %s but actual version is %s" % (
+ request.name,
+ min_requested,
+ max_requested,
+ core_version
+ )
+ context.set_details(msg)
+ raise Exception(msg)
+
+ else:
+ match_version = semver.match(core_version, requested_core_version.strip())
+ if not match_version:
+ log.error("Not loading service because of mismatching versions", service=request.name,
+ core_version=core_version, requested_core_version=requested_core_version)
+ context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
+ msg = "Service %s is requesting core version %s but actual version is %s" % (
request.name, requested_core_version, core_version)
- context.set_details(msg)
- raise Exception(msg)
- context.set_details(msg)
- raise Exception(msg)
+ context.set_details(msg)
+ raise Exception(msg)
builder = DynamicBuilder()
result = builder.handle_loadmodels_request(request)