A trailing slash in the NOMAD_ADDR environment variable may lead to failing API requests with the message
nomad.api.exceptions.BaseNomadException: The BaseNomadException was raised with following response: Invalid method.
This happend to us using the nomad.api.jobs.Jobs.parse method with makes a call to the parse endpoint (https://www.nomadproject.io/api/jobs#parse-job) via POST. If the NOMAD_ADDR ends with a slash, the server first issues a 301 redirect and the following request would downgrade to GET and thus fail.
While the proper fix would be for the Nomad API to issue a 307 instead of a 301 (which retains method and body), the python-nomad library can easily account for that mistake by automatically stripping a trailing slash (e.g. with (os.getenv('NOMAD_ADDR', '').rstrip('/') or None in nomad.Nomad.__init__.
A trailing slash in the
NOMAD_ADDR
environment variable may lead to failing API requests with the messagenomad.api.exceptions.BaseNomadException: The BaseNomadException was raised with following response: Invalid method.
This happend to us using the
nomad.api.jobs.Jobs.parse
method with makes a call to the parse endpoint (https://www.nomadproject.io/api/jobs#parse-job) viaPOST
. If theNOMAD_ADDR
ends with a slash, the server first issues a 301 redirect and the following request would downgrade toGET
and thus fail.While the proper fix would be for the Nomad API to issue a 307 instead of a 301 (which retains method and body), the
python-nomad
library can easily account for that mistake by automatically stripping a trailing slash (e.g. with(os.getenv('NOMAD_ADDR', '').rstrip('/') or None
innomad.Nomad.__init__
.