Clarify the registration error message
The issue was found by @marcin during 1.16.0 sanity checks: Source.
I installed the Stork agent and set the .env file to point to the server. I mistyped the server URL and the agent failed to register but gave me no indication that the URL is wrong and the connection was refused. That's because of this part of the code:
// If connection is refused and retries are enabled than wait for 10 seconds
// and try again. This method is used in case of agent token based registration
// to allow smooth automated registration even if server is down for some time.
// In case of server token based registration this method is invoked manually so
// it should fail immediately if there is no connection to the server.
if retry && strings.Contains(err.Error(), "connection refused") {
log.Println("Sleeping for 10 seconds before next registration attempt")
time.Sleep(10 * time.Second)
} else {
return 0, nil, nil, [32]byte{}, errors.Wrapf(err, "problem registering machine")
}
I'd rather want to see something about connection refused because I'd know that the address is wrong.