From 5bc4d898634006acaef66dc07bffe7bdc6730dcf Mon Sep 17 00:00:00 2001 From: Peter Stachowski Date: Mon, 21 Sep 2015 18:00:56 -0400 Subject: [PATCH] Fix promote for Redis datastore The 'set' command in the Python client interpretes None as the string 'None.' If no password is set on the master, a detach/attach (such as is done with promote) will have the slaves try and use 'none' as a password. This will cause them to not be able to connect to the master and leave them in a detached state. The 'masterpass' is now set to an empty string if no password is set. The restart of Redis was also moved before attaching the slave, so that the mapped CONFIG command is recognized properly. This is required so that setting the master password completes successfully. (cherry picked from commit 6c4db5d327df7e10f7a0bf38deaee0db4fe2ee5a) Closes-Bug: #1498208 Change-Id: Ibc842b95fd191908d4fac420030f84393c696013 Depends-On: Ida0aa155b1e1ec7b8e9fa73006d3db9a88ffea02 --- trove/guestagent/datastore/experimental/redis/manager.py | 3 ++- .../strategies/replication/experimental/redis_sync.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/trove/guestagent/datastore/experimental/redis/manager.py b/trove/guestagent/datastore/experimental/redis/manager.py index e88d3c1efe..3a6baf4ac1 100644 --- a/trove/guestagent/datastore/experimental/redis/manager.py +++ b/trove/guestagent/datastore/experimental/redis/manager.py @@ -122,9 +122,10 @@ class Manager(periodic_task.PeriodicTasks): persistence_dir = self._app.get_working_dir() self._perform_restore(backup_info, context, persistence_dir, self._app) + else: + self._app.restart() if snapshot: self.attach_replica(context, snapshot, snapshot['config']) - self._app.restart() if cluster_config: self._app.status.set_status( rd_instance.ServiceStatuses.BUILD_PENDING) diff --git a/trove/guestagent/strategies/replication/experimental/redis_sync.py b/trove/guestagent/strategies/replication/experimental/redis_sync.py index 35c7e866b2..3eb95524ff 100644 --- a/trove/guestagent/strategies/replication/experimental/redis_sync.py +++ b/trove/guestagent/strategies/replication/experimental/redis_sync.py @@ -66,6 +66,8 @@ class RedisSyncReplication(base.Replication): if master_passwd: connect_options['masterauth'] = master_passwd service.admin.config_set('masterauth', master_passwd) + else: + service.admin.config_set('masterauth', "") service.configuration_manager.apply_system_override( connect_options, change_id=self.CONF_LABEL_REPLICATION_SLAVE) service.admin.set_master(host=master_host, port=master_port) @@ -75,7 +77,7 @@ class RedisSyncReplication(base.Replication): service.configuration_manager.remove_system_override( change_id=self.CONF_LABEL_REPLICATION_SLAVE) service.admin.set_master(host=None, port=None) - service.admin.config_set('masterauth', None) + service.admin.config_set('masterauth', "") return None def cleanup_source_on_replica_detach(self, service, replica_info):