From 038fc27ef046d3e5e5bcc6b00f37ab8bd145ec50 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Wed, 7 Aug 2019 17:35:15 -0700 Subject: [PATCH] Always preload the alloc node so the client can be dialed first --- ui/app/components/task-file.js | 23 ++++++++++++------- .../routes/allocations/allocation/task/fs.js | 5 ++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ui/app/components/task-file.js b/ui/app/components/task-file.js index 9a6100402..4f982a7a6 100644 --- a/ui/app/components/task-file.js +++ b/ui/app/components/task-file.js @@ -100,15 +100,13 @@ export default Component.extend({ const timing = this.useServer ? this.serverTimeout : this.clientTimeout; const logFetch = url => RSVP.race([this.token.authorizedRequest(url), timeout(timing)]).then( - response => response, - error => { - if (this.useServer) { - this.set('noConnection', true); - } else { - this.send('failoverToServer'); + response => { + if (!response || !response.ok) { + this.nextErrorState(response); } - throw error; - } + return response; + }, + error => this.nextErrorState(error) ); return Log.create({ @@ -119,6 +117,15 @@ export default Component.extend({ }); }), + nextErrorState(error) { + if (this.useServer) { + this.set('noConnection', true); + } else { + this.send('failoverToServer'); + } + throw error; + }, + actions: { toggleStream() { this.set('mode', 'streaming'); diff --git a/ui/app/routes/allocations/allocation/task/fs.js b/ui/app/routes/allocations/allocation/task/fs.js index 12ee70fc4..cc0b6213a 100644 --- a/ui/app/routes/allocations/allocation/task/fs.js +++ b/ui/app/routes/allocations/allocation/task/fs.js @@ -9,9 +9,8 @@ export default Route.extend({ const pathWithTaskName = `${task.name}${decodedPath.startsWith('/') ? '' : '/'}${decodedPath}`; - return task - .stat(pathWithTaskName) - .then(statJson => { + return RSVP.all([task.stat(pathWithTaskName), task.get('allocation.node')]) + .then(([statJson]) => { if (statJson.IsDir) { return RSVP.hash({ path: decodedPath,