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

feat: add ipv6 support #32960

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

UnyieldingOrca
Copy link

This PR updates the func utils get IP address function to support getting a IPv6 address if it is available and return it. I've tested that this works locally when running inside a docker container that has an IPv6 network address.

This PR should address #20217

Thank you for review!

Signed-off-by: David Pichler <david.pichler@grainger.com>
@sre-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: UnyieldingOrca
To complete the pull request process, please assign yanliang567 after the PR has been reviewed.
You can assign the PR to them by writing /assign @yanliang567 in a comment when ready.

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

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

@sre-ci-robot sre-ci-robot added the size/M Denotes a PR that changes 30-99 lines. label May 10, 2024
@mergify mergify bot added dco-passed DCO check passed. kind/feature Issues related to feature request from users do-not-merge/missing-related-issue labels May 10, 2024
Copy link
Contributor

mergify bot commented May 10, 2024

@UnyieldingOrca Please associate the related issue to the body of your Pull Request. (eg. “issue: #”)

@yhmo
Copy link
Contributor

yhmo commented May 11, 2024

My suggestion, put the logic into one loop.

// GetValidLocalIP returns the first valid local ip address
func GetValidLocalIP(addrs []net.Addr) string {
	for _, addr := range addrs {
		ipaddr, ok := addr.(*net.IPNet)
		// illegal address
		if !ok || !ipaddr.IP.IsGlobalUnicast() {
			return ""
		}

		// valid ipv4 addresses
		if ipaddr.IP.To4() != nil {
			return ipaddr.IP.String()
		}

		// valid ipv6 addresses
		if ipaddr.IP.To16() != nil {
			return "[" + ipaddr.IP.String() + "]"
		}
	}

	return ""
}

@yhmo
Copy link
Contributor

yhmo commented May 11, 2024

@UnyieldingOrca
Could you confirm it works fine for the three cases?

  1. ipv4 only (all components only have ipv4 address)
  2. ipv4 & ipv6 dual stack (some components have ipv4 address, others ipv6 address)
  3. ipv6 only (all components only have ipv6 address)

Copy link

codecov bot commented May 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.70%. Comparing base (cedb33c) to head (e0caf97).
Report is 31 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #32960      +/-   ##
==========================================
- Coverage   81.79%   81.70%   -0.10%     
==========================================
  Files        1006     1007       +1     
  Lines      126785   127634     +849     
==========================================
+ Hits       103701   104278     +577     
- Misses      19147    19364     +217     
- Partials     3937     3992      +55     
Files Coverage Δ
pkg/util/funcutil/func.go 91.72% <100.00%> (+0.26%) ⬆️

... and 70 files with indirect coverage changes

@mergify mergify bot added the ci-passed label May 11, 2024
@UnyieldingOrca
Copy link
Author

UnyieldingOrca commented May 11, 2024

My suggestion, put the logic into one loop.

The reason I wrote this way is because this code will behave no differently for anyone currently using milvus. If they have a valid ipv4 address that one will be returned, and only if there are no ipv4 addresses will the code return an ipv6 address. I think it will be a bit safer this way.

Could you confirm it works fine for the three cases?

I tested different versions of this code locally using an edited version of deployments/docker/dev/docker-compose-apple-silicon.yml, (see #20217 (reply in thread) for details) a dev container for building milvus, and the builder container in the main docker compose file to run scripts/start_cluster.sh

I only checked that there were no errors in some of the log files and that I was able to connect from my host machine using pymilvus and run a .list_collections() command.

I tested this code in a dual stack network setup using docker and I was able to connect to milvus. I also tested a different version of the code where GetValidLocalIP only returned IPv6 network addresses and that worked as well.

I did not attempt to run all of the python unit/integration tests though.

@UnyieldingOrca
Copy link
Author

@yhmo Does my latest comment address your concerns?

@UnyieldingOrca
Copy link
Author

@bigsheeper @godchen0212 @yhmo Is there a way to push a docker image for this commit to docker hub so that I can test using it. I have an IPv6 only kubernetes environment I can deploy a milvus cluster into using the milvus operator and can test there.

If there isn't a workflow for that, would you guys be OK with approving this PR and merging it into master, with the changes and tests I'm confident this change isn't breaking for anyone and merging would allow me to use/test milvus in my environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-passed dco-passed DCO check passed. do-not-merge/missing-related-issue kind/feature Issues related to feature request from users size/M Denotes a PR that changes 30-99 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants