mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-07-28 19:12:43 +00:00
add backup exposer for block data mover
Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
@@ -150,7 +150,7 @@ func (r *DataDownloadReconciler) Reconcile(ctx context.Context, req ctrl.Request
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
if !datamover.IsBuiltInUploader(dd.Spec.DataMover) {
|
||||
if !datamover.IsBuiltInDataMover(dd.Spec.DataMover) {
|
||||
log.WithField("data mover", dd.Spec.DataMover).Info("it is not one built-in data mover which is not supported by Velero")
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ func (r *DataUploadReconciler) Reconcile(ctx context.Context, req ctrl.Request)
|
||||
return ctrl.Result{}, errors.Wrap(err, "getting DataUpload")
|
||||
}
|
||||
|
||||
if !datamover.IsBuiltInUploader(du.Spec.DataMover) {
|
||||
if !datamover.IsBuiltInDataMover(du.Spec.DataMover) {
|
||||
log.WithField("Data mover", du.Spec.DataMover).Debug("it is not one built-in data mover which is not supported by Velero")
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
@@ -937,7 +937,7 @@ func (r *DataUploadReconciler) setupExposeParam(du *velerov2alpha1api.DataUpload
|
||||
}
|
||||
|
||||
nodeOS := ""
|
||||
if du.Spec.DataMover == velerotypes.DataMoverTypeVeleroBlock {
|
||||
if du.Spec.DataMover == datamover.DataMoverTypeVeleroBlock {
|
||||
nodeOS = kube.NodeOSLinux
|
||||
} else {
|
||||
nodeOS = kube.GetPVCAttachingNodeOS(pvc, r.kubeClient.CoreV1(), r.kubeClient.StorageV1(), log)
|
||||
@@ -1015,6 +1015,7 @@ func (r *DataUploadReconciler) setupExposeParam(du *velerov2alpha1api.DataUpload
|
||||
Resources: r.podResources,
|
||||
NodeOS: nodeOS,
|
||||
PriorityClassName: r.dataMovePriorityClass,
|
||||
DataMover: du.Spec.DataMover,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ func (d *DataUploadDeleteAction) Execute(input *velero.DeleteItemActionExecuteIn
|
||||
|
||||
// generate the configmap which is to be created and used as a way to communicate the snapshot info to the backup deletion controller
|
||||
func genConfigmap(bak *velerov1.Backup, du velerov2alpha1.DataUpload) *corev1api.ConfigMap {
|
||||
if !IsBuiltInUploader(du.Spec.DataMover) || du.Status.SnapshotID == "" {
|
||||
if !IsBuiltInDataMover(du.Spec.DataMover) || du.Status.SnapshotID == "" {
|
||||
return nil
|
||||
}
|
||||
snapshot := repotypes.SnapshotIdentifier{
|
||||
|
||||
@@ -18,6 +18,11 @@ package datamover
|
||||
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
DataMoverTypeVeleroFs string = "velero-fs"
|
||||
DataMoverTypeVeleroBlock string = "velero-block"
|
||||
)
|
||||
|
||||
func GetUploaderType(dataMover string) string {
|
||||
if dataMover == "" || dataMover == "velero" {
|
||||
return "kopia"
|
||||
@@ -26,7 +31,7 @@ func GetUploaderType(dataMover string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func IsBuiltInUploader(dataMover string) bool {
|
||||
func IsBuiltInDataMover(dataMover string) bool {
|
||||
return dataMover == "" || dataMover == "velero"
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestIsBuiltInUploader(t *testing.T) {
|
||||
}
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(tt *testing.T) {
|
||||
assert.Equal(tt, tc.want, IsBuiltInUploader(tc.dataMover))
|
||||
assert.Equal(tt, tc.want, IsBuiltInDataMover(tc.dataMover))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import (
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/vmware-tanzu/velero/pkg/datamover"
|
||||
"github.com/vmware-tanzu/velero/pkg/nodeagent"
|
||||
velerotypes "github.com/vmware-tanzu/velero/pkg/types"
|
||||
"github.com/vmware-tanzu/velero/pkg/util"
|
||||
@@ -97,9 +98,6 @@ type CSISnapshotExposeParam struct {
|
||||
|
||||
// DataMover is the data mover type, e.g., velero-fs, velero-block
|
||||
DataMover string
|
||||
|
||||
// CSISnapshotMetadataServiceConfigs is the config for CSI snapshot metadata service
|
||||
CSISnapshotMetadataServiceConfigs *velerotypes.CSISnapshotMetadataService
|
||||
}
|
||||
|
||||
// CSISnapshotExposeWaitParam define the input param for WaitExposed of CSI snapshots
|
||||
@@ -271,7 +269,6 @@ func (e *csiSnapshotExposer) Expose(ctx context.Context, ownerObject corev1api.O
|
||||
csiExposeParam.PriorityClassName,
|
||||
intoleratableNodes,
|
||||
volumeTopology,
|
||||
csiExposeParam.CSISnapshotMetadataServiceConfigs,
|
||||
)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error to create backup pod")
|
||||
@@ -459,7 +456,7 @@ func (e *csiSnapshotExposer) CleanUp(ctx context.Context, ownerObject corev1api.
|
||||
}
|
||||
|
||||
func getVolumeModeByAccessMode(accessMode string, dataMover string) (corev1api.PersistentVolumeMode, error) {
|
||||
if dataMover == velerotypes.DataMoverTypeVeleroBlock {
|
||||
if dataMover == datamover.DataMoverTypeVeleroBlock {
|
||||
return corev1api.PersistentVolumeBlock, nil
|
||||
}
|
||||
|
||||
@@ -616,7 +613,6 @@ func (e *csiSnapshotExposer) createBackupPod(
|
||||
priorityClassName string,
|
||||
intoleratableNodes []string,
|
||||
volumeTopology *corev1api.NodeSelector,
|
||||
csiSnapshotMetadataServiceConfigs *velerotypes.CSISnapshotMetadataService,
|
||||
) (*corev1api.Pod, error) {
|
||||
podName := ownerObject.Name
|
||||
|
||||
@@ -672,12 +668,6 @@ func (e *csiSnapshotExposer) createBackupPod(
|
||||
args = append(args, podInfo.logFormatArgs...)
|
||||
args = append(args, podInfo.logLevelArgs...)
|
||||
|
||||
if csiSnapshotMetadataServiceConfigs != nil {
|
||||
if csiSnapshotMetadataServiceConfigs.SAName != "" {
|
||||
args = append(args, fmt.Sprintf("--csi-snapshot-metadata-service-sa=%s", csiSnapshotMetadataServiceConfigs.SAName))
|
||||
}
|
||||
}
|
||||
|
||||
if affinity == nil {
|
||||
affinity = &kube.LoadAffinity{}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,6 @@ func TestCreateBackupPodWithPriorityClass(t *testing.T) {
|
||||
tc.expectedPriorityClass,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
require.NoError(t, err, tc.description)
|
||||
@@ -242,7 +241,6 @@ func TestCreateBackupPodWithMissingConfigMap(t *testing.T) {
|
||||
"", // empty priority class since config map is missing
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
// Should succeed even when config map is missing
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
Copyright The Velero Contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package types
|
||||
|
||||
const (
|
||||
DataMoverTypeVeleroFs string = "velero-fs"
|
||||
DataMoverTypeVeleroBlock string = "velero-block"
|
||||
)
|
||||
@@ -74,10 +74,6 @@ type CachePVC struct {
|
||||
ResidentThresholdInMB int64 `json:"residentThresholdInMB,omitempty"`
|
||||
}
|
||||
|
||||
type CSISnapshotMetadataService struct {
|
||||
SAName string `json:"saName,omitempty"`
|
||||
}
|
||||
|
||||
type NodeAgentConfigs struct {
|
||||
// LoadConcurrency is the config for data path load concurrency per node.
|
||||
LoadConcurrency *LoadConcurrency `json:"loadConcurrency,omitempty"`
|
||||
@@ -108,7 +104,4 @@ type NodeAgentConfigs struct {
|
||||
|
||||
// PodLabels are labels to be added to pods created by node-agent, i.e., data mover pods.
|
||||
PodLabels map[string]string `json:"podLabels,omitempty"`
|
||||
|
||||
// CSISnapshotMetadataServiceConfigs is the config for CSI snapshot metadata service
|
||||
CSISnapshotMetadataServiceConfigs *CSISnapshotMetadataService `json:"csiSnapshotMetadataServiceConfigs,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user