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

Duplicated index in allocation name #6829

Closed
pznamensky opened this issue Dec 10, 2019 · 5 comments
Closed

Duplicated index in allocation name #6829

pznamensky opened this issue Dec 10, 2019 · 5 comments

Comments

@pznamensky
Copy link

Nomad version

Nomad v0.9.4 (a81aa84)

Operating system and Environment details

CentOS Linux release 7.7.1908 (Core)
docker-ce-18.03.1

Issue

Similar to #3698
After updating a nomad job some allocations got the same name.

nomad-bm alloc -json | jq '.[] | .Name + " - " + .TaskStates[].State' | grep app | sort | uniq -c
      1 "app.app[0] - running"
      1 "app.app[10] - running"
      1 "app.app[11] - running"
      2 "app.app[1] - running" // duplicate name
      1 "app.app[2] - running"
      2 "app.app[3] - running" // duplicate name
      1 "app.app[4] - running"
      2 "app.app[5] - running" // duplicate name
      1 "app.app[6] - running"
      2 "app.app[7] - running" // duplicate name
      1 "app.app[8] - running"
      1 "app.app[9] - running"

Reproduction steps

  1. create a job
  2. make changes in nomad file
  3. run nomad run with that changes
  4. check allocation names

Job file (if appropriate)

job "app" {
  datacenters = ["dc1"]
  type = "service"

  update {
    max_parallel = 2
    min_healthy_time = "10s"
    healthy_deadline = "3m"
    canary = 12
    auto_promote = true
  }
  group "app" {
    count = 16
    restart {
      attempts = 10
      interval = "5m"
      delay = "20s"
      mode = "delay"
    }
    task "app" {
      driver = "docker"
      config {
        image = "app:master"
      }
      resources {
        network {
          port "http" {}
        }
      }
      service {
        name = "app"
        port = "http"
        check {
          type     = "tcp"
          interval = "10s"
          timeout  = "5s"
        }
      }
    }
  }
}
@tgross
Copy link
Member

tgross commented Dec 10, 2019

Hi @pznamensky! The allocation indexes aren't guaranteed to be unique. The servers make a best-effort attempt to make this value unique from 0 to count-1 but when you have canaries on the task group, there are reused indexes since you have multiple job versions running at the same time.

If you need a unique number for interpolating a value in your application, you can get this by combining the job version and the alloc index (which together should be unique).

@tgross
Copy link
Member

tgross commented Dec 10, 2019

I'm going to close this issue as a duplicate of #5879.

@pznamensky
Copy link
Author

@tgross thanks for the explanation!

@pznamensky
Copy link
Author

@tgross, sorry for coming back to it, but what is the purpose of ALLOC INDEX? Since there is no guarantees it is unique, probably it would be reasonable to delete it at all. What do you think?

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants