Set backupsession state to NEW
This commit is contained in:
parent
aba4ae4620
commit
888284017e
@ -35,8 +35,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TargetStatus struct {
|
type TargetStatus struct {
|
||||||
Name string `json:"name"`
|
BackupType `json:"backupType"`
|
||||||
Kind string `json:"kind"`
|
TargetName string `json:"targetName"`
|
||||||
|
TargetKind `json:"targetKind"`
|
||||||
SessionState `json:"state"`
|
SessionState `json:"state"`
|
||||||
SnapshotId string `json:"snapshotId"`
|
SnapshotId string `json:"snapshotId"`
|
||||||
StartTime *metav1.Time `json:"startTime"`
|
StartTime *metav1.Time `json:"startTime"`
|
||||||
|
|||||||
@ -18,8 +18,10 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
formolv1alpha1 "github.com/desmo999r/formol/api/v1alpha1"
|
formolv1alpha1 "github.com/desmo999r/formol/api/v1alpha1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *BackupSessionReconciler) isBackupOngoing(backupConf formolv1alpha1.BackupConfiguration) bool {
|
func (r *BackupSessionReconciler) isBackupOngoing(backupConf formolv1alpha1.BackupConfiguration) bool {
|
||||||
@ -36,10 +38,26 @@ func (r *BackupSessionReconciler) isBackupOngoing(backupConf formolv1alpha1.Back
|
|||||||
return len(backupSessionList.Items) > 0
|
return len(backupSessionList.Items) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *BackupSessionReconciler) startNextTask(backupSession formolv1alpha1.BackupSession, backupConf formolv1alpha1.BackupConfiguration) (formolv1alpha1.TargetStatus, error) {
|
func (r *BackupSessionReconciler) startNextTask(backupSession formolv1alpha1.BackupSession, backupConf formolv1alpha1.BackupConfiguration) (*formolv1alpha1.TargetStatus, error) {
|
||||||
nextTargetIndex := len(backupSession.Status.Targets)
|
nextTargetIndex := len(backupSession.Status.Targets)
|
||||||
if nextTargetIndex < len(backupConf.Spec.Targets) {
|
if nextTargetIndex < len(backupConf.Spec.Targets) {
|
||||||
nextTarget := backupConf.Spec.Targets[nextTargetIndex]
|
nextTarget := backupConf.Spec.Targets[nextTargetIndex]
|
||||||
|
nextTargetStatus := formolv1alpha1.TargetStatus{
|
||||||
|
BackupType: nextTarget.BackupType,
|
||||||
|
TargetName: nextTarget.TargetName,
|
||||||
|
TargetKind: nextTarget.TargetKind,
|
||||||
|
SessionState: formolv1alpha1.New,
|
||||||
|
StartTime: &metav1.Time{Time: time.Now()},
|
||||||
|
Try: 1,
|
||||||
}
|
}
|
||||||
|
switch nextTarget.BackupType {
|
||||||
|
case formolv1alpha1.JobKind:
|
||||||
|
r.Log.V(0).Info("Starts a new JobKind task", "target", nextTarget)
|
||||||
|
case formolv1alpha1.SnapshotKind:
|
||||||
|
r.Log.V(0).Info("Starts a new SnapshotKind task", "target", nextTarget)
|
||||||
|
}
|
||||||
|
return &nextTargetStatus, nil
|
||||||
|
} else {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user