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/event.inc.php | 4 ++-- inc/trigger.inc.php | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/inc/event.inc.php b/inc/event.inc.php index e5ade41b..2d916b48 100644 --- a/inc/event.inc.php +++ b/inc/event.inc.php @@ -64,7 +64,7 @@ class Event } else { $res = Taskmanager::waitComplete($ipxeId, 5000); if (Taskmanager::isFailed($res)) { - EventLog::failure('Update PXE Menu failed', $res['data']['error']); + EventLog::failure('Update PXE Menu failed', $res['data']['error'] ?? $res['data']['error'] ?? ''); $everythingFine = false; } } @@ -79,7 +79,7 @@ class Event $mountStatus = Taskmanager::waitComplete($mountId, 10000); } if ($mountId !== false && Taskmanager::isFailed($mountStatus)) { - EventLog::failure('Mounting VM store failed', $mountStatus['data']['messages']); + EventLog::failure('Mounting VM store failed', $mountStatus['data']['messages'] ?? ''); $everythingFine = false; } elseif ($mountId !== false && !Taskmanager::isFinished($mountStatus)) { // TODO: Still running - create callback 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