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

Golang API reports Artifact Headers are an invalid key #14657

Closed
jimrazmus opened this issue Sep 22, 2022 · 2 comments · Fixed by #14637
Closed

Golang API reports Artifact Headers are an invalid key #14657

jimrazmus opened this issue Sep 22, 2022 · 2 comments · Fixed by #14637
Assignees
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/hcl theme/jobspec type/bug

Comments

@jimrazmus
Copy link
Contributor

Nomad version

github.com/hashicorp/nomad v1.3.5
github.com/hashicorp/nomad/api v0.0.0-20220922140200-349501f82584

Operating system and Environment details

Mac OS 12.5.1

Issue

Calling jobspec.Parse (github.com/hashicorp/nomad/jobspec) with a job containing an artifact clause with 'headers' fails and reports that 'headers' is an invalid key.

Looking at the parseArtifacts function in the jobspec.go file, we can see that 'headers' is not in the list of valid keys.

Reproduction steps

Provide the job definition to the jobspec.Parse function.

job, err := jobspec.Parse(&buf)

Expected Result

The job definition should parse successfully and return a *api.Job.

Actual Result

Parse returns an error indicating artifact -> invalid key: headers

Job file

job "docs" {
  datacenters = ["dc1"]
  group "example" {
    network {
      port "http" {
        static = "5678"
      }
    }
    task "server" {
      artifact {
        headers {
          User-Agent    = "nomad-[${NOMAD_JOB_ID}]-[${NOMAD_GROUP_NAME}]-[${NOMAD_TASK_NAME}]"
          X-Nomad-Alloc = "${NOMAD_ALLOC_ID}"
        }
        source = "https://example.com/file.txt"
      }
      config {
        image = "hashicorp/http-echo"
        ports = ["http"]
        args = [
          "-listen",
          ":5678",
          "-text",
          "hello world",
        ]
      }
      driver = "docker"
    }
  }
}

Nomad Server logs (if appropriate)

NA

Nomad Client logs (if appropriate)

NA

@lgfa29
Copy link
Contributor

lgfa29 commented Sep 22, 2022

Thanks for report @jimrazmus!

This is also a problem when running nomad run -hcl1. For a while we were deciding on how to handle and deprecate HCLv1 parsing, but it was decided to keep support for both for now. This change was probably caught in the middle of that discussion.

Just as a heads up, the jobspec and jobspec2 packages are not part of the api package, so we don't have any breaking change policy around them. That being said, it may be better to use jobspec2 for parsing jobs unless you really need HCLv1 parsing for some reason.

And thanks for the PR, I will get a fix there soon 🙂

@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 Jan 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/hcl theme/jobspec type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants