Skip to content

Commit f8adedc

Browse files
committed
Merge release branch 4.19 to 4.20
* 4.19: linstor: try to delete -rst resource before snapshot backup (#10443)
2 parents 54c1f92 + 95c2481 commit f8adedc

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

plugins/storage/volume/linstor/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to Linstor CloudStack plugin will be documented in this file
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2025-02-21]
9+
10+
### Fixed
11+
12+
- Always try to delete cs-...-rst resource before doing a snapshot backup
13+
814
## [2025-01-27]
915

1016
### Fixed

plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,8 @@ private String restoreResourceFromSnapshot(
11191119
String snapshotName,
11201120
String restoredName) throws ApiException {
11211121
final String rscGrp = getRscGrp(storagePoolVO);
1122+
// try to delete -rst resource, could happen if the copy failed and noone deleted it.
1123+
deleteResourceDefinition(storagePoolVO, restoredName);
11221124
ResourceDefinitionCreate rdc = createResourceDefinitionCreate(restoredName, rscGrp);
11231125
api.resourceDefinitionCreate(rdc);
11241126

@@ -1261,19 +1263,22 @@ private Answer copyFromTemporaryResource(
12611263
throws ApiException {
12621264
Answer answer;
12631265
String restoreName = rscName + "-rst";
1264-
String devName = restoreResourceFromSnapshot(api, pool, rscName, snapshotName, restoreName);
1265-
1266-
Optional<RemoteHostEndPoint> optEPAny = getLinstorEP(api, restoreName);
1267-
if (optEPAny.isPresent()) {
1268-
// patch the src device path to the temporary linstor resource
1269-
snapshotObject.setPath(devName);
1270-
origCmd.setSrcTO(snapshotObject.getTO());
1271-
answer = optEPAny.get().sendMessage(origCmd);
1272-
} else{
1273-
answer = new Answer(origCmd, false, "Unable to get matching Linstor endpoint.");
1266+
try {
1267+
String devName = restoreResourceFromSnapshot(api, pool, rscName, snapshotName, restoreName);
1268+
1269+
Optional<RemoteHostEndPoint> optEPAny = getLinstorEP(api, restoreName);
1270+
if (optEPAny.isPresent()) {
1271+
// patch the src device path to the temporary linstor resource
1272+
snapshotObject.setPath(devName);
1273+
origCmd.setSrcTO(snapshotObject.getTO());
1274+
answer = optEPAny.get().sendMessage(origCmd);
1275+
} else{
1276+
answer = new Answer(origCmd, false, "Unable to get matching Linstor endpoint.");
1277+
}
1278+
} finally {
1279+
// delete the temporary resource, noop if already gone
1280+
api.resourceDefinitionDelete(restoreName);
12741281
}
1275-
// delete the temporary resource, noop if already gone
1276-
api.resourceDefinitionDelete(restoreName);
12771282
return answer;
12781283
}
12791284

0 commit comments

Comments
 (0)