Skip to content

Commit

Permalink
update backup type
Browse files Browse the repository at this point in the history
  • Loading branch information
polefishu committed Dec 24, 2019
1 parent a39cf0f commit 7552f83
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/redis/v1alpha1/redisclusterbackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type RedisClusterBackupSpec struct {
RedisClusterName string `json:"redisClusterName"`
Storage *RedisStorage `json:"storage,omitempty"`
store.Backend `json:",inline"`
PodSpec PodSpec `json:"podSpec,omitempty"`
PodSpec *PodSpec `json:"podSpec,omitempty"`
}

type PodSpec struct {
Expand Down
31 changes: 18 additions & 13 deletions pkg/controller/redisclusterbackup/sync_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,22 @@ func (r *ReconcileRedisClusterBackup) getBackupJob(reqLogger logr.Logger, backup
},
},
},
RestartPolicy: corev1.RestartPolicyNever,
NodeSelector: backup.Spec.PodSpec.NodeSelector,
Affinity: backup.Spec.PodSpec.Affinity,
SchedulerName: backup.Spec.PodSpec.SchedulerName,
Tolerations: backup.Spec.PodSpec.Tolerations,
PriorityClassName: backup.Spec.PodSpec.PriorityClassName,
Priority: backup.Spec.PodSpec.Priority,
SecurityContext: backup.Spec.PodSpec.SecurityContext,
ImagePullSecrets: backup.Spec.PodSpec.ImagePullSecrets,
RestartPolicy: corev1.RestartPolicyNever,
},
},
},
}
if backup.Spec.PodSpec != nil {
podSpec := job.Spec.Template.Spec
podSpec.NodeSelector = backup.Spec.PodSpec.NodeSelector
podSpec.Affinity = backup.Spec.PodSpec.Affinity
podSpec.SchedulerName = backup.Spec.PodSpec.SchedulerName
podSpec.Tolerations = backup.Spec.PodSpec.Tolerations
podSpec.PriorityClassName = backup.Spec.PodSpec.PriorityClassName
podSpec.Priority = backup.Spec.PodSpec.Priority
podSpec.SecurityContext = backup.Spec.PodSpec.SecurityContext
podSpec.ImagePullSecrets = backup.Spec.PodSpec.ImagePullSecrets
}
if backup.Spec.Backend.Local != nil {
job.Spec.Template.Spec.Volumes = append(job.Spec.Template.Spec.Volumes, corev1.Volume{
Name: "local",
Expand Down Expand Up @@ -333,10 +336,6 @@ func (r *ReconcileRedisClusterBackup) backupContainers(backup *redisv1alpha1.Red
fmt.Sprintf(`--snapshot=%s-%d`, backup.Name, i),
"--",
},
Resources: backup.Spec.PodSpec.Resources,
LivenessProbe: backup.Spec.PodSpec.LivenessProbe,
ReadinessProbe: backup.Spec.PodSpec.ReadinessProbe,
Lifecycle: backup.Spec.PodSpec.Lifecycle,
VolumeMounts: []corev1.VolumeMount{
{
Name: redisv1alpha1.UtilVolumeName,
Expand All @@ -359,6 +358,12 @@ func (r *ReconcileRedisClusterBackup) backupContainers(backup *redisv1alpha1.Red
SubPath: backup.Spec.Backend.Local.SubPath,
})
}
if backup.Spec.PodSpec != nil {
container.Resources = backup.Spec.PodSpec.Resources
container.LivenessProbe = backup.Spec.PodSpec.LivenessProbe
container.ReadinessProbe = backup.Spec.PodSpec.ReadinessProbe
container.Lifecycle = backup.Spec.PodSpec.Lifecycle
}
containers[i] = container
i++
}
Expand Down

0 comments on commit 7552f83

Please sign in to comment.