From de8ac4cb6510f89ec2ed5316397ace849dbf5fbf Mon Sep 17 00:00:00 2001 From: xue_meng_en <1836611252@qq.com> Date: Wed, 13 Mar 2024 19:24:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E6=90=AD=E5=BB=BA=E5=AE=B9=E7=81=BE?= =?UTF-8?q?=E5=85=B3=E7=B3=BB=E7=9A=84=E9=9B=86=E7=BE=A4=E6=89=A7=E8=A1=8C?= =?UTF-8?q?gs=5Fsdr=20stop=E6=AD=A3=E5=B8=B8=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../streaming_disaster_recovery/streaming_base.py | 11 +++++++++-- .../streaming_disaster_recovery_stop.py | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/script/impl/streaming_disaster_recovery/streaming_base.py b/script/impl/streaming_disaster_recovery/streaming_base.py index 79e7d2d..47cb21b 100644 --- a/script/impl/streaming_disaster_recovery/streaming_base.py +++ b/script/impl/streaming_disaster_recovery/streaming_base.py @@ -414,11 +414,18 @@ class StreamingBase(object): """ Streaming step """ - step = -1 - if os.path.isfile(self.step_file_path): + step = 0 + if not os.path.exists(os.path.dirname(self.step_file_path)): + # If streaming dir(streaming_cabin) does not exist, + # it means the cluster is not a DR cluster, return -1. + step = -1 + elif os.path.isfile(self.step_file_path): step_list = FileUtil.readFile(self.step_file_path) if step_list: step = int(step_list[0].split("_")[0]) + # When streaming dir exists but the step file does not exist, + # it means the cluster is a DR cluster but it is in archive or recovery + # and not in any operation process(start, stop, failover, switchover), return 0. if step == -1: self.logger.log("Got the step for action:[%s]." % self.params.task) else: diff --git a/script/impl/streaming_disaster_recovery/streaming_modules/streaming_disaster_recovery_stop.py b/script/impl/streaming_disaster_recovery/streaming_modules/streaming_disaster_recovery_stop.py index 0a41368..39f50a9 100644 --- a/script/impl/streaming_disaster_recovery/streaming_modules/streaming_disaster_recovery_stop.py +++ b/script/impl/streaming_disaster_recovery/streaming_modules/streaming_disaster_recovery_stop.py @@ -30,6 +30,8 @@ class StreamingStopHandler(StreamingBase): """ First step for streaming stop """ + if step == -1: + self.logger.logExit("No need to stop because the cluster is not a disaster cluster.") if step >= 2: return self.logger.debug("Start first step of streaming stop.")