mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-15 19:56:06 +00:00
Add "SnapshotClass" to DataUploadResult (#10227)
Add "SnapshotClass" to DataUploadResult Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Add "SnapshotClass" to DataUploadResult
|
||||
@@ -268,4 +268,8 @@ type DataUploadResult struct {
|
||||
// FSType is the file system type of the volume.
|
||||
// +optional
|
||||
FSType string `json:"fsType,omitempty"`
|
||||
|
||||
// SnapshotClass is the name of the snapshot class that the volume snapshot is created with
|
||||
// +optional
|
||||
SnapshotClass string `json:"snapshotClass,omitempty"`
|
||||
}
|
||||
|
||||
@@ -82,6 +82,9 @@ func (d *DataUploadRetrieveAction) Execute(input *velero.RestoreItemActionExecut
|
||||
NodeOS: dataUpload.Status.NodeOS,
|
||||
FSType: dataUpload.Spec.SourceFSType,
|
||||
}
|
||||
if dataUpload.Spec.CSISnapshot != nil {
|
||||
dataUploadResult.SnapshotClass = dataUpload.Spec.CSISnapshot.SnapshotClass
|
||||
}
|
||||
|
||||
jsonBytes, err := json.Marshal(dataUploadResult)
|
||||
if err != nil {
|
||||
|
||||
@@ -66,6 +66,29 @@ func TestDataUploadRetrieveActionExectue(t *testing.T) {
|
||||
},
|
||||
expectedDataUploadResult: builder.ForConfigMap("velero", "").ObjectMeta(builder.WithGenerateName("testDU-"), builder.WithLabels(velerov1.PVCNamespaceNameLabel, "testNamespace.testPVC", velerov1.RestoreUIDLabel, "testingUID", velerov1.ResourceUsageLabel, string(velerov1.VeleroResourceUsageDataUploadResult))).Data("testingUID", `{"backupStorageLocation":"testLocation","snapshotID":"fake-id","sourceNamespace":"testNamespace","snapshotSize":1000}`).Result(),
|
||||
},
|
||||
{
|
||||
name: "DataUploadRetrieve Action test with optional fields",
|
||||
dataUpload: func() *velerov2alpha1.DataUpload {
|
||||
du := builder.ForDataUpload("velero", "testDU").
|
||||
SourceNamespace("testNamespace").
|
||||
SourcePVC("testPVC").
|
||||
SnapshotID("fake-id").
|
||||
TotalBytes(1000).
|
||||
DataMover("velero").
|
||||
NodeOS("linux").
|
||||
CSISnapshot(&velerov2alpha1.CSISnapshotSpec{SnapshotClass: "testClass"}).
|
||||
Result()
|
||||
du.Status.DataMoverResult = &map[string]string{"key": "value"}
|
||||
du.Spec.SourceFSType = "ext4"
|
||||
return du
|
||||
}(),
|
||||
restore: builder.ForRestore("velero", "testRestore").ObjectMeta(builder.WithUID("testingUID")).Backup("testBackup").Result(),
|
||||
runtimeScheme: scheme,
|
||||
veleroObjs: []runtime.Object{
|
||||
builder.ForBackup("velero", "testBackup").StorageLocation("testLocation").Result(),
|
||||
},
|
||||
expectedDataUploadResult: builder.ForConfigMap("velero", "").ObjectMeta(builder.WithGenerateName("testDU-"), builder.WithLabels(velerov1.PVCNamespaceNameLabel, "testNamespace.testPVC", velerov1.RestoreUIDLabel, "testingUID", velerov1.ResourceUsageLabel, string(velerov1.VeleroResourceUsageDataUploadResult))).Data("testingUID", `{"backupStorageLocation":"testLocation","datamover":"velero","snapshotID":"fake-id","sourceNamespace":"testNamespace","dataMoverResult":{"key":"value"},"nodeOS":"linux","snapshotSize":1000,"fsType":"ext4","snapshotClass":"testClass"}`).Result(),
|
||||
},
|
||||
{
|
||||
name: "Long source namespace and PVC name should also work",
|
||||
dataUpload: builder.ForDataUpload("velero", "testDU").SourceNamespace("migre209d0da-49c7-45ba-8d5a-3e59fd591ec1").SourcePVC("kibishii-data-kibishii-deployment-0").Result(),
|
||||
|
||||
Reference in New Issue
Block a user