Skip to content

Update dependencies and restore etcd API#3245

Open
utafrali wants to merge 1 commit intoapache:developfrom
utafrali:fix/issue-3243-update-restore-the-previously-removed-ap
Open

Update dependencies and restore etcd API#3245
utafrali wants to merge 1 commit intoapache:developfrom
utafrali:fix/issue-3243-update-restore-the-previously-removed-ap

Conversation

@utafrali
Copy link
Copy Markdown

Description

Fixes #3243

Bumped the dependencies to newer versions. The main thing is restoring the etcd API in the client that was previously removed - it's needed for grpc compatibility.

Checklist

  • I confirm the target branch is develop
  • Code has passed local testing
  • I have added tests that prove my fix is effective or that my feature works

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 47.97%. Comparing base (e7770c9) to head (39cc231).
⚠️ Report is 14 commits behind head on develop.

Files with missing lines Patch % Lines
remoting/etcdv3/client.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3245      +/-   ##
===========================================
+ Coverage    47.91%   47.97%   +0.05%     
===========================================
  Files          467      467              
  Lines        34045    34045              
===========================================
+ Hits         16314    16334      +20     
+ Misses       16407    16388      -19     
+ Partials      1324     1323       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates etcdv3 client construction to use the newer gost etcd client API that accepts an options struct + context, and refreshes several Go module dependencies accordingly.

Changes:

  • Switch etcdv3 client creation from gxetcd.NewClient(...) to gxetcd.NewClientWithOptions(ctx, options).
  • Add context usage for etcdv3 client initialization.
  • Bump dependency versions in go.mod and update go.sum entries.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
remoting/etcdv3/client.go Migrates etcdv3 client initialization to the new NewClientWithOptions API and introduces context passing.
go.mod Updates versions for gost, logrus, and several golang.org/x/* modules.
go.sum Adds corresponding checksums for the updated module versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 42 to 44
if container.Client() == nil {
newClient, err := gxetcd.NewClient(options.Name, options.Endpoints, options.Timeout, options.Heartbeat)
newClient, err := gxetcd.NewClientWithOptions(context.Background(), options)
if err != nil {
Comment on lines 52 to 55
// Client lose connection with etcd server
if container.Client().GetRawClient() == nil {
newClient, err := gxetcd.NewClient(options.Name, options.Endpoints, options.Timeout, options.Heartbeat)
newClient, err := gxetcd.NewClientWithOptions(context.Background(), options)
if err != nil {
Comment on lines 74 to 76

newClient, err := gxetcd.NewClient(options.Name, options.Endpoints, options.Timeout, options.Heartbeat)
newClient, err := gxetcd.NewClientWithOptions(context.Background(), options)
if err != nil {
// new Client
if container.Client() == nil {
newClient, err := gxetcd.NewClient(options.Name, options.Endpoints, options.Timeout, options.Heartbeat)
newClient, err := gxetcd.NewClientWithOptions(context.Background(), options)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All three NewClientWithOptions call sites use context.Background(), which creates an uncancellable context. ValidateClient is called under container.ClientLock(), so if etcd is unreachable and the dial blocks, the lock is held indefinitely — freezing the entire application.

NewClientWithOptions internally calls context.WithCancel(ctx), so cancellation from the caller side is fully supported but unused here.

Suggestion: At minimum, use context.WithTimeout(context.Background(), options.Timeout) to bound the blocking time:

ctx, cancel := context.WithTimeout(context.Background(), options.Timeout)
defer cancel()
newClient, err := gxetcd.NewClientWithOptions(ctx, options)

Ideally, accept a context.Context parameter in ValidateClient and NewServiceDiscoveryClient to give callers full control over cancellation.

@AlexStocks
Copy link
Copy Markdown
Contributor

metadata/report/etcd/report.go:120 — This PR migrates remoting/etcdv3/client.go from NewClient to NewClientWithOptions (which supports TLS, username, password), but metadata/report/etcd/report.go still uses the old NewClient API:

client, err := gxetcd.NewClient(gxetcd.MetadataETCDV3Client, addresses, timeout, 1)

This inconsistency means metadata report will not benefit from TLS/auth support, and if a future gost version removes NewClient, this file breaks.

Suggestion: Update to NewClientWithOptions for consistency:

client, err := gxetcd.NewClientWithOptions(context.Background(), &gxetcd.Options{
    Name:      gxetcd.MetadataETCDV3Client,
    Endpoints: addresses,
    Timeout:   timeout,
    Heartbeat: 1,
})

@AlexStocks
Copy link
Copy Markdown
Contributor

The PR checklist states "I confirm the target branch is develop", but this PR actually targets main. Please confirm the intended target branch — if the project convention is to merge into develop first, this PR should be retargeted.

@AlexStocks AlexStocks changed the base branch from main to develop March 14, 2026 03:12
@AlexStocks
Copy link
Copy Markdown
Contributor

The PR checklist states "I confirm the target branch is develop", but this PR actually targets main. Please confirm the intended target branch — if the project convention is to merge into develop first, this PR should be retargeted.

I have changed the target branch to develop.

@Alanxtl Alanxtl self-assigned this Mar 14, 2026
@Alanxtl
Copy link
Copy Markdown
Contributor

Alanxtl commented Mar 14, 2026

@CAICAIIs check this

@utafrali
Copy link
Copy Markdown
Author

Done, pushed the fix.

@Alanxtl
Copy link
Copy Markdown
Contributor

Alanxtl commented Mar 16, 2026

actually, what you should do is to modify https://github.com/dubbogo/gost instead of dubbo-go repo.
The api we deleted in dubbogo/gost#131 and added back in dubbogo/gost#134.

What you should do is to do extally the same as dubbogo/gost#131

Copy link
Copy Markdown
Contributor

@AlexStocks AlexStocks left a comment

Choose a reason for hiding this comment

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

PR 主要是更新 gost 依赖(v1.14.3 → v1.14.4)并恢复 etcd client API。

发现一个问题:gxetcd.NewClientWithOptions(context.Background(), options) 使用了硬编码的 context.Background()。建议改成支持调用者传入 context,或者至少使用 context.TODO() 表明这是临时的。

其他方面看起来没问题:依赖更新是常规操作,gost 的 API 变更(从 NewClient 到 NewClientWithOptions)应该是向下兼容的。

// new Client
if container.Client() == nil {
newClient, err := gxetcd.NewClient(options.Name, options.Endpoints, options.Timeout, options.Heartbeat)
newClient, err := gxetcd.NewClientWithOptions(context.Background(), options)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这里硬编码了 context.Background()。建议使用 context.TODO() 表明这是临时的,或者考虑添加一个 context 参数让调用者控制。

// Client lose connection with etcd server
if container.Client().GetRawClient() == nil {
newClient, err := gxetcd.NewClient(options.Name, options.Endpoints, options.Timeout, options.Heartbeat)
newClient, err := gxetcd.NewClientWithOptions(context.Background(), options)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

同上,硬编码 context.Background()

}

newClient, err := gxetcd.NewClient(options.Name, options.Endpoints, options.Timeout, options.Heartbeat)
newClient, err := gxetcd.NewClientWithOptions(context.Background(), options)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

同上,硬编码 context.Background()

@CAICAIIs
Copy link
Copy Markdown
Contributor

Please resolve the conflict when you have time~

@utafrali utafrali force-pushed the fix/issue-3243-update-restore-the-previously-removed-ap branch from 39cc231 to c7025d9 Compare April 7, 2026 14:26
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 7, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UPDATE] Restore the previously removed API for etcd/grpc compatibility/update

6 participants