Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Improve error messages when remote addresses are bad #101

Closed
wants to merge 7 commits into from

Conversation

anacrolix
Copy link
Contributor

Improves the error message when there are no addresses because they're all filtered out, or none are given. Also the dial logic is simplified. Timing, and pseudo-random channel operations make optimistic selects unworthwhile.

@anacrolix anacrolix requested review from a user, bigs and raulk February 4, 2019 04:27
@ghost ghost assigned anacrolix Feb 4, 2019
@ghost ghost added the status/in-progress In progress label Feb 4, 2019
@anacrolix anacrolix force-pushed the dial-no-remote-addrs branch from 02574c4 to 2da188f Compare February 5, 2019 05:01
@anacrolix anacrolix force-pushed the dial-no-remote-addrs branch from 2da188f to e1d4fbb Compare February 19, 2019 09:29
@anacrolix
Copy link
Contributor Author

Fixes #69.

Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

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

I do not think this PR brings any improvement, and in fact it adds a superfluous goroutine and makes the code less readable by substituting a digestible loop with a dance of boolean flags, counters and unnecessary synchronisation because the whole thing has no reason to be multithreaded.

The original intention was based on wrong assumptions, that we clarified during conversation.

The title is also misleading, as it suggests we're only improving an error code, but in reality it attempts to sneak in a refactor of the dialling loop.

@anacrolix I think we're better off closing this PR – I'll let you do it. Please submit the error message improvement separately.

@anacrolix anacrolix force-pushed the dial-no-remote-addrs branch from e1d4fbb to 63776e0 Compare February 20, 2019 00:22
@anacrolix
Copy link
Contributor Author

I've refactored this back to the channel model, with the optimistic select. I need the more specific error messages as "default failure" is getting really old really quick and making debugging a pain.

Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

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

@anacrolix I don't like this mixture of functional and procedural (and the added indirection) just to shortcut 2-3 lines of code. To me, the value prop is not there, especially given that repetition in Go is idiomatic. I much rather read this linearly than seesawing up and down.

@raulk
Copy link
Member

raulk commented Feb 20, 2019

I suggest this PR sticks to introducing an exported error for when we have no remote addresses to dial.

@anacrolix
Copy link
Contributor Author

I'm on board with that error now, I'll add it.

@anacrolix
Copy link
Contributor Author

anacrolix commented Feb 21, 2019

@raulk This error, if exposed, belongs in go-libp2p-net, as a part of the Dialer and Network interfaces there.

@anacrolix
Copy link
Contributor Author

@anacrolix I don't like this mixture of functional and procedural (and the added indirection) just to shortcut 2-3 lines of code. To me, the value prop is not there, especially given that repetition in Go is idiomatic. I much rather read this linearly than seesawing up and down.

It's explicit about identical behaviour on different sets of communication clauses in the select. I think it's worth doing, especially with the extensive behaviour and comments in onDialResult. ctxDoneRetErr is there for symmetry. I don't want to bike-shed this part.

@anacrolix
Copy link
Contributor Author

This now requires libp2p/go-libp2p-net#38 to be merged.

@raulk
Copy link
Member

raulk commented Feb 27, 2019

@anacrolix

I don't want to bike-shed this part.

Isn't 90% of this PR a bike-shed of master?

First, would you mind making this PR stick to its title?

Second, you're proposing to introduce a personal stylistic preference on code that has been vetted by the community at large. As I explained above, IMO your change introduces extra bookkeeping variables, and makes it unreadable linearly. This is a critical part of the system where explicitness is appreciated. Optimistic selects are used largely in the codebase in their denormalised form. I also believe that, in Go, repetitiveness is OK and idiomatic. Moreover, the resulting block has no substantial reduction in LoC either, so by all accounts I really don't understand your insistence here.

To move forward, I propose to stop beating a dead horse. Can you close this PR and open a new one, just with the changes announced in the title, which are pretty non-controversial?

If you really want to push the closure stuff, open a separate PR just for that and try to get others to chime in; you already know where I stand ;-)

@anacrolix anacrolix closed this Mar 4, 2019
@ghost ghost removed the status/in-progress In progress label Mar 4, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants