Add toggleable hostname flag to HTTP responses
To better support multi-pod deployments, we should add a call to our response chain that adds the pod's hostname to a response header when enabled (by default this should be disabled). This can be done through a call to the host machine, with the exec
answer from this SO answer being the most stable mechanism in our case. While this won't work on Windows, that doesn't really matter since the only time this will matter is in Unix environments.
Regarding the command to use, it looks like in our pods the safest command is likely uname -n
rather than hostname
as not all unix instances have access to the hostname
shortcut. We should cache this once and reference and reuse the cached answer as this will never change in the runtime of a server, and we should reduce native system calls where possible.
I think a good name for the header could be x-node-name
, as the value we're pulling is the node hostname of the server rather than an ID of any kind.