From 2731cd8f0c4abed64c6acf2c8695ce29edcb54d9 Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Thu, 29 Apr 2021 11:19:15 +0200 Subject: [PATCH] Cancellable pods list requests --- lib/ui/dashboard.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ui/dashboard.js b/lib/ui/dashboard.js index 35b26fc..24319e8 100644 --- a/lib/ui/dashboard.js +++ b/lib/ui/dashboard.js @@ -711,10 +711,12 @@ class Dashboard extends EventEmitter { this.run = function (namespace) { current_namespace = namespace; let listPodsError; - // FIXME: should be cancellable - const promise = until(client.pods(namespace).get()) + let { promise, cancellation } = client.pods(namespace).get({ cancellable: true }); + cancellations.add('dashboard.pods', cancellation); + promise = until(promise) .do(pods_table, pods_table.setLabel) .spin(s => `${s} Pods {grey-fg}[${namespace}]{/grey-fg}`) + .cancel(c => cancellations.add('dashboard.pods', c)) .done(_ => `Pods {grey-fg}[${namespace}]{/grey-fg}`) .then(response => { pods_list = JSON.parse(response.body.toString('utf8')); @@ -740,7 +742,7 @@ class Dashboard extends EventEmitter { yield* watchPodChanges(namespace); } }); - cancellations.add('dashboard', cancellation); + cancellations.add('dashboard.pods', cancellation); return promise; }) .catch(error => {