Skip to content

Commit

Permalink
stateful deployments: validate there are no sticky per_alloc volume r…
Browse files Browse the repository at this point in the history
…equests (#24714)

This changeset adds an additional validation that prevents users from setting
per_alloc and sticky flags on volume requests.

Ref: #24479
  • Loading branch information
pkazmierczak authored Dec 19, 2024
1 parent ab2a6fd commit 6ea52e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nomad/structs/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ func (v *VolumeRequest) Validate(jobType string, taskGroupCount, canaries int) e
if canaries > 0 {
addErr("volume cannot be per_alloc when canaries are in use")
}
if v.Sticky {
addErr("volume cannot be per_alloc and sticky at the same time")
}
}

switch v.Type {
Expand Down
11 changes: 11 additions & 0 deletions nomad/structs/volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ func TestVolumeRequest_Validate(t *testing.T) {
PerAlloc: true,
},
},
{
name: "per_alloc sticky",
expected: []string{
"volume cannot be per_alloc and sticky at the same time",
},
req: &VolumeRequest{
Type: VolumeTypeCSI,
PerAlloc: true,
Sticky: true,
},
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 6ea52e4

Please sign in to comment.