Merge release branch 4.20 to main

* 4.20:
  Fix Stats Collector to not divide by zero (#10492)
  linstor: try to delete -rst resource before snapshot backup (#10443)
This commit is contained in:
Daan Hoogland 2025-03-12 11:31:56 +01:00
commit 9c6f2a9e14
3 changed files with 24 additions and 13 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/),
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]
### Fixed

View File

@ -1119,6 +1119,8 @@ public class LinstorPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
String snapshotName,
String restoredName) throws ApiException {
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);
api.resourceDefinitionCreate(rdc);
@ -1261,6 +1263,7 @@ public class LinstorPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
throws ApiException {
Answer answer;
String restoreName = rscName + "-rst";
try {
String devName = restoreResourceFromSnapshot(api, pool, rscName, snapshotName, restoreName);
Optional<RemoteHostEndPoint> optEPAny = getLinstorEP(api, restoreName);
@ -1272,8 +1275,10 @@ public class LinstorPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
} else{
answer = new Answer(origCmd, false, "Unable to get matching Linstor endpoint.");
}
} finally {
// delete the temporary resource, noop if already gone
api.resourceDefinitionDelete(restoreName);
}
return answer;
}

View File

@ -718,10 +718,10 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
getDynamicDataFromDB();
long interval = (Long) dbStats.get(uptime) - lastUptime;
long activity = (Long) dbStats.get(queries) - lastQueries;
loadHistory.add(0, Double.valueOf(activity / interval));
loadHistory.add(0, interval == 0 ? -1 : Double.valueOf(activity / interval));
int maxsize = DATABASE_SERVER_LOAD_HISTORY_RETENTION_NUMBER.value();
while (loadHistory.size() > maxsize) {
loadHistory.remove(maxsize - 1);
loadHistory.remove(maxsize);
}
} catch (Throwable e) {
// pokemon catch to make sure the thread stays running