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

NOMAD_ALLOC_INDEX is 0 on all nodes when using system scheduler. #1851

Closed
siffiejoe opened this issue Oct 24, 2016 · 6 comments
Closed

NOMAD_ALLOC_INDEX is 0 on all nodes when using system scheduler. #1851

siffiejoe opened this issue Oct 24, 2016 · 6 comments

Comments

@siffiejoe
Copy link

siffiejoe commented Oct 24, 2016

Nomad version

Nomad v0.4.0

Operating system and Environment details

Linux host01 3.13.0-100-generic #147-Ubuntu SMP Tue Oct 18 16:48:51 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Issue

Two different nodes get the same allocation index (0) when using the system scheduler.

Reproduction steps

Create a nomad cluster of at least two nodes, copy the following script onto all nodes as /tmp/x.sh and run the job script below.

#!/bin/sh

while true; do
  echo "NOMAD_ALLOC_INDEX: $NOMAD_ALLOC_INDEX"
  sleep 1
done

All (both in my case) print the same allocation index (i.e. 0).

Job file (if appropriate)

job "xxx" {
    type = "system"

    datacenters = ["dc1"]

    task "x" {
    driver = "raw_exec"
    config {
        command = "/tmp/x.sh"
        args = []
    }
    resources {
        memory = 10
    }
    kill_timeout = 10s
    }
}
@dadgar
Copy link
Contributor

dadgar commented Nov 10, 2016

Hey,

This is currently the desired behavior. The allocation index is used to indicate the instance out of a desired count size. System jobs do not have an explicit count but are based more on the size of a the targeted cluster, making the index less informative.

I'm curious what you have in mind for the index. Further there is an associated cost with making it a monotonically increasing counter (need to store additional meta data) and I am not sure of the benefit.

@siffiejoe
Copy link
Author

I was trying to use the allocation index to get separate host names for each instance via consul. I need this because the service needs host names/addresses of all nodes that are going to be part of the cluster in advance (zookeeper is the culprit). I also want to wait until all instances are up before I start dependent services, and checking for zk-N.zookeeper.service.consul is an easy way to do that.

@jippi
Copy link
Contributor

jippi commented Nov 10, 2016

@siffiejoe I've been helping @smuthali with zookeeper as well, and he got something working out of that, perhaps drop by the gitter channel and give him a poke? :)

@dadgar
Copy link
Contributor

dadgar commented Nov 10, 2016

@siffiejoe I think you could accomplish that by using node.unique.id or node.unique.name.

I am going to close this issue as it is desired behavior. Hope you get the help you need from @jippi and @smuthali

Best,
Alex

@dadgar dadgar closed this as completed Nov 10, 2016
@jippi
Copy link
Contributor

jippi commented Nov 10, 2016

a hack is to have a docker entrypoint that echo ${NOMAD_ALLOC_INDEX} into the required file :)

@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 Dec 18, 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

3 participants