sureshanaparti commented on code in PR #13877:
URL: https://github.com/apache/cloudstack/pull/13877#discussion_r4033685270
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtTakeBackupCommandWrapper.java:
##########
@@ -69,8 +86,63 @@ public Answer execute(TakeBackupCommand command,
LibvirtComputingResource libvir
}
}
- List<String[]> commands = new ArrayList<>();
- commands.add(new String[]{
+ Pair<Integer, String> result =
runBackupScript(libvirtComputingResource, command, vmName, backupRepoType,
backupRepoAddress,
+ mountOptions, backupPath, diskPaths, command.getMode(),
+ command.getBitmapNew(), command.getBitmapParent(),
command.getParentPaths(), timeout);
+
+ if (result.first() != 0) {
+ logger.debug("Failed to take VM backup: " + result.second());
+ BackupAnswer answer = new BackupAnswer(command, false,
result.second().trim());
+ if (EXIT_CLEANUP_FAILED.equals(result.first())) {
+ logger.debug("Backup cleanup failed");
+ answer.setNeedsCleanup(true);
+ }
+ return answer;
+ }
+
+ // The script self-heals to a full backup when an incremental can't
proceed (e.g. the
+ // parent checkpoint can't be re-registered) and signals it with
INCREMENTAL_FALLBACK
+ // on stdout. Detect it, then strip the marker line before parsing the
backup size.
+ String rawStdout = result.second();
+ boolean incrementalFallback =
rawStdout.contains(INCREMENTAL_FALLBACK_MARKER);
+ String stdout = stripMarkerLines(rawStdout).trim();
+ long backupSize = parseBackupSize(stdout, diskPaths);
+
+ BackupAnswer answer = new BackupAnswer(command, true, stdout);
+ answer.setSize(backupSize);
+ // A successful run always created command.getBitmapNew() (full and
incremental both do;
+ // it is null for legacy-full, which the orchestrator treats as "no
bitmap").
+ answer.setBitmapCreated(command.getBitmapNew());
+ answer.setIncrementalFallback(incrementalFallback);
+ return answer;
+ }
+
+ /** Remove nasbackup.sh's stdout signalling marker lines so they don't
pollute size parsing. */
+ private String stripMarkerLines(String stdout) {
+ if (stdout == null || stdout.isEmpty()) {
Review Comment:
```suggestion
if (StringUtils.isBlank(stdout)) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]