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.77k stars 1.94k forks source link

UI job editor puts list variables into quotes which causes invalid `input.hcl` file structure #23732

Closed Davasny closed 1 month ago

Davasny commented 1 month ago

Nomad version

Output from nomad version

Nomad v1.8.2
BuildDate 2024-07-16T08:50:09Z
Revision 7f0822c1e4f25907d9f60e2d595411950dd1bd28

Operating system and Environment details

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

Issue

UI job editor puts list variables into quotes which causes invalid input.hcl file structure

Reproduction steps

  1. Run provided jobspec using cli
nomad job run -var='tags=["aa"]' test-redis.nomad
  1. Go to deployed service via nomad ui

  2. Go to definition, edit, try to plan without any change

  3. You will see exception

Failed to parse job: unable to parse var content: input.hcl:1,9-11: Missing newline after argument; An argument definition must end with a newline.

image

Expected Result

Job should be planned without exception

UI should not put list variable value into quotes. Changing value by hand will result in accepted plan

- tags="["aa"]"
+ tags=["aa"]

Actual Result

Failed to parse job: unable to parse var content: input.hcl:1,9-11: Missing newline after argument; An argument definition must end with a newline.

Job file (if appropriate)

variable "tags" {
  type = list(string)
}

job "test-redis" {
  datacenters = [
    "*"
  ]
  type = "service"

  group "redis" {
    count = 1

    task "redis" {
      driver = "docker"

      config {
        image = "redis"
        ports = ["redis"]
      }
    }

    network {
      port "redis" {
        to = 6379
      }
    }

    service {
      name = "test-redis"
      port = "redis"
      tags = var.tags
    }
  }
}

Nomad Server logs (if appropriate)

Nomad Client logs (if appropriate)

tgross commented 1 month ago

Hi @Davasny! I don't think the UI does any parsing of the HCL which is maybe why it's not identifying the variables type correctly. I'll mark this for further investigation.

the-nando commented 1 month ago

@tgross I think this is a duplicate of the issue we've discussed here: https://github.com/hashicorp/nomad/issues/23462

tgross commented 1 month ago

Good catch, thanks @the-nando! I'm going to close this as a duplicate, but ping @philrenaud so he sees the additional context here.