From 59ae2573d31d3bd709453c8060c1f3cec97692b5 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 22 Sep 2020 15:04:09 +0200 Subject: [Trigger/Event] Fix minor warnings --- inc/trigger.inc.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'inc/trigger.inc.php') diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index 134bab53..5024b907 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -98,7 +98,7 @@ class Trigger * * @param array $vmstore VM Store configuration to use. If false, read from properties * @param bool $ifLocalOnly Only execute task if the storage type is local (used for DNBD3) - * @return array|false task status of mount procedure, or false on error + * @return string|false task id of mount procedure, or false on error */ public static function mount($vmstore = false, $ifLocalOnly = false) { @@ -130,7 +130,7 @@ class Trigger }else { $opts = null; } - return Taskmanager::submit('MountVmStore', array( + $status = Taskmanager::submit('MountVmStore', array( 'address' => $addr, 'type' => 'images', 'opts' => $opts, @@ -138,6 +138,12 @@ class Trigger 'username' => $vmstore['cifsuser'], 'password' => $vmstore['cifspasswd'] )); + if (!Taskmanager::isFailed($status)) { + // In case we have a concurrent active task, this should be enough + // for the taskmanager to give us the existing id + $status = Taskmanager::waitComplete($status, 100); + } + return $status['data']['existingTask'] ?? $status['id'] ?? false; } /** -- cgit v1.2.3-55-g7522