Agent registration using the server token is broken
The issue was originally reported on our mailing list.
When the server token is used to register, the registration process ends with the Stork agent being pinged by the Stork server. If the agent doesn't respond to ping, an error message is produced.
The ping command is sent over the GRPC protocol. The agent must listen to the GRPC endpoint to handle it. However, if the agent is not registered, the GRPC credentials are missing. From Stork 1.17, the Stork agent validates the GRPC credentials on startup and rejects to start if they are missing and the self-registration flow is not used. This causes Stork to be unable to run during registration with the server token, so it cannot respond to the ping command. The ping command always fails.
The good news is that the GRPC credentials are created before the ping command is sent, so they exist even if the ping fails. The other good news is it doesn't affect the self-registration flow.
We need to re-design how the ping command is handled. To handle the ping request, we should probably start a temporary GRPC listener during registration.