Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

simulation: retry if we hit a collision on tcp/udp ports #1616

Merged
merged 2 commits into from
Jul 29, 2019

Conversation

nonsense
Copy link
Contributor

Due to setupListening in p2p/server.go it is possible to get a free TCP port, but for the OS to already be using the same UDP port. When that happens, Swarm crashes.

This PR is adding a retry mechanism to the simulation framework, so that when the OS gives us a TCP port, whose corresponding UDP is taken, we try to reboot the node.

func (srv *Server) setupListening() error {
	// Launch the TCP listener.
	listener, err := net.Listen("tcp", srv.ListenAddr)
	if err != nil {
		return err
	}
	laddr := listener.Addr().(*net.TCPAddr)
	srv.ListenAddr = laddr.String()

@nonsense nonsense requested review from janos and skylenet July 29, 2019 12:52
@nonsense nonsense force-pushed the exec-adapter-tcp-udp-fail branch from a282e78 to 3a38a61 Compare July 29, 2019 12:57
@nonsense nonsense force-pushed the exec-adapter-tcp-udp-fail branch from 3a38a61 to 2d0a023 Compare July 29, 2019 12:57
@nonsense
Copy link
Contributor Author

@janos this is only for Exec adapter, Docker or Kubernetes don't have this problem. The general issue is that we assume that if the OS gives us a TCP port that we can bind to, then the UDP port must also be free, which is def not the case on my laptop or on Travis.

@nonsense nonsense requested a review from acud July 29, 2019 13:06
acud
acud previously approved these changes Jul 29, 2019
@nonsense nonsense merged commit 496b08b into master Jul 29, 2019
@skylenet skylenet added this to the 0.5.0 milestone Sep 17, 2019
chadsr added a commit to chadsr/swarm that referenced this pull request Sep 23, 2019
* 'master' of github.com:ethersphere/swarm: (54 commits)
  api, chunk, cmd, shed, storage: add support for pinning content (ethersphere#1509)
  docs/swarm-guide: cleanup (ethersphere#1620)
  travis: split jobs into different stages (ethersphere#1615)
  simulation: retry if we hit a collision on tcp/udp ports (ethersphere#1616)
  api, chunk: rename Tag.New to Tag.Create (ethersphere#1614)
  pss: instrumentation and refactor (ethersphere#1580)
  api, cmd, network: add --disable-auto-connect flag (ethersphere#1576)
  changelog: fix typo (ethersphere#1605)
  version: update to v0.4.4 unstable (ethersphere#1603)
  swarm: release v0.4.3 (ethersphere#1602)
  network/retrieve: add bzz-retrieve protocol (ethersphere#1589)
  PoC: Network simulation framework (ethersphere#1555)
  network: structured output for kademlia table (ethersphere#1586)
  client: add bzz client, update smoke tests (ethersphere#1582)
  swarm-smoke: fix check max prox hosts for pull/push sync modes (ethersphere#1578)
  cmd/swarm: allow using a network interface by name for nat purposes (ethersphere#1557)
  pss: disable TestForwardBasic (ethersphere#1544)
  api, network: count chunk deliveries per peer (ethersphere#1534)
  network/newstream: new stream! protocol base implementation (ethersphere#1500)
  swarm: fix bzz_info.port when using dynamic port allocation (ethersphere#1537)
  ...
@nonsense nonsense deleted the exec-adapter-tcp-udp-fail branch September 30, 2019 10:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants