jrxFive/python-nomad

plan_job does not use the diff flag correctly

jeteon opened this issue · 1 comments

According to the docs the Nomad API expects a Diff parameter to be optionally supplied in the payload of the request like so:

{
  "Job": "...",
  "Diff": true,
  "PolicyOverride": false
}

However the code adds this as a parameter on the URL instead:

def plan_job(self, id, job, diff=False):
""" Invoke a dry-run of the scheduler for the job.
https://www.nomadproject.io/docs/http/job.html
arguments:
- id
- job, dict
- diff, optional boolean
returns: dict
raises:
- nomad.api.exceptions.BaseNomadException
- nomad.api.exceptions.URLNotFoundNomadException
"""
return self._post(id, "plan", json_dict=job, params={"diff": diff})

This results in you not being able to actually request a diff on a plan by calling nomad.job_plan(id, job, diff=True) since it is not put into the body and thus ignored by the Nomad server.

Merged in #61