From 0951fe1c5011767da2ebe9839e4548e6e0690f36 Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Tue, 11 Jul 2023 10:00:05 -0500 Subject: [PATCH] backport of commit 0a5e90120b18ff450457463d6bcee68ec6804bb0 (#17900) This pull request was automerged via backport-assistant --- command/namespace_apply_test.go | 18 ++++++++++++++++++ nomad/structs/structs.go | 8 ++++---- .../docs/other-specifications/namespace.mdx | 12 ++++++------ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/command/namespace_apply_test.go b/command/namespace_apply_test.go index 05154146c..08c840e48 100644 --- a/command/namespace_apply_test.go +++ b/command/namespace_apply_test.go @@ -120,6 +120,24 @@ meta { input: "", expected: &api.Namespace{}, }, + { + name: "lists in node pool config are nil if not provided", + input: ` +name = "nil-lists" + +node_pool_config { + default = "default" +} +`, + expected: &api.Namespace{ + Name: "nil-lists", + NodePoolConfiguration: &api.NamespaceNodePoolConfiguration{ + Default: "default", + Allowed: nil, + Denied: nil, + }, + }, + }, } for _, tc := range testCases { diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 0b560c08e..ae8742949 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -5396,10 +5396,10 @@ type NamespaceNodePoolConfiguration struct { Default string // Allowed specifies the node pools that are allowed to be used by jobs in - // this namespace. This field supports wildcard globbing through the use - // of `*` for multi-character matching. If specified, only the node pools - // that match these patterns are allowed. This field cannot be used - // with Denied. + // this namespace. By default, all node pools are allowed. If an empty list + // is provided only the namespace's default node pool is allowed. This field + // supports wildcard globbing through the use of `*` for multi-character + // matching. This field cannot be used with Denied. Allowed []string // Denied specifies the node pools that are not allowed to be used by jobs diff --git a/website/content/docs/other-specifications/namespace.mdx b/website/content/docs/other-specifications/namespace.mdx index 56a61b0da..08e08f326 100644 --- a/website/content/docs/other-specifications/namespace.mdx +++ b/website/content/docs/other-specifications/namespace.mdx @@ -79,13 +79,13 @@ node_pool_config { - `default` `(string: "default")` - Specifies the node pool to use for jobs in this namespace that don't define a node pool in their specification. -- `allowed` `(array: [])` - Specifies the node pools that are allowed - to be used by jobs in this namespace. This field supports wildcard globbing - through the use of `*` for multi-character matching. If specified, only the - node pools that match these patterns are allowed. This field cannot be used - with `denied`. +- `allowed` `(array: nil)` - Specifies the node pools that are allowed + to be used by jobs in this namespace. By default, all node pools are allowed. + If an empty list is provided only the namespace's default node pool is + allowed. This field supports wildcard globbing through the use of `*` for + multi-character matching. This field cannot be used with `denied`. -- `denied` `(array: [])` - Specifies the node pools that are not +- `denied` `(array: nil)` - Specifies the node pools that are not allowed to be used by jobs in this namespace. This field supports wildcard globbing through the use of `*` for multi-character matching. If specified, any node pool is allowed to be used, except for those that match any of these