Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version tag HTTP API doesn't tag latest version (docs+api inaccurate) #24266

Open
maxramqvist opened this issue Oct 21, 2024 · 4 comments
Open
Assignees
Labels

Comments

@maxramqvist
Copy link

Nomad version

Nomad v1.9.1 BuildDate 2024-10-21T09:00:50Z Revision d9ec23f0c1035401e9df6c64d6ffb8bffc555a5e

With ACLs enabled and using Nomad namespaces.

Operating system and Environment details

Ubuntu 22.04, kernel 6.9.3 on x86_64

Issue

According to the docs:

Optionally, you can also supply a tag description and a version number. If you do not supply a version number, Nomad tags the latest version.

If I don't supply the version number the oldest version gets tagged instead of the latest version.

Reproduction steps

  1. Nomad doesn't tag the latest version. The version must be specified in the POST body for the tagging to work.
curl -H "x-nomad-token: $NOMAD_TOKEN" http://localhost:4646/v1/job/test-service/versions/vLatest/tag\?namespace\=mynamespace -X POST -d '{}'  
{"Name":"vLatest","Description":"","TaggedTime":1729537471780368140,"Index":232,"LastContact":0,"KnownLeader":false,"NextToken":""}

image

Adding Version to the body tags the version intended.
curl -H "x-nomad-token: $NOMAD_TOKEN" http://localhost:4646/v1/job/test-service/versions/vActualLatest/tag\?namespace\=mynamespace -X POST -d '{"Version": 3}' Results in:
{"Name":"vActualLatest","Description":"","TaggedTime":1729537656801230518,"Index":270,"LastContact":0,"KnownLeader":false,"NextToken":""}
Results in the desired version getting tagged:
image

  1. An empty body isn't accepted, but a body with an empty JSON object {} is accepted. No biggie really, just not obvious that its required.

curl -X POST -H "x-nomad-token: $NOMAD_TOKEN" http://localhost:4646/v1/job/test-service/versions/v3/tag\?namespace\=mynamespace results in the response: Request body is empty.
Specifying an empty JSON as request body works:
curl -H "x-nomad-token: $NOMAD_TOKEN" http://localhost:4646/v1/job/test-service/versions/v3/tag\?namespace\=mynamespace -X POST -d '{}', response: ``{"Name":"v3","Description":"","TaggedTime":1729537150671061477,"Index":186,"LastContact":0,"KnownLeader":false,"NextToken":""}

Expected Result

I could create a tag on the latest version of a job without specifying the exact version of the job, as the docs say.

Actual Result

The first version, number 0, gets tagged if I don't specify the exact version I want to tag.

@philrenaud philrenaud self-assigned this Oct 21, 2024
@maxramqvist
Copy link
Author

Another issue is that diffs doesn't work in the UI. As you can see in the screenshots, the web ui shows "No changes" - but I've made changes to a few different things in the job. Meta, Docker configuration (labels, image) and some Consul tags.

Using the "Diff against"-button results in that button changing and the url changing but nothing else.
I checked the browsers dev tools aswell, no requests get sent when using that button.

Can confirm it both happens on when running Nomad in dev mode and proper production mode with a server cluster and separate clients.

Perhaps I should post a separate issue?

@maxramqvist maxramqvist changed the title Version tag HTTP API doesn't tag latest version (docs inaccurate) Version tag HTTP API doesn't tag latest version (docs+api inaccurate) Oct 22, 2024
@philrenaud
Copy link
Contributor

Yes, I'd appreciate a second issue for that one — should definitely be showing you diffs between job versions. For a minimum reproduction, could you try modifying a task group's count value to see if that shows up in the diff?

@maxramqvist
Copy link
Author

Yep, I'll post a proper issue for that tomorrow. Can confirm no diffs are shown when just changing count.

Thanks in the meantime. Nomad really is a great product!

@philrenaud
Copy link
Contributor

Thanks for saying so!

And regarding the original issue:

  • we'll change the documentation here; during development, we had a "if version is not supplied, assume latest" convenience rule at HTTP API level, but ended up moving it to the CLI layer. Why? Internally, we reasoned that CLI version tagging was prone to be a lot more manual and one-shot than doing it via the API, where perf matters more and we might assume that the user has access to the latest version of the job in question (which comes back with a standard job request).
  • If the version is not included in the POST body, we actually try for version 0. If you have more versions than agent.server.job_tracked_versions (defaults to 6), you actually get a job "jobname" version 0 not found error, which is not what we intended. I think if it's not provided, we'll throw an error here.`

So that's two upcoming changes: one to clarify in the docs that latest-version is only presumed for CLI requests, and another to throw an error when a version is not supplied to the HTTP API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

2 participants