From def93200b1c858bfbe8f9b7eb6130f7933ea10b9 Mon Sep 17 00:00:00 2001 From: Pavel Aminov <76755257+aminovpavel@users.noreply.github.com> Date: Wed, 13 Sep 2023 17:52:04 +0300 Subject: [PATCH] Adding node_pool to job key validation (#18366) --- .changelog/18366.txt | 3 +++ api/jobs.go | 2 +- jobspec/parse_job.go | 1 + jobspec/parse_test.go | 1 + jobspec/test-fixtures/basic.hcl | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changelog/18366.txt diff --git a/.changelog/18366.txt b/.changelog/18366.txt new file mode 100644 index 000000000..841d49a5a --- /dev/null +++ b/.changelog/18366.txt @@ -0,0 +1,3 @@ +```release-note:improvement +jobspec: add `node_pool` as a valid field +``` diff --git a/api/jobs.go b/api/jobs.go index 702680cc9..297e595c9 100644 --- a/api/jobs.go +++ b/api/jobs.go @@ -966,7 +966,7 @@ type Job struct { Priority *int `hcl:"priority,optional"` AllAtOnce *bool `mapstructure:"all_at_once" hcl:"all_at_once,optional"` Datacenters []string `hcl:"datacenters,optional"` - NodePool *string `hcl:"node_pool,optional"` + NodePool *string `mapstructure:"node_pool" hcl:"node_pool,optional"` Constraints []*Constraint `hcl:"constraint,block"` Affinities []*Affinity `hcl:"affinity,block"` TaskGroups []*TaskGroup `hcl:"group,block"` diff --git a/jobspec/parse_job.go b/jobspec/parse_job.go index 3ce283087..9cedf3309 100644 --- a/jobspec/parse_job.go +++ b/jobspec/parse_job.go @@ -66,6 +66,7 @@ func parseJob(result *api.Job, list *ast.ObjectList) error { "affinity", "spread", "datacenters", + "node_pool", "group", "id", "meta", diff --git a/jobspec/parse_test.go b/jobspec/parse_test.go index 2f41a7d5a..b44777a58 100644 --- a/jobspec/parse_test.go +++ b/jobspec/parse_test.go @@ -61,6 +61,7 @@ func TestParse(t *testing.T) { Datacenters: []string{"us2", "eu1"}, Region: stringToPtr("fooregion"), Namespace: stringToPtr("foonamespace"), + NodePool: stringToPtr("dev"), ConsulToken: stringToPtr("abc"), VaultToken: stringToPtr("foo"), diff --git a/jobspec/test-fixtures/basic.hcl b/jobspec/test-fixtures/basic.hcl index aba8ea342..1176a9d96 100644 --- a/jobspec/test-fixtures/basic.hcl +++ b/jobspec/test-fixtures/basic.hcl @@ -4,6 +4,7 @@ job "binstore-storagelocker" { region = "fooregion" namespace = "foonamespace" + node_pool = "dev" type = "batch" priority = 52 all_at_once = true