remove the initContainer once the restore is done
This commit is contained in:
parent
8ea4e3bffe
commit
5e5e4a9a77
@ -54,6 +54,9 @@ func (r *BackupSessionReconciler) Reconcile(ctx context.Context, req ctrl.Reques
|
||||
var targetStatus *formolv1alpha1.TargetStatus
|
||||
var result error
|
||||
targetName := os.Getenv(formolv1alpha1.TARGET_NAME)
|
||||
if targetName == "" {
|
||||
panic("targetName is empty. That should not happen")
|
||||
}
|
||||
|
||||
for i, t := range backupConf.Spec.Targets {
|
||||
if t.TargetName == targetName {
|
||||
|
||||
@ -87,6 +87,27 @@ func StartRestore(
|
||||
log.Error(err, "unable to update RestoreSession", "restoreSession", restoreSession)
|
||||
return
|
||||
}
|
||||
log.V(0).Info("restore over. removing the initContainer")
|
||||
targetObject, targetPodSpec := formolv1alpha1.GetTargetObjects(target.TargetKind)
|
||||
if err := session.Get(session.Context, client.ObjectKey{
|
||||
Namespace: restoreSessionNamespace,
|
||||
Name: target.TargetName,
|
||||
}, targetObject); err != nil {
|
||||
log.Error(err, "unable to get target objects", "target", target.TargetName)
|
||||
return
|
||||
}
|
||||
initContainers := []corev1.Container{}
|
||||
for _, c := range targetPodSpec.InitContainers {
|
||||
if c.Name == formolv1alpha1.RESTORECONTAINER_NAME {
|
||||
continue
|
||||
}
|
||||
initContainers = append(initContainers, c)
|
||||
}
|
||||
targetPodSpec.InitContainers = initContainers
|
||||
if err := session.Update(session.Context, targetObject); err != nil {
|
||||
log.Error(err, "unable to remove the restore initContainer", "targetObject", targetObject)
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user