Skip to content

Commit 369023b

Browse files
committed
Introduce configurable timeout to Create NAS backup
1 parent 59b6c32 commit 369023b

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

core/src/main/java/org/apache/cloudstack/backup/TakeBackupCommand.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class TakeBackupCommand extends Command {
3535
private Boolean quiesce;
3636
@LogLevel(LogLevel.Log4jLevel.Off)
3737
private String mountOptions;
38+
private Integer timeout;
3839

3940
public TakeBackupCommand(String vmName, String backupPath) {
4041
super();
@@ -106,6 +107,14 @@ public void setQuiesce(Boolean quiesce) {
106107
this.quiesce = quiesce;
107108
}
108109

110+
public Integer getTimeout() {
111+
return this.timeout == null ? 0 : this.timeout;
112+
}
113+
114+
public void setTimeout(Integer timeout) {
115+
this.timeout = timeout;
116+
}
117+
109118
@Override
110119
public boolean executeInSequence() {
111120
return true;

plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ public class NASBackupProvider extends AdapterBase implements BackupProvider, Co
8585
true,
8686
BackupFrameworkEnabled.key());
8787

88+
ConfigKey<Integer> NASBackupCreateBackupTimeout = new ConfigKey<>("Advanced", Integer.class,
89+
"nas.backup.create.backup.timeout",
90+
"14400",
91+
"Timeout in seconds for the create backup command.",
92+
true,
93+
BackupFrameworkEnabled.key());
94+
8895
@Inject
8996
private BackupDao backupDao;
9097

@@ -205,6 +212,7 @@ public Pair<Boolean, Backup> takeBackup(final VirtualMachine vm, Boolean quiesce
205212
command.setBackupRepoAddress(backupRepository.getAddress());
206213
command.setMountOptions(backupRepository.getMountOptions());
207214
command.setQuiesce(quiesceVM);
215+
command.setTimeout(NASBackupCreateBackupTimeout.value());
208216

209217
if (VirtualMachine.State.Stopped.equals(vm.getState())) {
210218
List<VolumeVO> vmVolumes = volumeDao.findByInstance(vm.getId());

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtTakeBackupCommandWrapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public Answer execute(TakeBackupCommand command, LibvirtComputingResource libvir
5151
final String mountOptions = command.getMountOptions();
5252
List<PrimaryDataStoreTO> volumePools = command.getVolumePools();
5353
final List<String> volumePaths = command.getVolumePaths();
54+
Long timeout = (long) (command.getTimeout() * 1000);
5455
KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr();
5556

5657
List<String> diskPaths = new ArrayList<>();
@@ -81,7 +82,7 @@ public Answer execute(TakeBackupCommand command, LibvirtComputingResource libvir
8182
"-d", diskPaths.isEmpty() ? "" : String.join(",", diskPaths)
8283
});
8384

84-
Pair<Integer, String> result = Script.executePipedCommands(commands, libvirtComputingResource.getCmdsTimeout());
85+
Pair<Integer, String> result = Script.executePipedCommands(commands, timeout);
8586

8687
if (result.first() != 0) {
8788
logger.debug("Failed to take VM backup: " + result.second());

0 commit comments

Comments
 (0)