mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-07-19 14:32:36 +00:00
support fsType for data mover
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -121,6 +121,9 @@ spec:
|
||||
description: TargetVolume is the information of the target PVC and
|
||||
PV.
|
||||
properties:
|
||||
fsType:
|
||||
description: FSType is the file system type of the target volume.
|
||||
type: string
|
||||
namespace:
|
||||
description: Namespace is the target namespace
|
||||
type: string
|
||||
|
||||
@@ -133,6 +133,9 @@ spec:
|
||||
description: SnapshotType is the type of the snapshot to be backed
|
||||
up.
|
||||
type: string
|
||||
sourceFSType:
|
||||
description: SourceFSType is the file system type of the source volume.
|
||||
type: string
|
||||
sourceNamespace:
|
||||
description: |-
|
||||
SourceNamespace is the original namespace where the volume is backed up from.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -74,6 +74,10 @@ type TargetVolumeSpec struct {
|
||||
|
||||
// Namespace is the target namespace
|
||||
Namespace string `json:"namespace"`
|
||||
|
||||
// FSType is the file system type of the target volume.
|
||||
// +optional
|
||||
FSType string `json:"fsType,omitempty"`
|
||||
}
|
||||
|
||||
// DataDownloadPhase represents the lifecycle phase of a DataDownload.
|
||||
|
||||
@@ -60,6 +60,10 @@ type DataUploadSpec struct {
|
||||
// OperationTimeout specifies the time used to wait internal operations,
|
||||
// before returning error as timeout.
|
||||
OperationTimeout metav1.Duration `json:"operationTimeout"`
|
||||
|
||||
// SourceFSType is the file system type of the source volume.
|
||||
// +optional
|
||||
SourceFSType string `json:"sourceFSType,omitempty"`
|
||||
}
|
||||
|
||||
type SnapshotType string
|
||||
@@ -253,4 +257,8 @@ type DataUploadResult struct {
|
||||
// SnapshotSize is the logical size in Bytes of the snapshot.
|
||||
// +optional
|
||||
SnapshotSize int64 `json:"snapshotSize,omitempty"`
|
||||
|
||||
// FSType is the file system type of the volume.
|
||||
// +optional
|
||||
FSType string `json:"fsType,omitempty"`
|
||||
}
|
||||
|
||||
@@ -166,6 +166,7 @@ func (p *pvcBackupItemAction) validatePVCandPV(
|
||||
) (
|
||||
valid bool,
|
||||
updateItem runtime.Unstructured,
|
||||
fsType string,
|
||||
err error,
|
||||
) {
|
||||
updateItem = item
|
||||
@@ -174,6 +175,7 @@ func (p *pvcBackupItemAction) validatePVCandPV(
|
||||
if pvc.Spec.StorageClassName == nil {
|
||||
return false,
|
||||
updateItem,
|
||||
"",
|
||||
errors.Errorf(
|
||||
"Cannot snapshot PVC %s/%s, PVC has no storage class.",
|
||||
pvc.Namespace, pvc.Name)
|
||||
@@ -187,7 +189,7 @@ func (p *pvcBackupItemAction) validatePVCandPV(
|
||||
// Do nothing if this is not a CSI provisioned volume
|
||||
pv, err := kubeutil.GetPVForPVC(&pvc, p.crClient)
|
||||
if err != nil {
|
||||
return false, updateItem, errors.WithStack(err)
|
||||
return false, updateItem, "", errors.WithStack(err)
|
||||
}
|
||||
|
||||
if pv.Spec.PersistentVolumeSource.CSI == nil {
|
||||
@@ -202,10 +204,10 @@ func (p *pvcBackupItemAction) validatePVCandPV(
|
||||
})
|
||||
data, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&pvc)
|
||||
updateItem = &unstructured.Unstructured{Object: data}
|
||||
return false, updateItem, err
|
||||
return false, updateItem, "", err
|
||||
}
|
||||
|
||||
return true, updateItem, nil
|
||||
return true, updateItem, pv.Spec.PersistentVolumeSource.CSI.FSType, nil
|
||||
}
|
||||
|
||||
func (p *pvcBackupItemAction) createVolumeSnapshot(
|
||||
@@ -301,10 +303,12 @@ func (p *pvcBackupItemAction) Execute(
|
||||
); err != nil {
|
||||
return nil, nil, "", nil, errors.WithStack(err)
|
||||
}
|
||||
if valid, item, err := p.validatePVCandPV(
|
||||
|
||||
valid, item, fsType, err := p.validatePVCandPV(
|
||||
pvc,
|
||||
item,
|
||||
); !valid {
|
||||
)
|
||||
if !valid {
|
||||
if err != nil {
|
||||
return nil, nil, "", nil, err
|
||||
}
|
||||
@@ -392,6 +396,7 @@ func (p *pvcBackupItemAction) Execute(
|
||||
&pvc,
|
||||
operationID,
|
||||
vsc,
|
||||
fsType,
|
||||
)
|
||||
if err != nil {
|
||||
dataUploadLog.WithError(err).Error("failed to submit DataUpload")
|
||||
@@ -530,6 +535,7 @@ func newDataUpload(
|
||||
pvc *corev1api.PersistentVolumeClaim,
|
||||
operationID string,
|
||||
vsc *snapshotv1api.VolumeSnapshotContent,
|
||||
fsType string,
|
||||
) *velerov2alpha1.DataUpload {
|
||||
dataUpload := &velerov2alpha1.DataUpload{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
@@ -567,6 +573,7 @@ func newDataUpload(
|
||||
BackupStorageLocation: backup.Spec.StorageLocation,
|
||||
SourceNamespace: pvc.Namespace,
|
||||
OperationTimeout: backup.Spec.CSISnapshotTimeout,
|
||||
SourceFSType: fsType,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -591,8 +598,9 @@ func createDataUpload(
|
||||
pvc *corev1api.PersistentVolumeClaim,
|
||||
operationID string,
|
||||
vsc *snapshotv1api.VolumeSnapshotContent,
|
||||
fsType string,
|
||||
) (*velerov2alpha1.DataUpload, error) {
|
||||
dataUpload := newDataUpload(backup, vs, pvc, operationID, vsc)
|
||||
dataUpload := newDataUpload(backup, vs, pvc, operationID, vsc, fsType)
|
||||
|
||||
err := crClient.Create(ctx, dataUpload)
|
||||
if err != nil {
|
||||
|
||||
@@ -479,6 +479,7 @@ func (r *DataDownloadReconciler) OnDataDownloadCompleted(ctx context.Context, na
|
||||
TargetPVCName: dd.Spec.TargetVolume.PVC,
|
||||
TargetNamespace: dd.Spec.TargetVolume.Namespace,
|
||||
OperationTimeout: dd.Spec.OperationTimeout.Duration,
|
||||
TargetFSType: dd.Spec.TargetVolume.FSType,
|
||||
})
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to rebind PV to target PVC on completion")
|
||||
|
||||
@@ -91,6 +91,9 @@ type GenericRestoreRebindVolumeParam struct {
|
||||
|
||||
// OperationTimeout specifies the time wait for resources operations in Expose
|
||||
OperationTimeout time.Duration
|
||||
|
||||
// TargetFSType is the file system type of the target volume
|
||||
TargetFSType string
|
||||
}
|
||||
|
||||
// GenericRestoreExposer is the interfaces for a generic restore exposer
|
||||
|
||||
@@ -427,6 +427,7 @@ func newDataDownload(
|
||||
TargetVolume: velerov2alpha1.TargetVolumeSpec{
|
||||
PVC: pvc.Name,
|
||||
Namespace: newNamespace,
|
||||
FSType: dataUploadResult.FSType,
|
||||
},
|
||||
BackupStorageLocation: dataUploadResult.BackupStorageLocation,
|
||||
DataMover: dataUploadResult.DataMover,
|
||||
|
||||
@@ -80,6 +80,7 @@ func (d *DataUploadRetrieveAction) Execute(input *velero.RestoreItemActionExecut
|
||||
SourceNamespace: dataUpload.Spec.SourceNamespace,
|
||||
DataMoverResult: dataUpload.Status.DataMoverResult,
|
||||
NodeOS: dataUpload.Status.NodeOS,
|
||||
FSType: dataUpload.Spec.SourceFSType,
|
||||
}
|
||||
|
||||
jsonBytes, err := json.Marshal(dataUploadResult)
|
||||
|
||||
Reference in New Issue
Block a user