linstor: try to delete -rst resource before snapshot backup (#10443)

If a -rst resource wasn't deleted because of a failed copy,
a reoccurring snapshot attempt couldn't be done, because there
was still the "old" -rst resource. To prevent this always
try to remove the -rst resource before, if it doesn't exist it is a noop.
This commit is contained in:
Rene Peinthor 2025-03-10 16:23:01 +01:00 committed by GitHub
parent 8ce34ad791
commit 95c24810ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 11 deletions

View File

@ -5,6 +5,12 @@ All notable changes to Linstor CloudStack plugin will be documented in this file
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2025-02-21]
### Fixed
- Always try to delete cs-...-rst resource before doing a snapshot backup
## [2025-01-27] ## [2025-01-27]
### Fixed ### Fixed

View File

@ -1117,6 +1117,8 @@ public class LinstorPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
String snapshotName, String snapshotName,
String restoredName) throws ApiException { String restoredName) throws ApiException {
final String rscGrp = getRscGrp(storagePoolVO); final String rscGrp = getRscGrp(storagePoolVO);
// try to delete -rst resource, could happen if the copy failed and noone deleted it.
deleteResourceDefinition(storagePoolVO, restoredName);
ResourceDefinitionCreate rdc = createResourceDefinitionCreate(restoredName, rscGrp); ResourceDefinitionCreate rdc = createResourceDefinitionCreate(restoredName, rscGrp);
api.resourceDefinitionCreate(rdc); api.resourceDefinitionCreate(rdc);
@ -1259,19 +1261,22 @@ public class LinstorPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
throws ApiException { throws ApiException {
Answer answer; Answer answer;
String restoreName = rscName + "-rst"; String restoreName = rscName + "-rst";
String devName = restoreResourceFromSnapshot(api, pool, rscName, snapshotName, restoreName); try {
String devName = restoreResourceFromSnapshot(api, pool, rscName, snapshotName, restoreName);
Optional<RemoteHostEndPoint> optEPAny = getLinstorEP(api, restoreName); Optional<RemoteHostEndPoint> optEPAny = getLinstorEP(api, restoreName);
if (optEPAny.isPresent()) { if (optEPAny.isPresent()) {
// patch the src device path to the temporary linstor resource // patch the src device path to the temporary linstor resource
snapshotObject.setPath(devName); snapshotObject.setPath(devName);
origCmd.setSrcTO(snapshotObject.getTO()); origCmd.setSrcTO(snapshotObject.getTO());
answer = optEPAny.get().sendMessage(origCmd); answer = optEPAny.get().sendMessage(origCmd);
} else{ } else{
answer = new Answer(origCmd, false, "Unable to get matching Linstor endpoint."); answer = new Answer(origCmd, false, "Unable to get matching Linstor endpoint.");
}
} finally {
// delete the temporary resource, noop if already gone
api.resourceDefinitionDelete(restoreName);
} }
// delete the temporary resource, noop if already gone
api.resourceDefinitionDelete(restoreName);
return answer; return answer;
} }