Skip to content

Commit

Permalink
fix(redis): 监听请求act需要考虑进程不存在的情况 #2178
Browse files Browse the repository at this point in the history
  • Loading branch information
OMG-By committed Nov 29, 2023
1 parent c8f18f3 commit aecb764
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ func (job *PredixyOperate) Run() (err error) {
} else {
// stop or shutdown
if !running {
if op == consts.ProxyShutdown {
if err := common.DeleteExporterConfigFile(port); err != nil {
job.runtime.Logger.Warn("predixy %d DeleteExporterConfigFile return err:%v", port, err)
} else {
job.runtime.Logger.Info("predixy %d DeleteExporterConfigFile success", port)
}
return job.DirBackup(execUser, port)
}
return nil
}
cmd = []string{"su", execUser, "-c", fmt.Sprintf("%s %s", stopScript, strconv.Itoa(port))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ func (job *TwemproxyOperate) Run() (err error) {
} else {
// stop or shutdown
if !running {
// 如果是shutdown,此时需要清理相关目录
if op == consts.ProxyShutdown {
if err := common.DeleteExporterConfigFile(port); err != nil {
job.runtime.Logger.Warn("twemproxy %d DeleteExporterConfigFile return err:%v", port, err)
} else {
job.runtime.Logger.Info("twemproxy %d DeleteExporterConfigFile success", port)
}

return job.DirBackup(execUser, port)
}
return nil
}
cmd = []string{"su", execUser, "-c", fmt.Sprintf("%s %s", stopScript, strconv.Itoa(port))}
Expand All @@ -115,6 +125,7 @@ func (job *TwemproxyOperate) Run() (err error) {
}
time.Sleep(5 * time.Second)

// 二次检查进程状态
running, err = job.IsTwemproxyRunning(port)
job.runtime.Logger.Info("check twemproxy %d after exec cmd. status is %s", port, running)
if running && op == consts.ProxyStart {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ def deploy_redis_cluster_flow(self):
"domain_name": self.data["domain_name"],
}
if self.data["cluster_type"] == ClusterType.TendisTwemproxyRedisInstance.value:
act_kwargs.cluster["conf"]["cluster-enabled"] = ClusterStatus.REDIS_CLUSTER_NO
# Redis2版本的配置没有cluster-enabled这个配置项
if not self.data["db_version"].startswith("Redis-2"):
act_kwargs.cluster["conf"]["cluster-enabled"] = ClusterStatus.REDIS_CLUSTER_NO

act_kwargs.get_redis_payload_func = RedisActPayload.set_redis_config.__name__
acts_list.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def redis_cluster_shutdown_flow(self):
**cluster_info["redis_map"],
**cluster_info["proxy_map"],
"monitor_time_ms": DEFAULT_MONITOR_TIME,
"ignore_req": False,
# 集群下架时,默认先关闭,所以这个实例应该没有请求了才对,所以这里应该是强制下架
"ignore_req": True,
"ignore_keys": DEFAULT_REDIS_SYSTEM_CMDS,
}
act_kwargs.bk_cloud_id = cluster_info["bk_cloud_id"]
Expand Down
Loading

0 comments on commit aecb764

Please sign in to comment.