The sidecar configuration is different depending on the backup type. Need more AddSidecar functions
This commit is contained in:
parent
e80871346e
commit
55f3dc8dff
@ -93,11 +93,20 @@ func (r *BackupConfigurationReconciler) Reconcile(ctx context.Context, req ctrl.
|
|||||||
backupConf.Status.ActiveCronJob = true
|
backupConf.Status.ActiveCronJob = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.AddSidecar(backupConf); err != nil {
|
for _, target := range backupConf.Spec.Targets {
|
||||||
r.Log.Error(err, "unable to add sidecar container")
|
switch target.BackupType {
|
||||||
|
case formolv1alpha1.OnlineKind:
|
||||||
|
// TODO: add a sidecar to the pod with the target.Containers[].Paths mounted
|
||||||
|
if err := r.AddOnlineSidecar(backupConf, target); err != nil {
|
||||||
|
r.Log.Error(err, "unable to add online sidecar")
|
||||||
return ctrl.Result{}, err
|
return ctrl.Result{}, err
|
||||||
} else {
|
}
|
||||||
backupConf.Status.ActiveSidecar = true
|
backupConf.Status.ActiveSidecar = true
|
||||||
|
case formolv1alpha1.JobKind:
|
||||||
|
// TODO: add a sidecar to the pod with a shared
|
||||||
|
case formolv1alpha1.SnapshotKind:
|
||||||
|
// TOD: add a sidecar to run the steps
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.Status().Update(ctx, &backupConf); err != nil {
|
if err := r.Status().Update(ctx, &backupConf); err != nil {
|
||||||
|
|||||||
@ -178,11 +178,7 @@ func (r *BackupConfigurationReconciler) DeleteSidecar(backupConf formolv1alpha1.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *BackupConfigurationReconciler) AddSidecar(backupConf formolv1alpha1.BackupConfiguration) error {
|
func (r *BackupConfigurationReconciler) AddOnlineSidecar(backupConf formolv1alpha1.BackupConfiguration, target formolv1alpha1.Target) error {
|
||||||
// Go through all the 'targets'
|
|
||||||
// the backupType: Online needs a sidecar container for every single listed 'container'
|
|
||||||
// if the backupType is something else than Online, the 'container' will still need a sidecar
|
|
||||||
// if it has 'steps'
|
|
||||||
addTags := func(sideCar *corev1.Container, podSpec *corev1.PodSpec, target formolv1alpha1.Target) bool {
|
addTags := func(sideCar *corev1.Container, podSpec *corev1.PodSpec, target formolv1alpha1.Target) bool {
|
||||||
for i, container := range podSpec.Containers {
|
for i, container := range podSpec.Containers {
|
||||||
if container.Name == formolv1alpha1.SIDECARCONTAINER_NAME {
|
if container.Name == formolv1alpha1.SIDECARCONTAINER_NAME {
|
||||||
@ -217,17 +213,6 @@ func (r *BackupConfigurationReconciler) AddSidecar(backupConf formolv1alpha1.Bac
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, target := range backupConf.Spec.Targets {
|
|
||||||
addSidecar := false
|
|
||||||
for _, targetContainer := range target.Containers {
|
|
||||||
if len(targetContainer.Steps) > 0 {
|
|
||||||
addSidecar = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if target.BackupType == formolv1alpha1.OnlineKind {
|
|
||||||
addSidecar = true
|
|
||||||
}
|
|
||||||
if addSidecar {
|
|
||||||
repo := formolv1alpha1.Repo{}
|
repo := formolv1alpha1.Repo{}
|
||||||
if err := r.Get(r.Context, client.ObjectKey{
|
if err := r.Get(r.Context, client.ObjectKey{
|
||||||
Namespace: backupConf.Namespace,
|
Namespace: backupConf.Namespace,
|
||||||
@ -285,8 +270,6 @@ func (r *BackupConfigurationReconciler) AddSidecar(backupConf formolv1alpha1.Bac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user