Fixing kubernetes version check (some versions return strings instead of ints)
Change-Id: Ieb897a207d3d37954867e1b624c37743f7eb3ec1
diff --git a/xos/synchronizer/steps/sync_kubernetes_service.py b/xos/synchronizer/steps/sync_kubernetes_service.py
index 5138c6c..0b929ee 100644
--- a/xos/synchronizer/steps/sync_kubernetes_service.py
+++ b/xos/synchronizer/steps/sync_kubernetes_service.py
@@ -45,10 +45,11 @@
res = self.api_instance.get_code()
major = res.major
minor = res.minor
+ log.debug("[K8Service SyncStep] API response", res=res)
log.info("[K8Service SyncStep] API Code", major=major, minor=minor,
expected_major=self.expected_major, expected_minor=self.expected_minor)
- if major != int(self.expected_major) or minor > int(self.expected_minor):
+ if int(major) != int(self.expected_major) or int(minor) > int(self.expected_minor):
raise Exception("Kubernetes cluster of version %s is not supported by the kubernetes-services" % res.git_version+
"the maximum supported version is %s" % self.max_version)
diff --git a/xos/synchronizer/tests/test_sync_kubernetesservice.py b/xos/synchronizer/tests/test_sync_kubernetesservice.py
index 75a79cc..75632cd 100644
--- a/xos/synchronizer/tests/test_sync_kubernetesservice.py
+++ b/xos/synchronizer/tests/test_sync_kubernetesservice.py
@@ -52,6 +52,20 @@
def test_valid_version(self):
version = MagicMock()
+ version.major = '1'
+ version.minor = '13'
+ version.git_version = "v1.13.0"
+
+ with patch.object(self.step_class, "init_kubernetes_client", new=fake_init_kubernetes_client):
+ step = self.step_class(model_accessor=self.model_accessor)
+
+ step.api_instance.get_code.return_value = version
+
+ step.sync_record(self.service)
+
+ def test_valid_version_int(self):
+
+ version = MagicMock()
version.major = 1
version.minor = 13
version.git_version = "v1.13.0"