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

Job Version Diff Overcounts #7390

Open OneCricketeer opened 4 years ago

OneCricketeer commented 4 years ago

Nomad version

0.10.x (I think)

Operating system and Environment details

Ubuntu, maybe

Issue

Overcount of true diff in changes under Versions tab (shows 36)

Its not really clear how this number is counted, but if we look at the following, clearly the Network and dynamic ports didn't change at all, so why are they counted?

Similarly, only the embedded template of the vault stanza has changed, so why is the whole template object diffed?

+/- Job: "app-409ac948732813afc40693894cd3355933f3ce75"
+/- Stop:   "true" => "false"
+/- Task Group: "app-409ac948732813afc40693894cd3355933f3ce75"
+/- Task: "app-409ac948732813afc40693894cd3355933f3ce75"
+/- Env[DEPLOYMENT_ID]: "e105d4d7-199a-4619-9cc7-f58266a606c1" => "c3a15bbc-1f6e-4ca7-af2f-d67d5d062b67"
+/- Config {
image:  "app:409ac948732813afc40693894cd3355933f3ce75"
labels[0][COMPONENT_ID]:    "f9c1644e-5023-4048-9446-771bd22124ad"
labels[0][MPAAS_APPLICATION_NAME]:  "app"
labels[0][MPAAS_APPLICATION_VERSION]:   "409ac948732813afc40693894cd3355933f3ce75"
labels[0][MPAAS_CLUSTER]:   "cluster"
+/- labels[0][MPAAS_DEPLOYMENT_ID]: "e105d4d7-199a-4619-9cc7-f58266a606c1" => "c3a15bbc-1f6e-4ca7-af2f-d67d5d062b67"
labels[0][MPAAS_ENVIRONMENT]:   "e"
labels[0][MPAAS_ORGANIZATION]:  "o"
labels[0][MPAAS_REGION]:    "r"
labels[0][MPAAS_SCHEDULER]: "NOMAD"
port_map[0][port_10080_label]:  "10080"
port_map[0][port_8080_label]:   "8080"
port_map[0][port_9080_label]:   "9080"}
+/- Resources {
CPU:    "75"
DiskMB: "0"
IOPS:   "0"
MemoryMB:   "2048"
+ Network {
+ MBits:    "10"
Mode:   ""
+ Dynamic Port {
+ Label:    "port_10080_label"
+ To:   "0"}
+ Dynamic Port {
+ Label:    "port_8080_label"
+ To:   "0"}
+ Dynamic Port {
+ Label:    "port_9080_label"
+ To:   "0"}
}
- Network {
- MBits:    "10"
Mode:   ""
- Dynamic Port {
- Label:    "port_10080_label"
- To:   "0"}
- Dynamic Port {
- Label:    "port_8080_label"
- To:   "0"}
- Dynamic Port {
- Label:    "port_9080_label"
- To:   "0"}
}
}
+/- Service {
AddressMode:    "auto"
Name:   "app-test"
PortLabel:  "port_8080_label"
- Tags {
Tags:   "app"
Tags:   "env-test"
Tags:   "iid-app_test_409ac948732813afc40693894cd3355933f3ce75.${NOMAD_ALLOC_ID}"
- Tags: "live"
Tags:   "appname"
Tags:   "netscaler"
Tags:   "nomad"
Tags:   "app"
Tags:   "ver-409ac948732813afc40693894cd3355933f3ce75"}
}
+ Template {
+ ChangeMode:   "restart"
ChangeSignal:   ""
+ DestPath: "${NOMAD_SECRETS_DIR}/secrets.json"
+ EmbeddedTmpl: "{{- range secrets "/multipaas/metadata/test/app/" }} {{- with secret (printf "/multipaas/data/test/app/%s" .) }}{{ range $k, $v := .Data.data }} {{- scratch.MapSet "secrets" $k $v }} {{- end }}{{ end }}{{ end }} {{- scratch.Get "secrets" | explodeMap | toJSONPretty }}"
+ Envvars:  "false"
+ LeftDelim:    "{{"
+ Perms:    "0644"
+ RightDelim:   "}}"
SourcePath: ""
+ Splay:    "300000000000"
+ VaultGrace:   "15000000000"}
- Template {
- ChangeMode:   "restart"
ChangeSignal:   ""
- DestPath: "${NOMAD_SECRETS_DIR}/secrets.json"
- EmbeddedTmpl: "{{- with secret "/multipaas/data/test/app/secrets" -}} {{ .Data.data | toJSON }} {{- end -}} "
- Envvars:  "false"
- LeftDelim:    "{{"
- Perms:    "0644"
- RightDelim:   "}}"
SourcePath: ""
- Splay:    "300000000000"
- VaultGrace:   "15000000000"}

Reproduction steps

Deploy new job definition with only the vault template and deployment UUID changes

Job file (if appropriate)

{
  "Affinities": null,
  "AllAtOnce": false,
  "Constraints": [
    {
      "LTarget": "${node.class}",
      "Operand": "=",
      "RTarget": "general"
    },
    {
      "LTarget": "${attr.platform.aws.placement.availability-zone}",
      "Operand": "distinct_property",
      "RTarget": "1"
    }
  ],
  "CreateIndex": 80524,
  "Datacenters": [
    "dc-1",
    "dc-2"
  ],
  "Dispatched": false,
  "ID": "app-409ac948732813afc40693894cd3355933f3ce75",
  "JobModifyIndex": 81100,
  "Meta": null,
  "ModifyIndex": 81111,
  "Name": "app-409ac948732813afc40693894cd3355933f3ce75",
  "Namespace": "default",
  "ParameterizedJob": null,
  "ParentID": "",
  "Payload": null,
  "Periodic": null,
  "Priority": 50,
  "Region": "dc-2",
  "Spreads": null,
  "Stable": true,
  "Status": "running",
  "StatusDescription": "",
  "Stop": false,
  "SubmitTime": 1584687877299625500,
  "TaskGroups": [
    {
      "Affinities": null,
      "Constraints": [
        {
          "LTarget": "${attr.vault.version}",
          "Operand": "semver",
          "RTarget": ">= 0.6.1"
        },
        {
          "LTarget": "${attr.os.signals}",
          "Operand": "set_contains",
          "RTarget": "SIGHUP"
        }
      ],
      "Count": 1,
      "EphemeralDisk": {
        "Migrate": false,
        "SizeMB": 300,
        "Sticky": false
      },
      "Meta": null,
      "Migrate": {
        "HealthCheck": "checks",
        "HealthyDeadline": 300000000000,
        "MaxParallel": 1,
        "MinHealthyTime": 10000000000
      },
      "Name": "app-409ac948732813afc40693894cd3355933f3ce75",
      "Networks": null,
      "ReschedulePolicy": {
        "Attempts": 0,
        "Delay": 10000000000,
        "DelayFunction": "exponential",
        "Interval": 360000000000,
        "MaxDelay": 3600000000000,
        "Unlimited": true
      },
      "RestartPolicy": {
        "Attempts": 2,
        "Delay": 15000000000,
        "Interval": 1800000000000,
        "Mode": "fail"
      },
      "Services": null,
      "Spreads": null,
      "Tasks": [
        {
          "Affinities": null,
          "Artifacts": null,
          "Config": {
            "labels": [
              {
                "MPAAS_REGION": "r",
                "MPAAS_ENVIRONMENT": "TEST",
                "MPAAS_DEPLOYMENT_ID": "1e5a6e70-2554-42fb-9e4b-08a50949dbeb",
                "MPAAS_ORGANIZATION": "o",
                "MPAAS_APPLICATION_NAME": "app",
                "COMPONENT_ID": "f9c1644e-5023-4048-9446-771bd22124ad",
                "MPAAS_APPLICATION_VERSION": "409ac948732813afc40693894cd3355933f3ce75",
                "MPAAS_CLUSTER": "dc-2",
                "MPAAS_SCHEDULER": "NOMAD"
              }
            ],
            "image": "app:409ac948732813afc40693894cd3355933f3ce75",
            "port_map": [
              {
                "port_9080_label": 9080,
                "port_10080_label": 10080,
                "port_8080_label": 8080
              }
            ],
            "ulimit": []
          },
          "Constraints": null,
          "DispatchPayload": null,
          "Driver": "docker",
          "Env": {
            "APP_NAME": "app",
            "MPAAS_REGION": "r",
            "MPAAS_CLUSTER": "dc-2",
            "MPAAS_ORGANIZATION": "o",
            "EXPEDIA_ENVIRONMENT": "test",
            "RMI_PORT": "PORT3",
            "MPAAS_DEPLOYMENT_ID": "1e5a6e70-2554-42fb-9e4b-08a50949dbeb",
            "MPAAS_ENVIRONMENT": "test",
            "SVC_MEM": "1024m",
            "COMPONENT_ID": "f9c1644e-5023-4048-9446-771bd22124ad",
            "BLOCK_ON_SECRETS": "true",
            "MPAAS_APPLICATION_NAME": "app",
            "MPAAS_APPLICATION_VERSION": "409ac948732813afc40693894cd3355933f3ce75",
            "MPAAS_SCHEDULER": "NOMAD"
          },
          "KillSignal": "",
          "KillTimeout": 5000000000,
          "Kind": "",
          "Leader": false,
          "LogConfig": {
            "MaxFileSizeMB": 15,
            "MaxFiles": 10
          },
          "Meta": null,
          "Name": "app-409ac948732813afc40693894cd3355933f3ce75",
          "Resources": {
            "CPU": 75,
            "Devices": null,
            "DiskMB": 0,
            "IOPS": 0,
            "MemoryMB": 2048,
            "Networks": [
              {
                "CIDR": "",
                "Device": "",
                "DynamicPorts": [
                  {
                    "Label": "port_8080_label",
                    "To": 0,
                    "Value": 0
                  },
                  {
                    "Label": "port_9080_label",
                    "To": 0,
                    "Value": 0
                  },
                  {
                    "Label": "port_10080_label",
                    "To": 0,
                    "Value": 0
                  }
                ],
                "IP": "",
                "MBits": 10,
                "Mode": "",
                "ReservedPorts": null
              }
            ]
          },
          "Services": [
            {
              "AddressMode": "auto",
              "CanaryTags": null,
              "Checks": [
                {
                  "AddressMode": "",
                  "Args": null,
                  "CheckRestart": {
                    "Grace": 300000000000,
                    "IgnoreWarnings": true,
                    "Limit": 3
                  },
                  "Command": "",
                  "GRPCService": "",
                  "GRPCUseTLS": false,
                  "Header": null,
                  "InitialStatus": "",
                  "Interval": 10000000000,
                  "Method": "",
                  "Name": "service: \"app-test\" check",
                  "Path": "/isActive",
                  "PortLabel": "port_8080_label",
                  "Protocol": "",
                  "TLSSkipVerify": false,
                  "TaskName": "",
                  "Timeout": 10000000000,
                  "Type": "http"
                }
              ],
              "Connect": null,
              "Meta": null,
              "Name": "app-test",
              "PortLabel": "port_8080_label",
              "Tags": [
                "nomad",
                "netscaler",
                "iid-app_test_409ac948732813afc40693894cd3355933f3ce75.${NOMAD_ALLOC_ID}",
                "env-test",
                "app-app",
                "ver-409ac948732813afc40693894cd3355933f3ce75",
                "live",
                "app",
                "appname"
              ]
            }
          ],
          "ShutdownDelay": 0,
          "Templates": [
            {
              "ChangeMode": "restart",
              "ChangeSignal": "",
              "DestPath": "${NOMAD_SECRETS_DIR}/secrets.json",
              "EmbeddedTmpl": "{{- range secrets \"/multipaas/metadata/test/app/\" }}\n{{- with secret (printf \"/multipaas/data/test/app/%s\" .) }}{{ range $k, $v := .Data.data }}\n{{- scratch.MapSet \"secrets\" $k $v }}\n{{- end }}{{ end }}{{ end }}\n{{- scratch.Get \"secrets\" | explodeMap | toJSONPretty }}",
              "Envvars": false,
              "LeftDelim": "{{",
              "Perms": "0644",
              "RightDelim": "}}",
              "SourcePath": "",
              "Splay": 300000000000,
              "VaultGrace": 15000000000
            }
          ],
          "User": "",
          "Vault": {
            "ChangeMode": "signal",
            "ChangeSignal": "SIGHUP",
            "Env": false,
            "Policies": [
              "multipaas/test/app"
            ]
          },
          "VolumeMounts": null
        }
      ],
      "Update": {
        "AutoPromote": false,
        "AutoRevert": false,
        "Canary": 0,
        "HealthCheck": "checks",
        "HealthyDeadline": 180000000000,
        "MaxParallel": 1,
        "MinHealthyTime": 10000000000,
        "ProgressDeadline": 600000000000,
        "Stagger": 30000000000
      },
      "Volumes": null
    }
  ],
  "Type": "service",
  "Update": {
    "AutoPromote": false,
    "AutoRevert": false,
    "Canary": 0,
    "HealthCheck": "",
    "HealthyDeadline": 0,
    "MaxParallel": 1,
    "MinHealthyTime": 0,
    "ProgressDeadline": 0,
    "Stagger": 30000000000
  },
  "VaultToken": "",
  "Version": 5
}
notnoop commented 4 years ago

Thanks for reporting the issue. It looks like the library we use for diffing structure was a bit more aggressive in marking structs as diff.