-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix: add restart empty sd protection #1494
Conversation
pkg/rest/first_launch.go
Outdated
) | ||
|
||
func Init() { | ||
enableInstanceNullProtect = config.GetBool("instance_null_protect.enable", true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
默认是关,因为这个功能会影响调试,可能造成开源开发者的困扰。
pkg/rest/first_launch.go
Outdated
|
||
func Init() { | ||
enableInstanceNullProtect = config.GetBool("instance_null_protect.enable", true) | ||
restartProtectInterval = time.Duration(config.GetInt("instance_null_protect.restart_protect_interval", 120)) * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
输入参数校验,有效值1-120秒,默认120秒,如果参数非法则打日志提示,并设置为120秒。
pkg/rest/first_launch.go
Outdated
restartProtectInterval = time.Duration(config.GetInt("instance_null_protect.restart_protect_interval", 120)) * time.Second | ||
RestartProtectHttpCode = config.GetInt("instance_null_protect.http_status", 304) | ||
logDir := filepath.Dir(config.GetString("log.file", "", config.WithStandby("logfile"))) | ||
firstLaunchFlagPath = filepath.Join(logDir, "first_launch.flag") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
日志打印关键参数
pkg/rest/first_launch.go
Outdated
) | ||
|
||
/** | ||
for restart service center, set a 2-minute time window to return http status 304 on discovery apis, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注释错误,不要固化参数值
@@ -167,6 +168,10 @@ func (s *InstanceResource) FindInstances(w http.ResponseWriter, r *http.Request) | |||
w.WriteHeader(http.StatusNotModified) | |||
return | |||
} | |||
if len(resp.Instances) == 0 && rest.IsWithinRestartProtection() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
保护逻辑,放在service/disco目录下
|
||
func Init() { | ||
enableInstanceNullProtect = config.GetBool("instance_null_protect.enable", false) | ||
restartProtectInterval = time.Duration(config.GetInt("instance_null_protect.restart_protect_interval", 120)) * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enable为false的时候,直接退出,不用做初始化的操作了
The SDK switches back to the service center which has recovered from the crash as soon as the sc server starts, even though the service center has not synced data from the peer yet, which results in an interruption of service discovery.
add ut