summaryrefslogtreecommitdiffstats
path: root/openshift-storage-libs/openshiftstoragelibs
diff options
context:
space:
mode:
authorvamahaja <vamahaja@redhat.com>2020-05-08 12:07:42 +0530
committervamahaja <vamahaja@redhat.com>2020-05-08 13:19:06 +0530
commit64d169df4de9e9a2479ca5a35cb1d62967631252 (patch)
tree4980035e2861d17db70bad77079f700417368405 /openshift-storage-libs/openshiftstoragelibs
parent5e62f595570c8716e0dd2b0ca9d3ff6c838be8d1 (diff)
[LibFix] Fix library 'get_openshift_storage_version'
Fix consists of - Add regular expression to get Openshift Storage Version based on environment variable 'ocsVersion' set in Dockerfile Change-Id: Iefed53a7af5b2867b68a4a8b72861047edcf1e4d Signed-off-by: vamahaja <vamahaja@redhat.com>
Diffstat (limited to 'openshift-storage-libs/openshiftstoragelibs')
-rw-r--r--openshift-storage-libs/openshiftstoragelibs/openshift_storage_version.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_storage_version.py b/openshift-storage-libs/openshiftstoragelibs/openshift_storage_version.py
index e798e8b..0ddef4e 100644
--- a/openshift-storage-libs/openshiftstoragelibs/openshift_storage_version.py
+++ b/openshift-storage-libs/openshiftstoragelibs/openshift_storage_version.py
@@ -33,7 +33,8 @@ from openshiftstoragelibs import exceptions
OPENSHIFT_STORAGE_VERSION_RE = r"(?:v?)(\d+)(?:\.)(\d+)(?:\.(\d+))?.*"
-BUILDS_LABEL_TAG_REGEX = r"^LABEL.(ocs|cns)\.tags=\"v(.*),v(.*)\"$"
+BUILDS_LABEL_TAG_REGEX_1 = r"^LABEL.(ocs|cns)\.tags=\"v(.*),v(.*)\"$"
+BUILDS_LABEL_TAG_REGEX_2 = r"^ENV ocsVersion=\"(.*)\"$"
OPENSHIFT_STORAGE_VERSION = None
@@ -60,18 +61,27 @@ def _get_openshift_storage_version_str(hostname=None):
"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)
-
- build_tag_match = re.search(BUILDS_LABEL_TAG_REGEX, out)
- if not build_tag_match:
- error_msg = "Unexpected BUILD LABEL tag expression: '%s'" % out
+ "| tail -1")
+
+ # Get ocs/cns tag LABEL and check if 'ocsVersion' is present in tag
+ out = command.cmd_run(
+ buildinfo_cmd % (gluster_pod, BUILDS_LABEL_TAG_REGEX_1), hostname)
+ build_tag_match = re.search(BUILDS_LABEL_TAG_REGEX_1, out)
+ if build_tag_match and "${ocsVersion}" not in build_tag_match.group(2):
+ return (build_tag_match.group(2)).strip()
+
+ # Get 'ocsVersion' environment variable
+ out = command.cmd_run(
+ buildinfo_cmd % (gluster_pod, BUILDS_LABEL_TAG_REGEX_2), hostname)
+ build_tag_match = re.search(BUILDS_LABEL_TAG_REGEX_2, out)
+ if build_tag_match:
+ return (build_tag_match.group(1)).strip()
+ else:
+ error_msg = (
+ "Unexpected BUILD LABEL or OcsVersion 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):
"""Parses OpenShift Storage version str into tuple of 3 values.