From f4714185802f098c964ec012d7af16106b45ad05 Mon Sep 17 00:00:00 2001 From: Piotr Kazmierczak <470696+pkazmierczak@users.noreply.github.com> Date: Thu, 19 Dec 2024 10:31:43 +0100 Subject: [PATCH] stateful deployments: validate there are no sticky per_alloc volume requests --- nomad/structs/volumes.go | 3 +++ nomad/structs/volumes_test.go | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/nomad/structs/volumes.go b/nomad/structs/volumes.go index 58c4eefacd3..f474fe1d28e 100644 --- a/nomad/structs/volumes.go +++ b/nomad/structs/volumes.go @@ -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 { diff --git a/nomad/structs/volumes_test.go b/nomad/structs/volumes_test.go index 9b697faf18c..fb5a1a04d64 100644 --- a/nomad/structs/volumes_test.go +++ b/nomad/structs/volumes_test.go @@ -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 {