Adding node_pool to job key validation (#18366)

This commit is contained in:
Pavel Aminov 2023-09-13 17:52:04 +03:00 committed by Luiz Aoqui
parent 9a188167cb
commit def93200b1
5 changed files with 7 additions and 1 deletions

3
.changelog/18366.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
jobspec: add `node_pool` as a valid field
```

View File

@ -966,7 +966,7 @@ type Job struct {
Priority *int `hcl:"priority,optional"` Priority *int `hcl:"priority,optional"`
AllAtOnce *bool `mapstructure:"all_at_once" hcl:"all_at_once,optional"` AllAtOnce *bool `mapstructure:"all_at_once" hcl:"all_at_once,optional"`
Datacenters []string `hcl:"datacenters,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"` Constraints []*Constraint `hcl:"constraint,block"`
Affinities []*Affinity `hcl:"affinity,block"` Affinities []*Affinity `hcl:"affinity,block"`
TaskGroups []*TaskGroup `hcl:"group,block"` TaskGroups []*TaskGroup `hcl:"group,block"`

View File

@ -66,6 +66,7 @@ func parseJob(result *api.Job, list *ast.ObjectList) error {
"affinity", "affinity",
"spread", "spread",
"datacenters", "datacenters",
"node_pool",
"group", "group",
"id", "id",
"meta", "meta",

View File

@ -61,6 +61,7 @@ func TestParse(t *testing.T) {
Datacenters: []string{"us2", "eu1"}, Datacenters: []string{"us2", "eu1"},
Region: stringToPtr("fooregion"), Region: stringToPtr("fooregion"),
Namespace: stringToPtr("foonamespace"), Namespace: stringToPtr("foonamespace"),
NodePool: stringToPtr("dev"),
ConsulToken: stringToPtr("abc"), ConsulToken: stringToPtr("abc"),
VaultToken: stringToPtr("foo"), VaultToken: stringToPtr("foo"),

View File

@ -4,6 +4,7 @@
job "binstore-storagelocker" { job "binstore-storagelocker" {
region = "fooregion" region = "fooregion"
namespace = "foonamespace" namespace = "foonamespace"
node_pool = "dev"
type = "batch" type = "batch"
priority = 52 priority = 52
all_at_once = true all_at_once = true