From 3e72a60f4de8dc62f20c671c503a09669d4dfc6d Mon Sep 17 00:00:00 2001 From: Jim Razmus II Date: Wed, 21 Sep 2022 15:39:07 +0000 Subject: [PATCH 1/3] backport of commit feee921dea84c0e6c225e31d5a1a90310d763fff --- jobspec/test-fixtures/artifacts.hcl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jobspec/test-fixtures/artifacts.hcl b/jobspec/test-fixtures/artifacts.hcl index 4631f595bef..29ab684fb78 100644 --- a/jobspec/test-fixtures/artifacts.hcl +++ b/jobspec/test-fixtures/artifacts.hcl @@ -20,6 +20,15 @@ job "binstore-storagelocker" { source = "http://foo.com/bam" destination = "var/foo" } + + artifact { + source = "https://example.com/file.txt" + + headers { + User-Agent = "nomad-[${NOMAD_JOB_ID}]-[${NOMAD_GROUP_NAME}]-[${NOMAD_TASK_NAME}]" + X-Nomad-Alloc = "${NOMAD_ALLOC_ID}" + } + } } } } From 9be10a6cf7cf0a0c085dbb1c5e779e91689a033b Mon Sep 17 00:00:00 2001 From: Luiz Aoqui Date: Thu, 22 Sep 2022 19:33:05 +0000 Subject: [PATCH 2/3] backport of commit 7aa9e1be3c95fbaaea4a674643744c7599b5542a --- jobspec/parse_task.go | 1 + jobspec/parse_test.go | 7 +++++++ jobspec/test-fixtures/artifacts.hcl | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/jobspec/parse_task.go b/jobspec/parse_task.go index 4bc77c310f2..2bdcac22720 100644 --- a/jobspec/parse_task.go +++ b/jobspec/parse_task.go @@ -370,6 +370,7 @@ func parseArtifacts(result *[]*api.TaskArtifact, list *ast.ObjectList) error { valid := []string{ "source", "options", + "headers", "mode", "destination", } diff --git a/jobspec/parse_test.go b/jobspec/parse_test.go index 1af37804371..bbd183abcd1 100644 --- a/jobspec/parse_test.go +++ b/jobspec/parse_test.go @@ -604,6 +604,13 @@ func TestParse(t *testing.T) { GetterOptions: nil, RelativeDest: stringToPtr("var/foo"), }, + { + GetterSource: stringToPtr("https://example.com/file.txt"), + GetterHeaders: map[string]string{ + "User-Agent": "nomad", + "X-Nomad-Alloc": "alloc", + }, + }, }, }, }, diff --git a/jobspec/test-fixtures/artifacts.hcl b/jobspec/test-fixtures/artifacts.hcl index 29ab684fb78..2da722850c8 100644 --- a/jobspec/test-fixtures/artifacts.hcl +++ b/jobspec/test-fixtures/artifacts.hcl @@ -25,8 +25,8 @@ job "binstore-storagelocker" { source = "https://example.com/file.txt" headers { - User-Agent = "nomad-[${NOMAD_JOB_ID}]-[${NOMAD_GROUP_NAME}]-[${NOMAD_TASK_NAME}]" - X-Nomad-Alloc = "${NOMAD_ALLOC_ID}" + User-Agent = "nomad" + X-Nomad-Alloc = "alloc" } } } From 130f13272835991e6475388a7f08612af66845e8 Mon Sep 17 00:00:00 2001 From: Luiz Aoqui Date: Thu, 22 Sep 2022 19:34:52 +0000 Subject: [PATCH 3/3] backport of commit 164c370886c7c02ed4144ea708bc9487ed9b4c40 --- .changelog/14637.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/14637.txt diff --git a/.changelog/14637.txt b/.changelog/14637.txt new file mode 100644 index 00000000000..7e01d444d33 --- /dev/null +++ b/.changelog/14637.txt @@ -0,0 +1,3 @@ +```release-note:bug +jobspec: Fixed a bug where an `artifact` with `headers` configuration would fail to parse when using HCLv1 +```