Fix gnocchi-upgrade Table <..> already exists errors

Currently we are calling /usr/bin/gnocchi-upgrade
--sacks-number=SACK_NUM from each node where gnocchi-api is part of the
role. gnocchi-upgrade seems to be racy and we sometimes end up with the
following error:

2018-03-14 12:39:39,683 [1] ERROR    oslo_db.sqlalchemy.exc_filters: DBAPIError exception wrapped from (pymysql.err.InternalError) (1050, u"Table 'archive_policy' already exists") [SQL: u'\nCREATE TABLE archive_policy (\n\tname VARCHAR(255) NOT NULL, \n\tback_window INTEGER NOT NULL, \n\tdefinition TEXT NOT NULL, \n\taggregation_methods TEXT NOT NULL, \n\tPRIMARY KEY (name)\n)ENGINE=InnoDB CHARSET=utf8\n\n']
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 166, in execute
    result = self._query(query)
  File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 856, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1057, in _read_query_result
    result.read()
  File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1340, in read
    first_packet = self.connection._read_packet()
  File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1014, in _read_packet
    packet.check_error()
  File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 393, in check_error
    err.raise_mysql_exception(self._data)
  File "/usr/lib/python2.7/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
InternalError: (1050, u"Table 'archive_policy' already exists")

Let's run it from a the bootstrap node by wrapping it into the
bootstrap_host_exec magic.

Change-Id: I106512eeffff3425608a543f9bc5e6a9508d15e5
Closes-Bug: #1755564
This commit is contained in:
Michele Baldessari 2018-03-14 20:49:05 +01:00
parent b6c9134c83
commit 1d704d4733
1 changed files with 1 additions and 1 deletions

View File

@ -120,7 +120,7 @@ outputs:
/var/lib/kolla/config_files/gnocchi_db_sync.json:
command:
str_replace:
template: /usr/bin/gnocchi-upgrade --sacks-number=SACK_NUM
template: /usr/bin/bootstrap_host_exec gnocchi_api /usr/bin/gnocchi-upgrade --sacks-number=SACK_NUM
params:
SACK_NUM: {get_param: NumberOfStorageSacks}
config_files: *gnocchi_api_kolla_config_files