nerdalert / nflow-generator

NetFlow Generator for Testing Flow Collection Apps
Apache License 2.0
107 stars 46 forks source link

[enhancement] retry on DNS or connection failures #4

Open jguay opened 5 years ago

jguay commented 5 years ago

Current behaviour When I connect to a container which may be down or not yet started, I hit error like this one

nflow0                     | time="2019-03-15T10:32:45Z" level=fatal msg="Error connecting to the target collector: write udp 172.18.0.5:40304->172.18.0.6:2055: write: connection refused"

Cause It seems a connection error is considered fatal here

Same point about DNS problem a few lines above which is also considered fatal

Requested feature It would be great if any connection error was just displayed and the connection would just be retried after 10 seconds so the nflow-generator container just keeps trying instead of failing

Workaround If I just set a restart policy for the container, or some script which would delay entrypoint till the destination host/port is reachable, I will be able to get around it but would prefer if the code just retry, never coded in go but could probably make a PR for this as change may be trivial