From 9a5cb537d1ae71cbdb572adbc53c3163b85ded53 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 30 Jun 2009 17:59:29 +0200 Subject: [PATCH] backend.DemoteFromMC: don't fail for missing files If the config file is missing when the DemoteFromMC() function is called, it will raise a ProgrammerError. Instead of changing the utils.CreateBackup() file which is called from multiple places, for now we only change the DemoteFromMC() function to not call it if the file is not existing (we rely on the master to prevent race conditions here). Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Olivier Tharan <olive@google.com> --- lib/backend.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/backend.py b/lib/backend.py index d438f1a93..bca351242 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -2308,7 +2308,8 @@ def DemoteFromMC(): if utils.IsProcessAlive(utils.ReadPidFile(pid_file)): return (False, "The master daemon is running, will not demote") try: - utils.CreateBackup(constants.CLUSTER_CONF_FILE) + if os.path.isfile(constants.CLUSTER_CONF_FILE): + utils.CreateBackup(constants.CLUSTER_CONF_FILE) except EnvironmentError, err: if err.errno != errno.ENOENT: return (False, "Error while backing up cluster file: %s" % str(err)) -- GitLab