From c63ca98bd2f0cd4be5429d425eccd5e34a9359c2 Mon Sep 17 00:00:00 2001 From: Matt Van Dijk Date: Mon, 28 Nov 2016 15:21:46 -0500 Subject: [PATCH] Various post-upgrade fixes The config file gets restored so the config cache needs refreshing. Touch .guestagent.prepare.end file after upgrade to fix the problem of the guestagent not knowing if prepare has ran. Write the volume mount to fstab to persist after subsequent restarts. Change-Id: I3831de12c999ef8818e80ecdb29f1d86ff8cd5c8 Closes-bug: #1645460 Depends-On: I5c1714b7839b2736c50f2daa2f4506c4006815a1 --- .../notes/post-upgrade-fixes-828811607826d433.yaml | 4 ++++ .../datastore/experimental/postgresql/manager.py | 3 ++- .../datastore/experimental/postgresql/service.py | 2 ++ trove/guestagent/datastore/mysql_common/manager.py | 1 + trove/guestagent/datastore/service.py | 11 +++++++---- 5 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/post-upgrade-fixes-828811607826d433.yaml diff --git a/releasenotes/notes/post-upgrade-fixes-828811607826d433.yaml b/releasenotes/notes/post-upgrade-fixes-828811607826d433.yaml new file mode 100644 index 0000000000..ca276a5176 --- /dev/null +++ b/releasenotes/notes/post-upgrade-fixes-828811607826d433.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - After upgrading the guestagent was in an inconsistent state. This became + apparent after restarting or resizing the instance after upgrading. diff --git a/trove/guestagent/datastore/experimental/postgresql/manager.py b/trove/guestagent/datastore/experimental/postgresql/manager.py index 840513123e..b945131cea 100644 --- a/trove/guestagent/datastore/experimental/postgresql/manager.py +++ b/trove/guestagent/datastore/experimental/postgresql/manager.py @@ -159,7 +159,8 @@ class Manager(manager.Manager): self.app.stop_db() if 'device' in upgrade_info: self.mount_volume(context, mount_point=upgrade_info['mount_point'], - device_path=upgrade_info['device']) + device_path=upgrade_info['device'], + write_to_fstab=True) self.app.restore_files_post_upgrade(upgrade_info) self.app.start_db() diff --git a/trove/guestagent/datastore/experimental/postgresql/service.py b/trove/guestagent/datastore/experimental/postgresql/service.py index a59d711058..1f7ce687eb 100644 --- a/trove/guestagent/datastore/experimental/postgresql/service.py +++ b/trove/guestagent/datastore/experimental/postgresql/service.py @@ -561,6 +561,8 @@ class PgSqlApp(object): force=True, as_root=True) operating_system.remove(upgrade_info['save_etc'], force=True, as_root=True) + self.configuration_manager.refresh_cache() + self.status.set_ready() class PgSqlAppStatus(service.BaseDbStatus): diff --git a/trove/guestagent/datastore/mysql_common/manager.py b/trove/guestagent/datastore/mysql_common/manager.py index b670dd0fa7..07be748edf 100644 --- a/trove/guestagent/datastore/mysql_common/manager.py +++ b/trove/guestagent/datastore/mysql_common/manager.py @@ -290,6 +290,7 @@ class MySqlManager(manager.Manager): operating_system.copy("%s/." % upgrade_info['home_save'], os.path.expanduser('~'), preserve=True, as_root=True) + self.configuration_manager.refresh_cache() app.start_mysql() def restart(self, context): diff --git a/trove/guestagent/datastore/service.py b/trove/guestagent/datastore/service.py index f5042f3acb..a3af9af819 100644 --- a/trove/guestagent/datastore/service.py +++ b/trove/guestagent/datastore/service.py @@ -97,16 +97,19 @@ class BaseDbStatus(object): """Called before restarting DB server.""" self.restart_mode = True + def set_ready(self): + prepare_end_file = guestagent_utils.build_file_path( + self.GUESTAGENT_DIR, self.PREPARE_END_FILENAME) + operating_system.write_file(prepare_end_file, '') + self.__refresh_prepare_completed() + def end_install(self, error_occurred=False, post_processing=False): """Called after prepare has ended.""" # Set the "we're done" flag if there's no error and # no post_processing is necessary if not (error_occurred or post_processing): - prepare_end_file = guestagent_utils.build_file_path( - self.GUESTAGENT_DIR, self.PREPARE_END_FILENAME) - operating_system.write_file(prepare_end_file, '') - self.__refresh_prepare_completed() + self.set_ready() final_status = None if error_occurred: