You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by pr...@apache.org on 2017/03/08 04:19:33 UTC

[2/2] ranger git commit: RANGER-1417 : Ranger Upgrade is failing for Oracle DB flavor

RANGER-1417 : Ranger Upgrade is failing for Oracle DB flavor


Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/16cc0d30
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/16cc0d30
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/16cc0d30

Branch: refs/heads/ranger-0.7
Commit: 16cc0d30c08dd7ffe17095c451062203f32c26db
Parents: fa98f45
Author: pradeep <pr...@apache.org>
Authored: Fri Mar 3 16:02:27 2017 +0530
Committer: pradeep <pr...@apache.org>
Committed: Wed Mar 8 09:48:41 2017 +0530

----------------------------------------------------------------------
 security-admin/scripts/db_setup.py | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/16cc0d30/security-admin/scripts/db_setup.py
----------------------------------------------------------------------
diff --git a/security-admin/scripts/db_setup.py b/security-admin/scripts/db_setup.py
index 4112e05..6d1a047 100644
--- a/security-admin/scripts/db_setup.py
+++ b/security-admin/scripts/db_setup.py
@@ -1185,6 +1185,31 @@ class OracleConf(BaseDB):
 						jisql_log(query, db_password)
 						output = check_output(query)
 						if output.strip(version + " |"):
+							#Fix to handle Ranger Upgrade failure for Oracle DB flavor 
+							if is_unix:
+								queryUpgradeCaseCheck = get_cmd + " -c \; -query \"select version from x_db_version_h where version = 'J%s' and active = 'N' and inst_by!='%s';\"" %(version,ranger_version)
+							elif os_name == "WINDOWS":
+								queryUpgradeCaseCheck = get_cmd + " -query \"select version from x_db_version_h where version = 'J%s' and active = 'N' and inst_by!='%s';\" -c ;" %(version,ranger_version)
+							jisql_log(queryUpgradeCaseCheck, db_password)
+							outputUpgradeCaseCheck = check_output(queryUpgradeCaseCheck)
+							if outputUpgradeCaseCheck.strip(version + " |"):
+								if is_unix:
+									queryUpdate = get_cmd + " -c \; -query \"update x_db_version_h set active='Y' where version='J%s' and active='N' and inst_by!='%s';\"" %(version, ranger_version)
+									jisql_log(queryUpdate, db_password)
+									retUpdate = subprocess.call(shlex.split(queryUpdate))
+								elif os_name == "WINDOWS":
+									queryUpdate = get_cmd + " -query \"update x_db_version_h set active='Y' where version='J%s' and active='N' and inst_by!='%s';\" -c ;" %(version, ranger_version)
+									jisql_log(queryUpdate, db_password)
+									retUpdate = subprocess.call(queryUpdate)
+								if retUpdate == 0:
+									log ("[I] java patch "+ className +" status has been updated..","info")
+							if is_unix:
+								query = get_cmd + " -c \; -query \"select version from x_db_version_h where version = 'J%s' and active = 'N';\"" %(version)
+							elif os_name == "WINDOWS":
+								query = get_cmd + " -query \"select version from x_db_version_h where version = 'J%s' and active = 'N';\" -c ;" %(version)
+							jisql_log(query, db_password)
+							output = check_output(query)
+							#End of Upgrade failure fix
 							while(output.strip(version + " |")):
 								log("[I] Java patch "+ className  +" is being applied by some other process" ,"info")
 								time.sleep(300)