Do not remove root user on disable
The existence of the root user (with remote access) is used to determine whether root was ever enabled on a restored instance. Do not remove it, just generate a new random password for it. Change-Id: I8a4321ac062b1ec565945b49dbb7c619b6da867f Closes-Bug: 1549600
This commit is contained in:
4
releasenotes/notes/mysql-root-fix-35079552e25170ca.yaml
Normal file
4
releasenotes/notes/mysql-root-fix-35079552e25170ca.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Do not remove MySQL root user on root-disable so that the
|
||||||
|
proper status can be reported on restore. Bug 1549600
|
||||||
@@ -1062,7 +1062,6 @@ class BaseMySqlRootAccess(object):
|
|||||||
return user.serialize()
|
return user.serialize()
|
||||||
|
|
||||||
def disable_root(self):
|
def disable_root(self):
|
||||||
"""Disable the root user global access
|
"""Reset the root password to an unknown value.
|
||||||
"""
|
"""
|
||||||
with self.local_sql_client(self.mysql_app.get_engine()) as client:
|
self.enable_root(root_password=None)
|
||||||
client.execute(text(sql_query.REMOVE_ROOT))
|
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ from trove.conductor import api as conductor_api
|
|||||||
from trove.guestagent.common.configuration import ConfigurationManager
|
from trove.guestagent.common.configuration import ConfigurationManager
|
||||||
from trove.guestagent.common.configuration import ImportOverrideStrategy
|
from trove.guestagent.common.configuration import ImportOverrideStrategy
|
||||||
from trove.guestagent.common import operating_system
|
from trove.guestagent.common import operating_system
|
||||||
from trove.guestagent.common import sql_query
|
|
||||||
from trove.guestagent.datastore.experimental.cassandra import (
|
from trove.guestagent.datastore.experimental.cassandra import (
|
||||||
service as cass_service)
|
service as cass_service)
|
||||||
from trove.guestagent.datastore.experimental.couchbase import (
|
from trove.guestagent.datastore.experimental.couchbase import (
|
||||||
@@ -1669,14 +1668,12 @@ class MySqlRootStatusTest(trove_testtools.TestCase):
|
|||||||
mock_execute.assert_any_call(TextClauseMatcher(
|
mock_execute.assert_any_call(TextClauseMatcher(
|
||||||
'UPDATE mysql.user'))
|
'UPDATE mysql.user'))
|
||||||
|
|
||||||
def test_root_disable(self):
|
@patch.object(MySqlRootAccess, 'enable_root')
|
||||||
with patch.object(self.mock_client,
|
def test_root_disable(self, enable_root_mock):
|
||||||
'execute', return_value=None) as mock_execute:
|
# invocation
|
||||||
# invocation
|
MySqlRootAccess().disable_root()
|
||||||
MySqlRootAccess().disable_root()
|
# verification
|
||||||
# verification
|
enable_root_mock.assert_called_once_with(root_password=None)
|
||||||
mock_execute.assert_any_call(TextClauseMatcher(
|
|
||||||
sql_query.REMOVE_ROOT))
|
|
||||||
|
|
||||||
|
|
||||||
class MockStats:
|
class MockStats:
|
||||||
|
|||||||
Reference in New Issue
Block a user