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.92k stars 1.95k forks source link

Support resolving other meta data variables inside the meta stanza #4255

Open aconte76 opened 6 years ago

aconte76 commented 6 years ago

Hi all, I've noticed that interpolation feature seems not working correctly on [meta stanza] but on application parameter: following job file example is very similar what normally is done for software parameters configuration. As suggestion perhaps could help to activate variables resolution also in meta stanza.

If filing a bug please include the following:

Nomad version

until 0.8.3

Operating system and Environment details

tested on linux darwin

Nomad Server logs

There are not particular logs

Nomad Client logs

There are not particular logs

Job file

 job "MY_JOB" {
    datacenters = ["dc1"]
    type = "batch"
    id = "MY_JOB"
    name = "MY_JOB"
    meta {
        RELEASE_VERSION = "2018.1.1.0"
        MY_HOME = "/opt/mysoftware-${NOMAD_META_RELEASE_VERSION}"
        MY_BIN = "${NOMAD_META_MY_HOME}/bin"
        MY_CFG = "${NOMAD_META_MY_HOME}/cfg"
        MY_EXECUTABLE = "${NOMAD_META_MY_BIN}/myExecutable" // could be an option
        MY_CFG_FILE = "${NOMAD_META_MY_CFG}/mySoftware.conf" // could be an option
    }

    group "MyGroup" {
        task "MyTask" {
            driver = "raw_exec"
            config = {
                command = "${NOMAD_META_MY_BIN}/myExecutable"
                args = [
                    "--notWorks", "${NOMAD_META_MY_CFG_FILE}",
                    "--thisWorks", "/opt/mysoftware-${NOMAD_META_RELEASE_VERSION}/cfg/mySoftware.conf"
                ]
            }
        }
    }
 } 
preetapan commented 6 years ago

@aconte76 Are you able to use your defined metadata as environment variables by reading them inside your executable? That should provide a way to get to them

aconte76 commented 6 years ago

@preetapan sure that I can but if you would like to simplify configuration with pure meta is possible to integrate better 3rdy part software mostly on lift&shift philosophy... It's also be read as a decoupling point from scheduler.

preetapan commented 6 years ago

@aconte76 Discussed with the team internally, and we concluded that it makes sense to support your use case. We would have to resolve them in order (i.e in order to use a variable declared in the meta stanza it would have to be defined before the one that needs it). We will add this to a future release.

Thanks for reporting this,

aconte76 commented 6 years ago

@preetapan sounds perfectly inline as a normal bourne shell already does! Thanks a lot