Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backup, restore): create backup and restore in cstor.openebs.io/v1 group #192

Merged
merged 1 commit into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/server/cstorvolumeconfig/backup_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ func (bOps *backupAPIOps) getBackupInterfaceFromPoolVersion(
poolVersion string, backup *cstorapis.CStorBackup) (backupHelper, error) {
// error will be reported when version doesn't contain any valid version pattern
// Ex: dev, ci, master
currentVersion, err := version.NewVersion(poolVersion)
// Spliting required if version contains RC1, RC2 to make comparisions
currentVersion, err := version.NewVersion(strings.Split(poolVersion, "-")[0])
if err != nil {
// We need to support backup for ci images also
if strings.TrimSpace(poolVersion) != "" && !strings.Contains(poolVersion, "dev") {
Expand Down
55 changes: 55 additions & 0 deletions pkg/server/cstorvolumeconfig/https_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,27 @@ func TestBackupPostEndPoint(t *testing.T) {
checkExistenceOfCStorCompletedBackup: true,
isV1Version: true,
},
"test backup when pool is in RC versions": {
cspcName: "cspc-disk-pool7",
poolVersion: "2.2.0-RC2",
cstorBackup: &openebsapis.CStorBackup{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
},
Spec: openebsapis.CStorBackupSpec{
BackupName: "backup7",
VolumeName: "volume7",
BackupDest: "172.102.29.12:3234",
SnapName: "snapshot7",
},
},
snapshotter: &snapshot.FakeSnapshotter{},
cvrStatus: cstorapis.CVRStatusOnline,
expectedResponseCode: http.StatusOK,
verifyBackUpStatus: verifyExistenceOfPendingV1Backup,
checkExistenceOfCStorCompletedBackup: true,
isV1Version: true,
},
}
os.Setenv(util.OpenEBSNamespace, "openebs")
for name, test := range tests {
Expand Down Expand Up @@ -1251,6 +1272,40 @@ func TestRestoreEndPoint(t *testing.T) {
verifyCStorRestoreCount: true,
isV1Version: true,
},
"When restore is triggered for pools on v1 supported RC version": {
cspcName: "cspc-cstor-pool9",
poolVersion: "2.2.0-RC3",
cstorRestore: &openebsapis.CStorRestore{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
},
Spec: openebsapis.CStorRestoreSpec{
RestoreName: "restore9",
VolumeName: "volume9",
RestoreSrc: "127.0.0.1:3422",
},
},
cvcObj: &cstorapis.CStorVolumeConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "volume9",
Namespace: namespace,
Labels: map[string]string{
openebstypes.CStorPoolClusterLabelKey: "cspc-cstor-pool9",
},
},
Spec: cstorapis.CStorVolumeConfigSpec{
Provision: cstorapis.VolumeProvision{
ReplicaCount: 3,
},
},
Status: cstorapis.CStorVolumeConfigStatus{
Phase: cstorapis.CStorVolumeConfigPhasePending,
},
},
expectedResponseCode: http.StatusOK,
verifyCStorRestoreCount: true,
isV1Version: true,
},
}
start := make(chan int, 1)
defer close(start)
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/cstorvolumeconfig/restore_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func createRestore(openebsClient clientset.Interface, restoreObj *cstorapis.CSto
if _, ok := cspiToCVRMap[cspi.Name]; !ok {
continue
}
poolVersion, err := version.NewVersion(cspiVersion)
poolVersion, err := version.NewVersion(strings.Split(cspiVersion, "-")[0])
// If Current version is empty treat it as a ci
if err != nil && (cspiVersion != "" && !strings.Contains(cspiVersion, "dev")) {
return nil, CodedError(500,
Expand Down