Skip to content

Commit b7fdb7f

Browse files
committed
fix: error out early if grpc address doesn't have a port
For nearly all users, the port needs to be specified and needs to be `443`. If skipped, GRPC will fall back to a different port that may not respond to SYN TCP segments. As a result, the agent process will just hang without logging anything. This change causes the agent to error out if the port is omitted, which allegedly should provide earlier feedback about this and other common mistakes.
1 parent 247e054 commit b7fdb7f

File tree

1 file changed

+6
-0
lines changed
  • cmd/synthetic-monitoring-agent

1 file changed

+6
-0
lines changed

cmd/synthetic-monitoring-agent/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ func run(args []string, stdout io.Writer) error {
144144
}
145145
}
146146

147+
if _, _, err := net.SplitHostPort(config.GrpcApiServerAddr); err != nil {
148+
// SplitHostPort errors if the address has no port. This is intended, as omitting the port in the address is
149+
// almost likely a user error that is hard to troubleshoot otherwise.
150+
return fmt.Errorf("parsing GRPC api server address %q: %w", config.GrpcApiServerAddr, err)
151+
}
152+
147153
// If the token is provided on the command line, prefer that. Otherwise
148154
// pull it from the environment variable SM_AGENT_API_TOKEN. If that's
149155
// not available, fallback to API_TOKEN, which was the environment

0 commit comments

Comments
 (0)