Skip to content

Commit

Permalink
np: update docs and add test for nil lists (#17899)
Browse files Browse the repository at this point in the history
Document and test that if a namespace does not provide an `allow` or
`deny` list than those are treated as `nil` and have a different
behaviour from an empty list (`[]string{}`).
  • Loading branch information
lgfa29 authored Jul 11, 2023
1 parent 79773a0 commit 99fb36e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
18 changes: 18 additions & 0 deletions command/namespace_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions website/content/docs/other-specifications/namespace.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>: [])` - 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<string>: 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<string>: [])` - Specifies the node pools that are not
- `denied` `(array<string>: 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
Expand Down

0 comments on commit 99fb36e

Please sign in to comment.