Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduler: volume updates should always be destructive #13008

Merged
merged 1 commit into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/13008.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
volumes: Fixed a bug where additions, updates, or removals of host volumes or CSI volumes were not treated as destructive updates
```
9 changes: 9 additions & 0 deletions scheduler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,12 @@ func tasksUpdated(jobA, jobB *structs.Job, taskGroup string) bool {
return true
}

// Check if volumes are updated (no task driver can support
// altering mounts in-place)
if !reflect.DeepEqual(a.Volumes, b.Volumes) {
return true
}

// Check each task
for _, at := range a.Tasks {
bt := b.LookupTask(at.Name)
Expand Down Expand Up @@ -554,6 +560,9 @@ func tasksUpdated(jobA, jobB *structs.Job, taskGroup string) bool {
if !reflect.DeepEqual(at.CSIPluginConfig, bt.CSIPluginConfig) {
return true
}
if !reflect.DeepEqual(at.VolumeMounts, bt.VolumeMounts) {
return true
}

// Check the metadata
if !reflect.DeepEqual(
Expand Down
26 changes: 26 additions & 0 deletions scheduler/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,32 @@ func TestTasksUpdated(t *testing.T) {
// Compare changed Template wait configs
j23.TaskGroups[0].Tasks[0].Templates[0].Wait.Max = helper.TimeToPtr(10 * time.Second)
require.True(t, tasksUpdated(j22, j23, name))

// Add a volume
j24 := mock.Job()
j25 := j24.Copy()
j25.TaskGroups[0].Volumes = map[string]*structs.VolumeRequest{
"myvolume": {
Name: "myvolume",
Type: "csi",
Source: "test-volume[0]",
}}
require.True(t, tasksUpdated(j24, j25, name))

// Alter a volume
j26 := j25.Copy()
j26.TaskGroups[0].Volumes["myvolume"].ReadOnly = true
require.True(t, tasksUpdated(j25, j26, name))

// Alter a CSI plugin
j27 := mock.Job()
j27.TaskGroups[0].Tasks[0].CSIPluginConfig = &structs.TaskCSIPluginConfig{
ID: "myplugin",
Type: "node",
}
j28 := j27.Copy()
j28.TaskGroups[0].Tasks[0].CSIPluginConfig.Type = "monolith"
require.True(t, tasksUpdated(j27, j28, name))
}

func TestTasksUpdated_connectServiceUpdated(t *testing.T) {
Expand Down