Skip to content

Commit

Permalink
vtbackupSpec: Allocate a new map to avoid mutating input. (bitpoke#125)
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Yeh <enisoc@planetscale.com>
  • Loading branch information
enisoc authored Sep 2, 2020
1 parent 3c243e9 commit 7fbec1d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/controller/vitessshard/reconcile_backup_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ func vtbackupSpec(key client.ObjectKey, vts *planetscalev2.VitessShard, parentLa
minRetentionTime := time.Duration(0)
minRetentionCount := 1

// Allocate a new map so we don't mutate inputs.
annotations := map[string]string{}
update.Annotations(&annotations, pool.Annotations)
update.Annotations(&annotations, backupLocation.Annotations)

// Fill in the parts of a vttablet spec that make sense for vtbackup.
tabletSpec := &vttablet.Spec{
GlobalLockserver: vts.Spec.GlobalLockserver,
Expand All @@ -238,9 +243,8 @@ func vtbackupSpec(key client.ObjectKey, vts *planetscalev2.VitessShard, parentLa
InitContainers: pool.InitContainers,
SidecarContainers: pool.SidecarContainers,
ExtraEnv: pool.ExtraEnv,
Annotations: pool.Annotations,
Annotations: annotations,
}
update.Annotations(&tabletSpec.Annotations, backupLocation.Annotations)

return &vttablet.BackupSpec{
InitialBackup: backupType == vitessbackup.TypeInit,
Expand Down

0 comments on commit 7fbec1d

Please sign in to comment.