hashicorp / nomad

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
https://www.nomadproject.io/
Other
14.94k stars 1.96k forks source link

cli: `service info` command returns incorrect services in output #19542

Open jrasell opened 11 months ago

jrasell commented 11 months ago

Nomad version

$ nomad version
Nomad v1.7.3-dev
BuildDate 2023-12-19T11:17:48Z
Revision b2f640346d7609057ab55a0037c23ad5f5edfb68

Issue

The service info command returns incorrect results when attempting to perform a simple service lookup within a particular namespace.

The list output correctly lists two services registered:

$ nomad service list
Service Name       Tags
grafana-server     []
prometheus-server  []

When I go to lookup the grafana-server service I get the following result:

$ nomad service info grafana-server
Job ID             Address               Tags  Node ID   Alloc ID
prometheus-server  192.168.108.13:24057  []    fc18ed18  04499ded

The API is returning the correct data, so this is a problem with the command.

$ nomad operator api /v1/service/grafana-server | jq
[
  {
    "Address": "192.168.108.13",
    "AllocID": "8fe15d39-cd9d-cbdb-ca31-d795b4f4ca78",
    "CreateIndex": 188,
    "Datacenter": "kent",
    "ID": "_nomad-task-8fe15d39-cd9d-cbdb-ca31-d795b4f4ca78-group-server-grafana-server-grafana",
    "JobID": "grafana-server",
    "ModifyIndex": 188,
    "Namespace": "default",
    "NodeID": "fc18ed18-d4ef-115c-17f5-43e4e48c37a8",
    "Port": 22138,
    "ServiceName": "grafana-server",
    "Tags": []
  }
]

It seems the bug was introduced within https://github.com/hashicorp/nomad/pull/18836

blmhemu commented 11 months ago

I can see this in 1.7.2 as well. The nomad templates are also quite messed up similar to https://github.com/hashicorp/nomad/issues/16616

jrasell commented 10 months ago

Hi @blmhemu; as far as this stated issue goes, it only affects the CLI and the linked issue is a separate, non-related bug.

blmhemu commented 10 months ago

I understand, but i could not repro #16616 on 1.6, only on 1.7.(2) (Let me know if I should raise another issue)

Also, I assumed templates use the data published by the API and if the API provides wrong info, may be the templates are rendedered with wrong info.

Pondidum commented 9 months ago

Seeing this with the 1.7.5 CLI too:

Nomad v1.7.5
BuildDate 2024-02-13T15:10:13Z
Revision 5f5d4646198d09b8f4f6cb90fb5d50b53fa328b8
> nomad service list
Service Name    Tags
caddy           [ingress]
noutaja         []
otel-collector  [otel]
> nomad service info otel-collector
Job ID  Address            Tags       Node ID   Alloc ID
caddy   192.168.1.128:443  [ingress]  06289a2e  c7c2a24f
> nomad service info otel-collector
Job ID   Address             Tags  Node ID   Alloc ID
noutaja  192.168.1.128:5959  []    06289a2e  8b8d5f7b
geekodour commented 6 months ago

Still relevant^, had me wondering where did I go wrong. @jrasell are you working on this? otherwise I think I can pick this up?

msherman13 commented 6 months ago

+1 on this, it's a bad issue that seems to have been included in one of the recent releases. breaks our workflow...

dpogorzelski commented 4 months ago

Still present in 1.8.1, just ran into this