Skip to content

Add Support for Unix Socket endpoints#19760

Merged
ahrtr merged 1 commit intoetcd-io:mainfrom
SalehBorhani:main
May 29, 2025
Merged

Add Support for Unix Socket endpoints#19760
ahrtr merged 1 commit intoetcd-io:mainfrom
SalehBorhani:main

Conversation

@SalehBorhani
Copy link
Contributor

This pull request addresses #19704, which highlights the lack of support for connecting to etcd servers using the Unix socket format (unix://). The changes introduce support for Unix sockets, making it possible to leverage them in single-node etcd setups for local communication. The validation logic has been updated to allow Unix socket schemes while ensuring compatibility with the existing host:port format required for multi-node clusters.

@k8s-ci-robot
Copy link

Hi @SalehBorhani. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@SalehBorhani
Copy link
Contributor Author

@ahrtr

@jmhbnz
Copy link
Member

jmhbnz commented May 16, 2025

/ok-to-test

@codecov
Copy link

codecov bot commented May 16, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 68.84%. Comparing base (b3b9e98) to head (b039448).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
server/embed/config.go 66.66% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
server/embed/config.go 78.62% <66.66%> (+0.39%) ⬆️

... and 28 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #19760      +/-   ##
==========================================
+ Coverage   66.85%   68.84%   +1.98%     
==========================================
  Files         424      424              
  Lines       35756    35774      +18     
==========================================
+ Hits        23905    24627     +722     
+ Misses      10446     9729     -717     
- Partials     1405     1418      +13     

Continue to review full report in Codecov by Sentry.

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

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

@SalehBorhani
Copy link
Contributor Author

I have fixed the issues. Would you please check that
@jmhbnz

@jmhbnz
Copy link
Member

jmhbnz commented May 18, 2025

Hey @SalehBorhani - Do you have capacity to add an e2e test to validate that connecting over unix socket works? This will help us ensure we don't accidentally break it in future, thanks!

@SalehBorhani
Copy link
Contributor Author

You're right @jmhbnz . I will provide that.

// Wait for the process to be ready
require.NoError(t, e2e.WaitReadyExpectProc(t.Context(), proc, e2e.EtcdServerReadyLines))

// Additional validation can be added here if needed
Copy link
Member

Choose a reason for hiding this comment

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

can you please try to write a key/value and read it back using the unix socket?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I forgot that :)

@SalehBorhani
Copy link
Contributor Author

Would you please check that if is it ok for writing in etcd and read from it ? @ahrtr

ahrtr
ahrtr previously approved these changes May 28, 2025
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

LGTM

thx for the nice work!

Please also add a changelog item in a followup PR.

cc @fuweid @ivanvc @jmhbnz @serathius

@SalehBorhani
Copy link
Contributor Author

Thanks for your guidance. But i didn't understand where you mentioned to add changelog the link. What should i do exactly ?
@ahrtr

@ahrtr
Copy link
Member

ahrtr commented May 28, 2025

Thanks for your guidance. But i didn't understand where you mentioned to add changelog the link. What should i do exactly ? @ahrtr

Please refer to the example #20045 . But you should update CHANGELOG-3.7.md: just add an item under the section "etcd server"

@SalehBorhani
Copy link
Contributor Author

I added to the changelog. @ahrtr

@ahrtr
Copy link
Member

ahrtr commented May 28, 2025

I see that this PR is based on a very old commit, please rebase this PR.

@SalehBorhani
Copy link
Contributor Author

I rebased with main branch. @ahrtr

@ahrtr ahrtr changed the title Add Support for Unix Socket Connections in etcd Client Add Support for Unix Socket endpoints May 28, 2025
@SalehBorhani
Copy link
Contributor Author

@ahrtr

Copy link
Member

@ivanvc ivanvc left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request and great job, @SalehBorhani. I left a comment for a minor improvement.

Comment on lines +744 to +747
unixSocket := "unix:///tmp/etcd-client.sock"

// Clean up the socket file after test
defer os.Remove("/tmp/etcd-client.sock")
Copy link
Member

Choose a reason for hiding this comment

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

Could we change this to use a t.TempDir(), so we don't need to clean it up and ensure it's unique?

Suggested change
unixSocket := "unix:///tmp/etcd-client.sock"
// Clean up the socket file after test
defer os.Remove("/tmp/etcd-client.sock")
socketDir := t.TempDir()
unixSocket := fmt.Sprintf("unix://%s/etcd-client.sock", socketDir)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes of course. I will check it now.

Signed-off-by: borhanisaleh6 <borhanisaleh6@gmail.com>
@SalehBorhani
Copy link
Contributor Author

Would you please check that ? @ivanvc

Copy link
Member

@ivanvc ivanvc left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your first contribution, @SalehBorhani!

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahrtr, ivanvc, SalehBorhani

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ahrtr ahrtr merged commit c904edc into etcd-io:main May 29, 2025
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants