@@ -337,24 +337,31 @@ func getMyceliumPeers() ([]string, error) {
337337		mycInterface  =  publicInterfaceName 
338338	}
339339
340+ 	log .Debug ().Str ("namespace" , mycNamespace ).Str ("interface" , mycInterface ).Msg ("get mycelium peers from" )
341+ 
340342	var  ips  []net.IPNet 
341343	bo  :=  backoff .NewExponentialBackOff ()
342344	bo .MaxElapsedTime  =  time .Minute 
343345	bo .MaxInterval  =  10  *  time .Second 
344346
345- 	err  :=  backoff . Retry ( func () error  {
346- 		ips , err  :=  baseifaceutil .GetIPsForIFace (mycInterface , mycNamespace )
347+ 	op  :=  func () error  {
348+ 		r , err  :=  baseifaceutil .GetIPsForIFace (mycInterface , mycNamespace )
347349		if  err  !=  nil  {
348- 			return  backoff . Permanent ( errors .Wrap (err , "failed to get IPs" ) )
350+ 			return  errors .Wrap (err , "failed to get IPs" )
349351		}
350- 		if  len (ips ) ==  0  {
352+ 		if  len (r ) ==  0  {
351353			return  fmt .Errorf ("no IPs available yet" )
352354		}
355+ 		ips  =  r  // only set if success 
353356		return  nil 
354- 	}, bo )
357+ 	}
358+ 
359+ 	notify  :=  func (err  error , d  time.Duration ) {
360+ 		log .Debug ().Err (err ).Dur ("wait" , d ).Msg ("retrying to get mycelium IPs" )
361+ 	}
355362
356363	var  hostPeers  []string 
357- 	if  err  !=  nil  {
364+ 	if  err  :=   backoff . RetryNotify ( op ,  bo ,  notify );  err   !=  nil  {
358365		log .Warn ().Msg ("failed to get IPs after 1 minute, falling back to public mycelium peers" )
359366		peers , err  :=  mycelium .FindPeers (context .Background (), nil )
360367		if  err  !=  nil  {
@@ -365,6 +372,7 @@ func getMyceliumPeers() ([]string, error) {
365372		hostPeers  =  baseifaceutil .BuildMyceliumPeerURLs (ips )
366373	}
367374
375+ 	log .Debug ().Str ("peers" , fmt .Sprintf ("%v" , hostPeers )).Msg ("mycelium peers discovered" )
368376	return  hostPeers , nil 
369377}
370378
0 commit comments