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
  • Loading branch information
pkazmierczak committed Dec 19, 2024
1 parent 22bb446 commit f471418
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 f471418

Please sign in to comment.