VolumeSnapshot will be deleted by the Job
This commit is contained in:
parent
9a49ac96c4
commit
1de6a31e25
@ -127,8 +127,6 @@ func (r *BackupSessionReconciler) Reconcile(ctx context.Context, req ctrl.Reques
|
|||||||
default:
|
default:
|
||||||
r.Log.Error(err, "unable to do snapshot backup")
|
r.Log.Error(err, "unable to do snapshot backup")
|
||||||
// TODO: cleanup existing snapshots
|
// TODO: cleanup existing snapshots
|
||||||
r.deleteVolumeSnapshots(target)
|
|
||||||
newSessionState = formolv1alpha1.Failure
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,10 +95,9 @@ func (r *BackupSessionReconciler) backupSnapshot(target formolv1alpha1.Target) e
|
|||||||
// sidecar := formolv1alpha1.GetSidecar(backupConf, target)
|
// sidecar := formolv1alpha1.GetSidecar(backupConf, target)
|
||||||
_, vms := formolv1alpha1.GetVolumeMounts(container, targetContainer)
|
_, vms := formolv1alpha1.GetVolumeMounts(container, targetContainer)
|
||||||
if err := r.snapshotVolumes(vms, targetPodSpec); err != nil {
|
if err := r.snapshotVolumes(vms, targetPodSpec); err != nil {
|
||||||
switch err.(type) {
|
if IsNotReadyToUse(err) {
|
||||||
case *NotReadyToUseError:
|
|
||||||
r.Log.V(0).Info("Some volumes are still not ready to use")
|
r.Log.V(0).Info("Some volumes are still not ready to use")
|
||||||
default:
|
} else {
|
||||||
r.Log.Error(err, "cannot snapshot the volumes")
|
r.Log.Error(err, "cannot snapshot the volumes")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -225,7 +224,7 @@ func (r *BackupSessionReconciler) createVolumeFromSnapshot(vs *volumesnapshotv1.
|
|||||||
Spec: corev1.PersistentVolumeClaimSpec{
|
Spec: corev1.PersistentVolumeClaimSpec{
|
||||||
StorageClassName: &pv.Spec.StorageClassName,
|
StorageClassName: &pv.Spec.StorageClassName,
|
||||||
//AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadOnlyMany},
|
//AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadOnlyMany},
|
||||||
AccessModes: pv.Spec.AccessModes,
|
AccessModes: pv.Spec.AccessModes,
|
||||||
DataSource: &corev1.TypedLocalObjectReference{
|
DataSource: &corev1.TypedLocalObjectReference{
|
||||||
APIGroup: func() *string { s := "snapshot.storage.k8s.io"; return &s }(),
|
APIGroup: func() *string { s := "snapshot.storage.k8s.io"; return &s }(),
|
||||||
Kind: "VolumeSnapshot",
|
Kind: "VolumeSnapshot",
|
||||||
@ -264,11 +263,11 @@ func (r *BackupSessionReconciler) snapshotVolumes(vms []corev1.VolumeMount, podS
|
|||||||
backupPVCName, err := r.createVolumeFromSnapshot(vs)
|
backupPVCName, err := r.createVolumeFromSnapshot(vs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Log.Error(err, "unable to create volume from snapshot", "vs", vs)
|
r.Log.Error(err, "unable to create volume from snapshot", "vs", vs)
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
podSpec.Volumes[i].VolumeSource.PersistentVolumeClaim = &corev1.PersistentVolumeClaimVolumeSource{
|
podSpec.Volumes[i].VolumeSource.PersistentVolumeClaim = &corev1.PersistentVolumeClaimVolumeSource{
|
||||||
ClaimName: backupPVCName,
|
ClaimName: backupPVCName,
|
||||||
ReadOnly: true,
|
ReadOnly: true,
|
||||||
}
|
}
|
||||||
// The snapshot and the volume will be deleted by the Job when the backup is over
|
// The snapshot and the volume will be deleted by the Job when the backup is over
|
||||||
}
|
}
|
||||||
@ -277,7 +276,3 @@ func (r *BackupSessionReconciler) snapshotVolumes(vms []corev1.VolumeMount, podS
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *BackupSessionReconciler) deleteVolumeSnapshots(target formolv1alpha1.Target) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|||||||
2
formol
2
formol
@ -1 +1 @@
|
|||||||
Subproject commit 61f45a79404e1f71d9f7661d295d6ac3cd07dd8c
|
Subproject commit 8975f77e5858ee167508ef0359c3b9d6cbaba6ee
|
||||||
Loading…
Reference in New Issue
Block a user