[Kimchi-devel] [PATCH] [Kimchi] Show error message for untracked and failed cloning tasks

Lucio Correia luciojhc at linux.vnet.ibm.com
Fri Jul 8 19:46:51 UTC 2016


When the asynchronous task for the cloning of a guest fails
too early, the task is not tracked by listVmsAuto(), which
does it only for 'running' tasks. Consequently, the error
message is not showed to the user.

Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.guest_main.js | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
index 8e12fb2..0e11aa1 100644
--- a/ui/js/src/kimchi.guest_main.js
+++ b/ui/js/src/kimchi.guest_main.js
@@ -360,6 +360,17 @@ kimchi.listVmsAuto = function() {
             return guests;
         };
 
+        var trackFailedCloningGuests = function() {
+            kimchi.getTasksByFilter('status=failed&target_uri=' + encodeURIComponent('^/plugins/kimchi/vms/.+/clone'), function(tasks) {
+                for (var i = 0; i < tasks.length; i++) {
+                    if (kimchi.trackingTasks.indexOf(tasks[i].id) == -1)
+                        kimchi.trackTask(tasks[i].id, null, function(err) {
+                           wok.message.error(err.message);
+                        }, null);
+                }
+            }, null, true);
+        };
+
         var getMigratingGuests = function() {
             var guests = [];
             kimchi.getTasksByFilter('status=running&target_uri=' + encodeURIComponent('^/plugins/kimchi/vms/.+/migrate'), function(tasks) {
@@ -381,7 +392,9 @@ kimchi.listVmsAuto = function() {
 
         kimchi.listVMs(function(result, textStatus, jqXHR) {
                 if (result && textStatus == "success") {
-
+                    // Some clone tasks may fail before being tracked. Show
+                    // error message for them.
+                    trackFailedCloningGuests();
                     var migrated = getMigratingGuests();
                     for (i = migrated.length - 1; i >= 0; i--) {
                         for (j = result.length - 1; j >= 0; j--) {
-- 
1.9.1




More information about the Kimchi-devel mailing list