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

Support ChooseHostInterface on Mac OS X #5497

Closed
wants to merge 4 commits into from

Conversation

sub-mod
Copy link
Contributor

@sub-mod sub-mod commented Mar 16, 2015

@thockin fixed the public method issue , @brendanburns also support for mac where route file is not present.

kindly review

inFile, err := os.Open("/proc/net/route")
if err != nil {
if os.IsNotExist(err) {
return chooseHostInterfaceNativeGo()
return chooseHostInterfaceNativeGo(nw)
Copy link
Member

Choose a reason for hiding this comment

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

log this happening - it's important in prod

@thockin thockin assigned ghost and unassigned thockin Mar 18, 2015
@ghost
Copy link

ghost commented Mar 18, 2015

I think that we want unit tests to explicitly use 127.0.0.1 (as per your PR 5400) and for ChooseHostInterface to do precisely the correct thing on a given platform (e.g. based on /proc/net/route on linux, perhaps netstat -nr on Mac OS X, route print on Windows, etc), or panic (on unsupported platforms). ChooseHostInterfaceNativeGo() is simply nor reliable enough on any platform, and should be deleted.

Ultimately we need to implement a different version of ChooseHostInterface() for each supported platform, correct in each case, using arch-specific compilation. You could either do this now while it's fresh in your mind, or defer until later, as it doesn't appear that we need the functionality yet, given that the specific testing problem is resolved by PR 5400.

@ghost
Copy link

ghost commented Mar 18, 2015

PS: To be clear, the overall goal of the above suggestion is to make sure that unreliable code like ChooseHostInterfaceNativeGo() does not accidentally leak from testing code into production code.

@thockin
Copy link
Member

thockin commented Mar 18, 2015

I think I agree - if I had been paying attention I would have argued
strongly against ever bringing back chooseHostInterfaceNativeGo() at all.

I think that any test which calls ChooseHostInterface() is already doomed.

I think that ChooseHostinterface is a linux-specific thing that we should
probably bust out into a _linux.go file and a _unsupported.go file, but I
don't think that should be needed for tests to pass. Sadly, there is
(AFAIK) no way to have a build tag that is "only for tests"

On Wed, Mar 18, 2015 at 3:20 PM, Quinton Hoole notifications@github.com
wrote:

PS: To be clear, the overall goal of the above suggestion is to make sure
that unreliable code like ChooseHostInterfaceNativeGo() does not
accidentally leak from testing code into production code.


Reply to this email directly or view it on GitHub
#5497 (comment)
.

@brendandburns
Copy link
Contributor

Closing this as it is unmergeable and hasn't been worked on in > 30 days.

Please re-open with fresh changes if the PR is still relevant.

@ghost
Copy link

ghost commented Apr 22, 2015

Ack - I'll open a separate PR to remove ChooseHostInterfaceNativeGo()

@ghost ghost mentioned this pull request Apr 22, 2015
@smarterclayton
Copy link
Contributor

ChooseHostInterface can choose an IPv6 only address in some cases, which we don't handle. I'm going to spawn a separate issue, but we're still busted in some cases.

@smarterclayton
Copy link
Contributor

Spawned #7716

@sub-mod sub-mod unassigned ghost Aug 12, 2015
@dims
Copy link
Member

dims commented Jun 10, 2016

@smarterclayton @quinton-hoole Since #7721 has merged Do we still need to do something here?

@smarterclayton
Copy link
Contributor

No.

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