Skip to content

Commit

Permalink
Prevent from writing into shared informer cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zimnx committed Nov 27, 2023
1 parent b061647 commit d5c6b67
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/controller/manager/sync_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ func syncBackupTasks(clusterID string, cluster *scyllav1.ScyllaCluster, syncer s
var actions []action

for _, bt := range cluster.Spec.Backups {
backupTask := &BackupTask{BackupTaskSpec: bt}
btCopy := *bt.DeepCopy()
backupTask := &BackupTask{BackupTaskSpec: btCopy}

for _, managerTask := range managerState.BackupTasks {
if syncer.taskID(backupTask.Name) == managerTask.ID {
Expand All @@ -137,7 +138,7 @@ func syncBackupTasks(clusterID string, cluster *scyllav1.ScyllaCluster, syncer s
actions = append(actions, &addTaskAction{
clusterID: clusterID,
task: mt,
taskSpec: bt,
taskSpec: btCopy,
})
} else if syncer.shouldUpdateTask(backupTask.Name) {
backupTask.ID = syncer.taskID(backupTask.Name)
Expand All @@ -158,7 +159,7 @@ func syncBackupTasks(clusterID string, cluster *scyllav1.ScyllaCluster, syncer s
actions = append(actions, &updateTaskAction{
clusterID: clusterID,
task: mt,
taskSpec: bt,
taskSpec: btCopy,
})
}
}
Expand All @@ -171,7 +172,8 @@ func syncRepairTasks(clusterID string, cluster *scyllav1.ScyllaCluster, syncer s
var actions []action

for _, rt := range cluster.Spec.Repairs {
repairTask := &RepairTask{RepairTaskSpec: rt}
rtCopy := *rt.DeepCopy()
repairTask := &RepairTask{RepairTaskSpec: rtCopy}

for _, managerTask := range managerState.RepairTasks {
if syncer.taskID(repairTask.Name) == managerTask.ID {
Expand All @@ -187,7 +189,7 @@ func syncRepairTasks(clusterID string, cluster *scyllav1.ScyllaCluster, syncer s
actions = append(actions, &addTaskAction{
clusterID: clusterID,
task: mt,
taskSpec: rt,
taskSpec: rtCopy,
})
} else if syncer.shouldUpdateTask(rt.Name) {
repairTask.ID = syncer.taskID(rt.Name)
Expand All @@ -207,7 +209,7 @@ func syncRepairTasks(clusterID string, cluster *scyllav1.ScyllaCluster, syncer s
actions = append(actions, &updateTaskAction{
clusterID: clusterID,
task: mt,
taskSpec: rt,
taskSpec: rtCopy,
})
}
}
Expand Down

0 comments on commit d5c6b67

Please sign in to comment.