Skip to content
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

Fix/consul unreg #973

Merged
merged 6 commits into from
Jan 10, 2021
Merged

Conversation

LaurenceLiZhixin
Copy link
Contributor

What this PR does:
fix consul unregister bug.

Which issue(s) this PR fixes:

Fixes #749

Special notes for your reviewer:
I record the copy of every registry url, and make sure the unregistry url is we wanted.
Does this PR introduce a user-facing change?:


@codecov-io
Copy link

codecov-io commented Dec 28, 2020

Codecov Report

Merging #973 (082a0bd) into develop (a976cf4) will decrease coverage by 0.33%.
The diff coverage is 54.83%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #973      +/-   ##
===========================================
- Coverage    59.92%   59.59%   -0.34%     
===========================================
  Files          261      261              
  Lines        12915    12903      -12     
===========================================
- Hits          7739     7689      -50     
- Misses        4223     4247      +24     
- Partials       953      967      +14     
Impacted Files Coverage Δ
cluster/router/chain/chain.go 67.96% <0.00%> (-2.67%) ⬇️
cluster/router/condition/router.go 78.91% <0.00%> (ø)
common/proxy/proxy.go 90.19% <ø> (+1.73%) ⬆️
common/rpc_service.go 87.41% <ø> (-0.70%) ⬇️
config_center/file/impl.go 52.47% <ø> (ø)
...lter_impl/tps/tps_limit_sliding_window_strategy.go 100.00% <ø> (ø)
metadata/service/remote/service.go 39.72% <0.00%> (ø)
remoting/getty/getty_client.go 44.30% <ø> (+2.32%) ⬆️
remoting/getty/getty_server.go 45.83% <0.00%> (+3.86%) ⬆️
remoting/kubernetes/registry_controller.go 46.12% <0.00%> (-5.31%) ⬇️
... and 47 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ae3c90...082a0bd. Read the comment docs.

@@ -91,6 +95,7 @@ func (r *consulRegistry) Register(url *common.URL) error {

// register actually register the @url
func (r *consulRegistry) register(url *common.URL) error {
r.registeredURLs = append(r.registeredURLs, url.Clone())
Copy link

@JiaLiangoooo JiaLiangoooo Dec 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问一个问题,在还没有注册consul之前就应该添加上去吗?

但是如果在注册成功之后,因为buildService(url)因为传进去的是url的引用,会修改掉url的参数,所以也会问题.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 我认为在注册前把url添加进数组没有问题。
    因为最终destroy的时候,即使unregister不存在的url也无妨。
  2. 因为buildServicce会对url进行修改,而其中buildid函数是根据修改前的url生成的id,在unregister的时候,也必须严格使用修改前的url来生成id,所以这里临时把修改前的拷贝了出来,用于unregister。

@AlexStocks AlexStocks force-pushed the develop branch 23 times, most recently from b6022bb to 9e40791 Compare January 4, 2021 08:59
select {
case <-done:
logger.Infof("consulRegistry unregister done")
case <-time.After(registryDestroyDefaultTimeout):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using getty.GetTimeWheel().After(registryDestroyDefaultTimeout) instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

@AlexStocks AlexStocks force-pushed the develop branch 4 times, most recently from ca6b03e to 34fa1da Compare January 6, 2021 02:12
@AlexStocks AlexStocks force-pushed the develop branch 3 times, most recently from d12bf6a to e633a73 Compare January 9, 2021 09:35
@AlexStocks AlexStocks merged commit 213637e into apache:develop Jan 10, 2021
AlexStocks added a commit that referenced this pull request Jan 10, 2021
AlexStocks added a commit that referenced this pull request Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants