Restore OnlineKind

This commit is contained in:
Jean-Marc ANDRE 2023-03-23 22:19:13 +01:00
parent 7e007bfd44
commit b2d80d66ae
6 changed files with 28 additions and 18 deletions

View File

@ -40,10 +40,11 @@ type TargetStatus struct {
TargetName string `json:"targetName"` TargetName string `json:"targetName"`
TargetKind `json:"targetKind"` TargetKind `json:"targetKind"`
SessionState `json:"state"` SessionState `json:"state"`
SnapshotId string `json:"snapshotId"` // +optional
StartTime *metav1.Time `json:"startTime"` SnapshotId string `json:"snapshotId,omitempty"`
Duration *metav1.Duration `json:"duration,omitempty"` StartTime *metav1.Time `json:"startTime"`
Try int `json:"try"` Duration *metav1.Duration `json:"duration,omitempty"`
Try int `json:"try"`
} }
// BackupSessionSpec defines the desired state of BackupSession // BackupSessionSpec defines the desired state of BackupSession

View File

@ -1,6 +1,7 @@
package v1alpha1 package v1alpha1
const ( const (
RESTORECONTAINER_NAME string = "formol-restore"
// the name of the sidecar container // the name of the sidecar container
SIDECARCONTAINER_NAME string = "formol" SIDECARCONTAINER_NAME string = "formol"
// the name of the container we backup when there are more than 1 container in the pod // the name of the container we backup when there are more than 1 container in the pod

View File

@ -27,7 +27,7 @@ type BackupSessionRef struct {
// RestoreSessionSpec defines the desired state of RestoreSession // RestoreSessionSpec defines the desired state of RestoreSession
type RestoreSessionSpec struct { type RestoreSessionSpec struct {
BackupSessionRef `json:"backupSessionRef"` BackupSessionRef `json:"backupSession"`
} }
// RestoreSessionStatus defines the observed state of RestoreSession // RestoreSessionStatus defines the observed state of RestoreSession

View File

@ -350,6 +350,11 @@ func (r *BackupConfigurationReconciler) createRBACSidecar(sa corev1.ServiceAccou
Name: FORMOL_SIDECAR_ROLE, Name: FORMOL_SIDECAR_ROLE,
}, },
Rules: []rbacv1.PolicyRule{ Rules: []rbacv1.PolicyRule{
rbacv1.PolicyRule{
Verbs: []string{"get", "list", "update"},
APIGroups: []string{"apps"},
Resources: []string{"deployments"},
},
rbacv1.PolicyRule{ rbacv1.PolicyRule{
Verbs: []string{"get", "list", "watch"}, Verbs: []string{"get", "list", "watch"},
APIGroups: []string{"formol.desmojim.fr"}, APIGroups: []string{"formol.desmojim.fr"},

View File

@ -58,7 +58,7 @@ func (r *RestoreSessionReconciler) Reconcile(ctx context.Context, req ctrl.Reque
if err := r.Get(r.Context, client.ObjectKey{ if err := r.Get(r.Context, client.ObjectKey{
Namespace: backupSession.Spec.Ref.Namespace, Namespace: backupSession.Spec.Ref.Namespace,
Name: backupSession.Spec.Ref.Name, Name: backupSession.Spec.Ref.Name,
}, &restoreSession); err != nil { }, &backupConf); err != nil {
r.Log.Error(err, "unable to get BackupConfiguration") r.Log.Error(err, "unable to get BackupConfiguration")
return ctrl.Result{}, err return ctrl.Result{}, err
} }

View File

@ -10,21 +10,24 @@ spec:
name: backup-demo name: backup-demo
namespace: demo namespace: demo
status: status:
keep: monthly keep: ""
startTime: "2021-05-01T22:15:28Z" startTime: "2023-03-20T20:47:08Z"
state: Success state: Success
target: target:
- duration: 17.952754232s - backupType: Online
kind: Sidecar duration: 3.189468146s
name: nginx-deployment snapshotId: 4730eaad
snapshotId: f411315c startTime: "2023-03-20T20:47:08Z"
startTime: "2021-05-01T22:15:34Z"
state: Success state: Success
targetKind: Deployment
targetName: apache-deployment
try: 1 try: 1
- duration: 25.46747271s - backupType: Job
kind: Job duration: 7.509060051s
name: backup-pg snapshotId: 4ddc5da1
snapshotId: ca673e5a startTime: "2023-03-20T20:47:08Z"
startTime: "2021-05-01T22:15:55Z"
state: Success state: Success
targetKind: StatefulSet
targetName: postgres-demo
try: 1 try: 1