Nomad: plan's diff output does not sort arrays numerically

Created on 15 Jun 2018  路  3Comments  路  Source: hashicorp/nomad

Nomad version

Nomad v0.8.3 (c85483da3471f4bd3a7c3de112e95f551071769f)

Operating system and Environment details

OS X, though likely n/a

Issue

The plan diff output lists the args[] changes, but is not sorted numerically. As a user, I'd expect an array to be sorted numerically by index.

+/- Task Group: "fabio" (2 create)
  +/- Task: "lb" (forces create/destroy update)
    +/- Config {
          args[0]:                                     "/fabio"
      +/- args[10]:                                    "-proxy.addr" => ":50560;proto=tcp"
      +/- args[11]:                                    ":9021;proto=tcp" => "-proxy.addr"
      +/- args[12]:                                    "-proxy.addr" => ":9021;proto=tcp"
      +/- args[13]:                                    ":49300;proto=tcp" => "-proxy.addr"
      +/- args[14]:                                    "-proxy.addr" => ":49300;proto=tcp"
      +/- args[15]:                                    ":50850;proto=tcp" => "-proxy.addr"
      +/- args[16]:                                    "-proxy.addr" => ":50850;proto=tcp"
      +/- args[17]:                                    ":52240;proto=tcp" => "-proxy.addr"
      +/- args[18]:                                    "-proxy.addr" => ":52240;proto=tcp"
      +/- args[19]:                                    ":50360;proto=tcp" => "-proxy.addr"
          args[1]:                                     "-registry.consul.addr=consul:8500"
      +/- args[20]:                                    "-proxy.addr" => ":50360;proto=tcp"
      +/- args[21]:                                    ":50880;proto=tcp" => "-proxy.addr"
      +/- args[22]:                                    "-proxy.addr" => ":50880;proto=tcp"
      +/- args[23]:                                    ":52760;proto=tcp" => "-proxy.addr"
      +/- args[24]:                                    "-proxy.addr" => ":52760;proto=tcp"
      +/- args[25]:                                    ":9010;proto=tcp" => "-proxy.addr"
      +/- args[26]:                                    "-proxy.addr" => ":9010;proto=tcp"
      +/- args[27]:                                    ":50110;proto=tcp" => "-proxy.addr"
      +/- args[28]:                                    "-proxy.addr" => ":50110;proto=tcp"
      +/- args[29]:                                    ":52100;proto=tcp" => "-proxy.addr"
          args[2]:                                     "-registry.consul.register.enabled=false"
      +/- args[30]:                                    "-proxy.addr" => ":52100;proto=tcp"
      +/- args[31]:                                    ":52810;proto=tcp" => "-proxy.addr"
      +/- args[32]:                                    "-proxy.addr" => ":52810;proto=tcp"
      +/- args[33]:                                    ":52410;proto=tcp" => "-proxy.addr"
      +/- args[34]:                                    "-proxy.addr" => ":52410;proto=tcp"

Reproduction steps

Change Task arguments in a arg list that exceeds 10 arguments.

themcli themplan typbug

Most helpful comment

Confirmed and can be reproduced by running nomad plan -verbose foo.nomad on any job file with 10 or more args:

job "echo" {
  type = "batch"
  datacenters = ["dc1"]
  group "echo" {
    task "echo" {
      driver = "raw_exec"

      config {
        command = "/bin/sh"
        args    = ["-c", "echo x", "", "", "", "", "", "", "", "", "", ""]
      }
    }
  }
}

Output snippet:

+ Config {
      + args[0]:  "-c"
        args[10]: ""
        args[11]: ""

All 3 comments

Confirmed and can be reproduced by running nomad plan -verbose foo.nomad on any job file with 10 or more args:

job "echo" {
  type = "batch"
  datacenters = ["dc1"]
  group "echo" {
    task "echo" {
      driver = "raw_exec"

      config {
        command = "/bin/sh"
        args    = ["-c", "echo x", "", "", "", "", "", "", "", "", "", ""]
      }
    }
  }
}

Output snippet:

+ Config {
      + args[0]:  "-c"
        args[10]: ""
        args[11]: ""

Thank you for providing a test case @schmichael. I was feeling pretty lazy at the time and didn't want to figure out how to make a minimal job spec. :frowning:

No worries @dekimsey -- your report was great! As a tip though nomad init -short is a great way to get a smaller sample job file without the tons of comments of the standard nomad init output. #4239

Was this page helpful?
0 / 5 - 0 ratings