Reworked Steps
This commit is contained in:
parent
560271a294
commit
b91c767e82
@ -50,7 +50,7 @@ func (r *BackupSessionReconciler) backupJob(tag string, target formolv1alpha1.Ta
|
|||||||
paths := []string{}
|
paths := []string{}
|
||||||
for _, container := range target.Containers {
|
for _, container := range target.Containers {
|
||||||
for _, job := range container.Job {
|
for _, job := range container.Job {
|
||||||
if err = r.runFunction("backup-" + job.Name); err != nil {
|
if err = r.runFunction(*job.Backup); err != nil {
|
||||||
r.Log.Error(err, "unable to run job")
|
r.Log.Error(err, "unable to run job")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,7 +65,7 @@ func (r *RestoreSessionReconciler) restoreJob(target formolv1alpha1.Target, targ
|
|||||||
}
|
}
|
||||||
for _, container := range target.Containers {
|
for _, container := range target.Containers {
|
||||||
for _, job := range container.Job {
|
for _, job := range container.Job {
|
||||||
if err := r.runFunction("restore-" + job.Name); err != nil {
|
if err := r.runFunction(*job.Restore); err != nil {
|
||||||
r.Log.Error(err, "unable to run restore job")
|
r.Log.Error(err, "unable to run restore job")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -270,15 +270,18 @@ func (s Session) runTargetContainerChroot(runCmd string, args ...string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Session) runSteps(initializeSteps bool, target formolv1alpha1.Target) error {
|
type selectStep func(formolv1alpha1.Step) *string
|
||||||
|
|
||||||
|
func (s Session) runSteps(target formolv1alpha1.Target, fn selectStep) error {
|
||||||
// For every container listed in the target, run the initialization steps
|
// For every container listed in the target, run the initialization steps
|
||||||
for _, container := range target.Containers {
|
for _, container := range target.Containers {
|
||||||
// Runs the steps one after the other
|
// Runs the steps one after the other
|
||||||
for _, step := range container.Steps {
|
for _, step := range container.Steps {
|
||||||
if (initializeSteps == true && step.Finalize != nil && *step.Finalize == true) || (initializeSteps == false && (step.Finalize == nil || step.Finalize != nil && *step.Finalize == false)) {
|
if fn(step) != nil {
|
||||||
continue
|
if err := s.runFunction(*fn(step)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return s.runFunction(step.Name)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.Log.V(0).Info("Done running steps")
|
s.Log.V(0).Info("Done running steps")
|
||||||
@ -287,15 +290,19 @@ func (s Session) runSteps(initializeSteps bool, target formolv1alpha1.Target) er
|
|||||||
|
|
||||||
// Run the initializing steps in the INITIALIZING state of the controller
|
// Run the initializing steps in the INITIALIZING state of the controller
|
||||||
// before actualy doing the backup in the RUNNING state
|
// before actualy doing the backup in the RUNNING state
|
||||||
func (s Session) runFinalizeSteps(target formolv1alpha1.Target) error {
|
func (s Session) runInitializeSteps(target formolv1alpha1.Target) error {
|
||||||
s.Log.V(0).Info("start to run the finalize steps it any")
|
s.Log.V(0).Info("start to run the finalize steps it any")
|
||||||
return s.runSteps(false, target)
|
return s.runSteps(target, func(step formolv1alpha1.Step) *string {
|
||||||
|
return step.Initialize
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the finalizing steps in the FINALIZE state of the controller
|
// Run the finalizing steps in the FINALIZE state of the controller
|
||||||
// after the backup in the RUNNING state.
|
// after the backup in the RUNNING state.
|
||||||
// The finalize happens whatever the result of the backup.
|
// The finalize happens whatever the result of the backup.
|
||||||
func (s Session) runInitializeSteps(target formolv1alpha1.Target) error {
|
func (s Session) runFinalizeSteps(target formolv1alpha1.Target) error {
|
||||||
s.Log.V(0).Info("start to run the initialize steps it any")
|
s.Log.V(0).Info("start to run the initialize steps it any")
|
||||||
return s.runSteps(true, target)
|
return s.runSteps(target, func(step formolv1alpha1.Step) *string {
|
||||||
|
return step.Finalize
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
2
formol
2
formol
@ -1 +1 @@
|
|||||||
Subproject commit b7747b635d0253d39829d64ae96472da09c64297
|
Subproject commit e73ef7c3f24ee612421b62963f443ff1a1e790dc
|
||||||
Loading…
Reference in New Issue
Block a user