summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs
diff options
context:
space:
mode:
authorvamahaja <vamahaja@redhat.com>2019-08-27 19:19:28 +0530
committervponomar <vponomar@redhat.com>2019-08-28 12:25:49 +0000
commit5f47f0017922a2b3055779c502e0e3a879f48fed (patch)
treee9cfa11e671a0951fafcb5b77563397cdfae6312 /openshift-storage-libs
parentffef7f14ef5c6d88ca8d68f9ab7b0a2319faef12 (diff)
Fix "openshift_storage_version" to get valid version for OCS 3.10 & 3.9
Change-Id: Ia0325c4309837fe3f89eab3c066775f9fb1ab1de Signed-off-by: vamahaja <vamahaja@redhat.com>
Diffstat (limited to 'openshift-storage-libs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_storage_version.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_storage_version.py b/openshift-storage-libs/openshiftstoragelibs/openshift_storage_version.py
index 5b0f7e3..e798e8b 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_storage_version.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_storage_version.py
@@ -29,10 +29,11 @@ from glusto.core import Glusto as g
import six
from openshiftstoragelibs import command
+from openshiftstoragelibs import exceptions
OPENSHIFT_STORAGE_VERSION_RE = r"(?:v?)(\d+)(?:\.)(\d+)(?:\.(\d+))?.*"
-BUILD_INFO_FILE_REGEX = r"Dockerfile-(:?.*)-rhgs-server-(:?.*)-"
+BUILDS_LABEL_TAG_REGEX = r"^LABEL.(ocs|cns)\.tags=\"v(.*),v(.*)\"$"
OPENSHIFT_STORAGE_VERSION = None
@@ -56,11 +57,20 @@ def _get_openshift_storage_version_str(hostname=None):
"OCS version check cannot be done on the standalone setup.")
buildinfo_cmd = (
- "oc rsh %s ls -l /root/buildinfo/ | "
- "awk '{print $9}' | tail -1" % gluster_pod)
+ "oc rsh %s "
+ "find . -name \"Dockerfile-rhgs3-rhgs-server-rhel7*\" "
+ r"-exec awk '/%s/{print $0}' {} \; "
+ "| tail -1" %
+ (gluster_pod, BUILDS_LABEL_TAG_REGEX))
out = command.cmd_run(buildinfo_cmd, hostname)
- return out
+ build_tag_match = re.search(BUILDS_LABEL_TAG_REGEX, out)
+ if not build_tag_match:
+ error_msg = "Unexpected BUILD LABEL tag expression: '%s'" % out
+ g.log.error(error_msg)
+ raise exceptions.ExecutionError(error_msg)
+
+ return (build_tag_match.group(2)).strip()
def _parse_openshift_storage_version(openshift_storage_version_str):