forked from rockstor/rockstor-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert share ID during snapshot task restore rockstor#2355
We previously recreated a scheduled task of type snapshot literally from the config backup file. As share IDs are highly likely to differ between system installations, this resulted in scheduled tasks of type snapshot being re-created upon config backup restore against the wrong share. This commit fixes this by: 1. fetching the share name from the ID in the backup file (source) 2. fetching the corresponding share ID in the new (target) system 3. updating the restore API call accordingly This commit also fixes some related issues by: - updating the API endpoint for scheduled tasks following rockstor#2365 - continuing restore process if a taskdef fails to be validated rockstor#2355 Moreover, the current `restore_scheduled_tasks()` logic does both the preparation/parsing of the API payload, and the API call. This makes it difficult to test the former. This commit thus refactors this part to split into: - parsing/preparation: `validate_task_definitions()` - API call: `restore_scheduled_tasks()` Accordingly two new unit tests are included.
- Loading branch information
1 parent
f397bc9
commit 16edb07
Showing
3 changed files
with
275 additions
and
28 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
src/rockstor/storageadmin/fixtures/test_config_backup.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[ | ||
{ | ||
"model": "storageadmin.pool", | ||
"pk": 2, | ||
"fields": { | ||
"name": "rock-pool", | ||
"uuid": "3d60105b-abae-456f-bbd1-a5f410295e9c", | ||
"size": 5242880, | ||
"raid": "single", | ||
"toc": "2023-02-26T22:15:14.503Z", | ||
"compression": "no", | ||
"mnt_options": null, | ||
"role": null | ||
} | ||
}, | ||
{ | ||
"model": "storageadmin.share", | ||
"pk": 3, | ||
"fields": { | ||
"pool": 2, | ||
"qgroup": "0/301", | ||
"pqgroup": "2015/136", | ||
"name": "test_share01", | ||
"uuid": null, | ||
"size": 5242880, | ||
"owner": "root", | ||
"group": "root", | ||
"perms": "755", | ||
"toc": "2023-02-26T22:15:14.581Z", | ||
"subvol_name": "test_share01", | ||
"replica": false, | ||
"compression_algo": null, | ||
"rusage": 16, | ||
"eusage": 16, | ||
"pqgroup_rusage": 16, | ||
"pqgroup_eusage": 16 | ||
} | ||
}, | ||
{ | ||
"model": "storageadmin.share", | ||
"pk": 4, | ||
"fields": { | ||
"pool": 2, | ||
"qgroup": "0/302", | ||
"pqgroup": "2015/137", | ||
"name": "test_share02", | ||
"uuid": null, | ||
"size": 5242880, | ||
"owner": "root", | ||
"group": "root", | ||
"perms": "755", | ||
"toc": "2023-02-26T22:15:14.606Z", | ||
"subvol_name": "test_share02", | ||
"replica": false, | ||
"compression_algo": null, | ||
"rusage": 16, | ||
"eusage": 16, | ||
"pqgroup_rusage": 16, | ||
"pqgroup_eusage": 16 | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters