From c78f532a48435997b59109e663889d338cafdfd2 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Thu, 5 Mar 2015 14:47:09 -0500 Subject: [PATCH 1/3] Fix error with permissions when setting up CLI tools. Better error messages and reporting --- src/ContainerHome.react.js | 2 +- src/Main.js | 2 -- src/Setup.react.js | 2 +- src/SetupStore.js | 51 ++++++++++++++++---------------------- src/SetupUtil.js | 3 ++- src/Util.js | 2 +- 6 files changed, 26 insertions(+), 36 deletions(-) diff --git a/src/ContainerHome.react.js b/src/ContainerHome.react.js index 45edefcf3d..689c2249bd 100644 --- a/src/ContainerHome.react.js +++ b/src/ContainerHome.react.js @@ -74,7 +74,7 @@ var ContainerHome = React.createClass({ if (this.props.error) { body = (
-

There was a problem connecting to the Docker Engine.
Either the VirtualBox VM was removed, is not responding or Docker is not running inside of it. Try restarting Kitematic. If the issue persists, please file a ticket on our GitHub repo.

+

There was a problem connecting to the Docker Engine in the VirtualBox VM.
This could be caused because this Mac is current connected a VPN, blocking access to the VM. If the issue persists, please file a ticket on our GitHub repo.

); diff --git a/src/Main.js b/src/Main.js index 70ab2e45a3..3378afe64a 100644 --- a/src/Main.js +++ b/src/Main.js @@ -108,6 +108,4 @@ SetupStore.setup().then(ip => { step: 'catch', error: err }); - console.log(err); - console.log(err.stack); }); diff --git a/src/Setup.react.js b/src/Setup.react.js index a5c284f26b..7bd7e37e82 100644 --- a/src/Setup.react.js +++ b/src/Setup.react.js @@ -127,7 +127,7 @@ var Setup = React.createClass({

Setup Error

We're Sorry!

There seems to have been an unexpected error with Kitematic:

-

{this.state.error}
{this.state.error.message}

+

{this.state.error.message || this.state.error}

diff --git a/src/SetupStore.js b/src/SetupStore.js index b2384c2534..49d52538df 100644 --- a/src/SetupStore.js +++ b/src/SetupStore.js @@ -115,10 +115,6 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), { error: function () { return _error; }, - setError: function (error) { - _error = error; - this.emit(this.ERROR_EVENT); - }, cancelled: function () { return _cancelled; }, @@ -195,20 +191,7 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), { break; } catch (err) { if (err) { - console.log('Setup encountered an error.'); - console.log(err); - console.log(err.stack); - metrics.track('Setup Failed', { - step: step.name - }); - var virtualboxVersion = virtualBox.installed() ? yield virtualBox.version() : 'Not installed'; - bugsnag.notify('SetupError', 'Setup failed', { - error: err, - step: step.name, - virtualbox: virtualboxVersion - }); - _error = err; - this.emit(this.ERROR_EVENT); + throw err; } else { metrics.track('Setup Cancelled'); _cancelled = true; @@ -223,24 +206,32 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), { }), setup: Promise.coroutine(function * () { while (true) { - var ip = yield this.run(); - if (!ip || !ip.length) { + try { + var ip = yield this.run(); + ip = null; + if (!ip || !ip.length) { + throw { + message: 'Machine IP could not be fetched. Please retry the setup. If this fails please file a ticket on our GitHub repo.', + machine: yield machine.info(), + ip: ip, + }; + } else { + metrics.track('Setup Finished'); + return ip; + } + } catch (err) { metrics.track('Setup Failed', { - step: 'done', - message: 'Machine IP not set' + step: _currentStep }); var virtualboxVersion = virtualBox.installed() ? yield virtualBox.version() : 'Not installed'; - bugsnag.notify('SetupError', 'Machine ip was not set', { - machine: yield machine.info(), - ip: ip, - step: 'done', + bugsnag.notify('SetupError', 'Setup failed', { + error: err, + step: _currentStep, virtualbox: virtualboxVersion }); - SetupStore.setError('Could not reach the Docker Engine inside the VirtualBox VM'); + _error = err; + this.emit(this.ERROR_EVENT); yield this.pause(); - } else { - metrics.track('Setup Finished'); - return ip; } } }) diff --git a/src/SetupUtil.js b/src/SetupUtil.js index 9b7f2d1973..69a69224bc 100644 --- a/src/SetupUtil.js +++ b/src/SetupUtil.js @@ -12,7 +12,8 @@ var SetupUtil = { if (!fs.existsSync('/usr/local') || !fs.existsSync('/usr/local/bin')) { return true; } - if (!fs.existsSync('/usr/local/bin/docker') && !fs.existsSync('/usr/local/bin/docker-machine')) { + + if (!fs.existsSync('/usr/local/bin/docker') || !fs.existsSync('/usr/local/bin/docker-machine')) { return fs.statSync('/usr/local/bin').gid !== 80 || fs.statSync('/usr/local/bin').uid !== process.getuid(); } diff --git a/src/Util.js b/src/Util.js index 4e0bab7a39..7430d0904f 100644 --- a/src/Util.js +++ b/src/Util.js @@ -11,7 +11,7 @@ module.exports = { if (code) { var cmd = Array.isArray(args) ? args.join(' ') : args; reject({ - message: cmd.replace(this.home(), '') + 'returned non zero exit code', + message: cmd.replace(this.home(), '') + ' returned non zero exit code', stderr: stderr, stdout: stdout }); From c059adbfb82193503db1178ba57fd06c244c4988 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Thu, 5 Mar 2015 14:50:20 -0500 Subject: [PATCH 2/3] Fix typo --- src/ContainerHome.react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ContainerHome.react.js b/src/ContainerHome.react.js index 689c2249bd..7bb94fc07f 100644 --- a/src/ContainerHome.react.js +++ b/src/ContainerHome.react.js @@ -74,7 +74,7 @@ var ContainerHome = React.createClass({ if (this.props.error) { body = (
-

There was a problem connecting to the Docker Engine in the VirtualBox VM.
This could be caused because this Mac is current connected a VPN, blocking access to the VM. If the issue persists, please file a ticket on our GitHub repo.

+

There was a problem connecting to the Docker Engine in the VirtualBox VM.
This could be caused because this Mac is currently connected a VPN, blocking access to the VM. If the issue persists, please file a ticket on our GitHub repo.

); From 93890506bc89ddc35893a9d1a9513c20a5d4ea5c Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Thu, 5 Mar 2015 14:53:04 -0500 Subject: [PATCH 3/3] Remove accidental test line --- src/SetupStore.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SetupStore.js b/src/SetupStore.js index 49d52538df..556a65ff0b 100644 --- a/src/SetupStore.js +++ b/src/SetupStore.js @@ -208,7 +208,6 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), { while (true) { try { var ip = yield this.run(); - ip = null; if (!ip || !ip.length) { throw { message: 'Machine IP could not be fetched. Please retry the setup. If this fails please file a ticket on our GitHub repo.',