From e35cd843a1151f953f65fd7ccd9ff1f39e8e1e7f Mon Sep 17 00:00:00 2001 From: Piotr Kazmierczak <470696+pkazmierczak@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:49:14 +0100 Subject: [PATCH 1/3] stateful deployments: add corrections to API structs and methods --- api/tasks.go | 6 ++++++ command/agent/job_endpoint.go | 2 ++ 2 files changed, 8 insertions(+) diff --git a/api/tasks.go b/api/tasks.go index 21d99bf4c2c..ed694dbd32d 100644 --- a/api/tasks.go +++ b/api/tasks.go @@ -455,6 +455,7 @@ type VolumeRequest struct { Type string `hcl:"type,optional"` Source string `hcl:"source,optional"` ReadOnly bool `hcl:"read_only,optional"` + Sticky bool `hcl:"sticky,optional"` AccessMode string `hcl:"access_mode,optional"` AttachmentMode string `hcl:"attachment_mode,optional"` MountOptions *CSIMountOptions `hcl:"mount_options,block"` @@ -474,6 +475,7 @@ type VolumeMount struct { Volume *string `hcl:"volume,optional"` Destination *string `hcl:"destination,optional"` ReadOnly *bool `mapstructure:"read_only" hcl:"read_only,optional"` + Sticky *bool `mapstructure:"sticky" hcl:"sticky,optional"` PropagationMode *string `mapstructure:"propagation_mode" hcl:"propagation_mode,optional"` SELinuxLabel *string `mapstructure:"selinux_label" hcl:"selinux_label,optional"` } @@ -487,6 +489,10 @@ func (vm *VolumeMount) Canonicalize() { vm.ReadOnly = pointerOf(false) } + if vm.Sticky == nil { + vm.Sticky = pointerOf(false) + } + if vm.SELinuxLabel == nil { vm.SELinuxLabel = pointerOf("") } diff --git a/command/agent/job_endpoint.go b/command/agent/job_endpoint.go index fd0c0c03501..51592e51346 100644 --- a/command/agent/job_endpoint.go +++ b/command/agent/job_endpoint.go @@ -1334,6 +1334,7 @@ func ApiTgToStructsTG(job *structs.Job, taskGroup *api.TaskGroup, tg *structs.Ta Name: v.Name, Type: v.Type, ReadOnly: v.ReadOnly, + Sticky: v.Sticky, Source: v.Source, AttachmentMode: structs.CSIVolumeAttachmentMode(v.AttachmentMode), AccessMode: structs.CSIVolumeAccessMode(v.AccessMode), @@ -2165,6 +2166,7 @@ func apiVolumeMountsToStructs(in []*api.VolumeMount) []*structs.VolumeMount { Volume: *mount.Volume, Destination: *mount.Destination, ReadOnly: *mount.ReadOnly, + Sticky: *mount.Sticky, PropagationMode: *mount.PropagationMode, SELinuxLabel: *mount.SELinuxLabel, }) From ac2bf736063785828aca611c907b2bbc5c5c40d9 Mon Sep 17 00:00:00 2001 From: Piotr Kazmierczak <470696+pkazmierczak@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:56:32 +0100 Subject: [PATCH 2/3] volumeMount fixes --- api/tasks.go | 5 ----- command/agent/job_endpoint.go | 1 - nomad/structs/volumes.go | 3 --- 3 files changed, 9 deletions(-) diff --git a/api/tasks.go b/api/tasks.go index ed694dbd32d..b39c55ad56b 100644 --- a/api/tasks.go +++ b/api/tasks.go @@ -475,7 +475,6 @@ type VolumeMount struct { Volume *string `hcl:"volume,optional"` Destination *string `hcl:"destination,optional"` ReadOnly *bool `mapstructure:"read_only" hcl:"read_only,optional"` - Sticky *bool `mapstructure:"sticky" hcl:"sticky,optional"` PropagationMode *string `mapstructure:"propagation_mode" hcl:"propagation_mode,optional"` SELinuxLabel *string `mapstructure:"selinux_label" hcl:"selinux_label,optional"` } @@ -489,10 +488,6 @@ func (vm *VolumeMount) Canonicalize() { vm.ReadOnly = pointerOf(false) } - if vm.Sticky == nil { - vm.Sticky = pointerOf(false) - } - if vm.SELinuxLabel == nil { vm.SELinuxLabel = pointerOf("") } diff --git a/command/agent/job_endpoint.go b/command/agent/job_endpoint.go index 51592e51346..5ebe21e1eb3 100644 --- a/command/agent/job_endpoint.go +++ b/command/agent/job_endpoint.go @@ -2166,7 +2166,6 @@ func apiVolumeMountsToStructs(in []*api.VolumeMount) []*structs.VolumeMount { Volume: *mount.Volume, Destination: *mount.Destination, ReadOnly: *mount.ReadOnly, - Sticky: *mount.Sticky, PropagationMode: *mount.PropagationMode, SELinuxLabel: *mount.SELinuxLabel, }) diff --git a/nomad/structs/volumes.go b/nomad/structs/volumes.go index b8c95fc2862..18d5f39289e 100644 --- a/nomad/structs/volumes.go +++ b/nomad/structs/volumes.go @@ -263,7 +263,6 @@ type VolumeMount struct { Volume string Destination string ReadOnly bool - Sticky bool PropagationMode string SELinuxLabel string } @@ -284,8 +283,6 @@ func (v *VolumeMount) Equal(o *VolumeMount) bool { return false case v.ReadOnly != o.ReadOnly: return false - case v.Sticky != o.Sticky: - return false case v.PropagationMode != o.PropagationMode: return false case v.SELinuxLabel != o.SELinuxLabel: From 0bc727a856a9247e46eaebe9a4580cb726ce1a03 Mon Sep 17 00:00:00 2001 From: Piotr Kazmierczak <470696+pkazmierczak@users.noreply.github.com> Date: Tue, 17 Dec 2024 20:13:41 +0100 Subject: [PATCH 3/3] diff test fix --- nomad/structs/diff_test.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/nomad/structs/diff_test.go b/nomad/structs/diff_test.go index 45563f23573..e394545ad1d 100644 --- a/nomad/structs/diff_test.go +++ b/nomad/structs/diff_test.go @@ -8376,12 +8376,6 @@ func TestTaskDiff(t *testing.T) { Old: "", New: "Z", }, - { - Type: DiffTypeAdded, - Name: "Sticky", - Old: "", - New: "false", - }, { Type: DiffTypeAdded, Name: "Volume",