Skip to content

Commit 30fe99a

Browse files
committed
use timeout set via "commands.timeout"
1 parent 369023b commit 30fe99a

File tree

4 files changed

+4
-21
lines changed

4 files changed

+4
-21
lines changed

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

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

4039
public TakeBackupCommand(String vmName, String backupPath) {
4140
super();
@@ -107,14 +106,6 @@ public void setQuiesce(Boolean quiesce) {
107106
this.quiesce = quiesce;
108107
}
109108

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-
118109
@Override
119110
public boolean executeInSequence() {
120111
return true;

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ 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-
9588
@Inject
9689
private BackupDao backupDao;
9790

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

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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public Answer execute(RestoreBackupCommand command, LibvirtComputingResource ser
7373
List<PrimaryDataStoreTO> restoreVolumePools = command.getRestoreVolumePools();
7474
List<String> restoreVolumePaths = command.getRestoreVolumePaths();
7575
Integer mountTimeout = command.getMountTimeout() * 1000;
76-
int timeout = command.getWait();
76+
int timeout = command.getWait() > 0 ? command.getWait() * 1000 : serverResource.getCmdsTimeout();
7777
KVMStoragePoolManager storagePoolMgr = serverResource.getStoragePoolMgr();
7878
List<String> backupFiles = command.getBackupFiles();
7979

@@ -252,7 +252,7 @@ private boolean replaceVolumeWithBackup(KVMStoragePoolManager storagePoolMgr, Pr
252252

253253
private boolean replaceVolumeWithBackup(KVMStoragePoolManager storagePoolMgr, PrimaryDataStoreTO volumePool, String volumePath, String backupPath, int timeout, boolean createTargetVolume) {
254254
if (volumePool.getPoolType() != Storage.StoragePoolType.RBD) {
255-
int exitValue = Script.runSimpleBashScriptForExitValue(String.format(RSYNC_COMMAND, backupPath, volumePath));
255+
int exitValue = Script.runSimpleBashScriptForExitValue(String.format(RSYNC_COMMAND, backupPath, volumePath), timeout, false);
256256
return exitValue == 0;
257257
}
258258

@@ -263,7 +263,7 @@ private boolean replaceRbdVolumeWithBackup(KVMStoragePoolManager storagePoolMgr,
263263
KVMStoragePool volumeStoragePool = storagePoolMgr.getStoragePool(volumePool.getPoolType(), volumePool.getUuid());
264264
QemuImg qemu;
265265
try {
266-
qemu = new QemuImg(timeout * 1000, true, false);
266+
qemu = new QemuImg(timeout, true, false);
267267
if (!createTargetVolume) {
268268
KVMPhysicalDisk rdbDisk = volumeStoragePool.getPhysicalDisk(volumePath);
269269
logger.debug("Restoring RBD volume: {}", rdbDisk.toString());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ 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);
5554
KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr();
55+
int timeout = command.getWait() > 0 ? command.getWait() * 1000 : libvirtComputingResource.getCmdsTimeout();
5656

5757
List<String> diskPaths = new ArrayList<>();
5858
if (Objects.nonNull(volumePaths)) {

0 commit comments

Comments
 (0)