Author: swagle
Date: Fri Mar 8 21:14:19 2013
New Revision: 1454564
URL: http://svn.apache.org/r1454564
Log:
AMBARI-1586. Upgrade of Ambari DB on upgrade to 1.2.2 should restore/keep the
configuration data for MAPREDUCE. (Sumit Mohanty via swagle)
Added:
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Check.sql
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Fix.sql
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.sql
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-server/pom.xml
incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py
Modified: incubator/ambari/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1454564&r1=1454563&r2=1454564&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Fri Mar 8 21:14:19 2013
@@ -451,6 +451,9 @@ Trunk (unreleased changes):
BUG FIXES
+ AMBARI-1586. Upgrade of Ambari DB on upgrade to 1.2.2 should restore/keep
+ the configuration data for MAPREDUCE. (Sumit Mohanty via swagle)
+
AMBARI-1594. Ambari UI shows failed services while processes are running
on the server. (swagle)
Modified: incubator/ambari/trunk/ambari-server/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/pom.xml?rev=1454564&r1=1454563&r2=1454564&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/pom.xml (original)
+++ incubator/ambari/trunk/ambari-server/pom.xml Fri Mar 8 21:14:19 2013
@@ -253,7 +253,9 @@
<groupname>root</groupname>
<sources>
<source>
-
<location>src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.1.sql</location>
+
<location>src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.sql</location>
+
<location>src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Fix.sql</location>
+
<location>src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Check.sql</location>
</source>
</sources>
</mapping>
Modified: incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py?rev=1454564&r1=1454563&r2=1454564&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py
(original)
+++ incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py Fri
Mar 8 21:14:19 2013
@@ -241,8 +241,6 @@ def write_property(key, value):
return 0
-
-
def setup_db(args):
#password access to ambari-server and mapred
configure_postgres_username_password(args)
@@ -258,12 +256,10 @@ def setup_db(args):
return retcode
-
-def upgrade_db(args):
+def execute_db_script(args, file):
#password access to ambari-server and mapred
configure_postgres_username_password(args)
dbname = args.postgredbname
- file = args.upgrade_script_file
username = args.postgres_username
password = args.postgres_password
command = SETUP_DB_CMD[:]
@@ -273,6 +269,28 @@ def upgrade_db(args):
print errdata
return retcode
+
+def check_db_consistency(args, file):
+ #password access to ambari-server and mapred
+ configure_postgres_username_password(args)
+ dbname = args.postgredbname
+ username = args.postgres_username
+ password = args.postgres_password
+ command = SETUP_DB_CMD[:]
+ command[-1] = command[-1].format(file, username, password)
+ retcode, outdata, errdata = run_os_command(command)
+ if not retcode == 0:
+ print errdata
+ return retcode
+ else:
+ # Assumes that the output is of the form ...\n<count>
+ print_info_msg("Parsing output: " + outdata)
+ lines = outdata.splitlines()
+ if (lines[-1] == '3'):
+ return 0
+ return -1
+
+
def upgrade_stack(args, stack_id):
#password access to ambari-server and mapred
configure_postgres_username_password(args)
@@ -879,19 +897,33 @@ def stop(args):
# Upgrades the Ambari Server.
#
def upgrade(args):
-
print 'Checking PostgreSQL...'
retcode = check_postgre_up()
if not retcode == 0:
- printErrorMsg ('PostgreSQL server not running. Exiting')
+ printErrorMsg('PostgreSQL server not running. Exiting')
sys.exit(retcode)
+ file = args.upgrade_script_file
print 'Upgrading database...'
- retcode = upgrade_db(args)
+ retcode = execute_db_script(args, file)
if not retcode == 0:
- printErrorMsg ('Database upgrade script has failed. Exiting.')
+ printErrorMsg('Database upgrade script has failed. Exiting.')
sys.exit(retcode)
+ print 'Checking database integrity...'
+ check_file = file[:-3] + "Check" + file[-4:]
+ retcode = check_db_consistency(args, check_file)
+
+ if not retcode == 0:
+ print 'Found inconsistency. Trying to fix...'
+ fix_file = file[:-3] + "Fix" + file[-4:]
+ retcode = execute_db_script(args, fix_file)
+
+ if not retcode == 0:
+ printErrorMsg('Database cannot be fixed. Exiting.')
+ sys.exit(retcode)
+ else:
+ print 'Database is consistent.'
print "Ambari Server 'upgrade' finished successfully"
@@ -1088,7 +1120,7 @@ def main():
help="File with drop script")
parser.add_option('-u', '--upgrade-script-file', default="/var/lib/"
"ambari-server/resources/upgrade/ddl/"
- "Ambari-DDL-Postgres-UPGRADE-1.2.1.sql",
+ "Ambari-DDL-Postgres-UPGRADE-1.2.2.sql",
help="File with upgrade script")
parser.add_option('-t', '--upgrade-stack-script-file', default="/var/lib/"
"ambari-server/resources/upgrade/dml/"
Added:
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Check.sql
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Check.sql?rev=1454564&view=auto
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Check.sql
(added)
+++
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Check.sql
Fri Mar 8 21:14:19 2013
@@ -0,0 +1,20 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+\connect ambari;
+
+COPY (SELECT count(*) FROM ambari.serviceconfigmapping WHERE service_name =
'MAPREDUCE') TO STDOUT WITH CSV;
Added:
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Fix.sql
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Fix.sql?rev=1454564&view=auto
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Fix.sql
(added)
+++
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.Fix.sql
Fri Mar 8 21:14:19 2013
@@ -0,0 +1,26 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+\connect ambari;
+
+INSERT INTO ambari.serviceconfigmapping (cluster_id, service_name,
config_type, config_tag, timestamp)
+ SELECT cluster_id, 'MAPREDUCE', type_name, version_tag, create_timestamp
from ambari.clusterconfig
+ WHERE type_name = 'global' ORDER BY create_timestamp DESC LIMIT 1;
+
+INSERT INTO ambari.serviceconfigmapping (cluster_id, service_name,
config_type, config_tag, timestamp)
+ SELECT cluster_id, 'MAPREDUCE', type_name, version_tag, create_timestamp
from ambari.clusterconfig
+ WHERE type_name = 'mapred-site' ORDER BY create_timestamp DESC LIMIT
1;
Added:
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.sql
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.sql?rev=1454564&view=auto
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.sql
(added)
+++
incubator/ambari/trunk/ambari-server/src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.2.2.sql
Fri Mar 8 21:14:19 2013
@@ -0,0 +1,21 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+\connect ambari;
+
+ALTER TABLE ambari.hosts
+ ALTER COLUMN disks_info TYPE VARCHAR(10000);