From 3dd9e720aa08c27c8c8763f79355ec357a17f390 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Mon, 2 Nov 2015 18:33:49 -0800 Subject: [PATCH] Better error & retry tracking in Kitematic Signed-off-by: Jeffrey Morgan --- src/utils/DockerMachineUtil.js | 15 +++++++++++++ src/utils/SetupUtil.js | 41 ++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/utils/DockerMachineUtil.js b/src/utils/DockerMachineUtil.js index e342e7fc..3f6802a5 100644 --- a/src/utils/DockerMachineUtil.js +++ b/src/utils/DockerMachineUtil.js @@ -21,6 +21,21 @@ var DockerMachine = { } return fs.existsSync(this.command()); }, + version: function () { + return util.exec([this.command(), '-v']).then(stdout => { + try { + let tokens = stdout.split(' '); + if (tokens.length < 3) { + return Promise.resolve(null); + } + return Promise.resolve(tokens[2]); + } catch (err) { + return Promise.resolve(null); + } + }).catch(() => { + return Promise.resolve(null); + }); + }, isoversion: function (machineName = this.name()) { try { var data = fs.readFileSync(path.join(util.home(), '.docker', 'machine', 'machines', machineName, 'boot2docker.iso'), 'utf8'); diff --git a/src/utils/SetupUtil.js b/src/utils/SetupUtil.js index 25cdd8aa..d5331c88 100644 --- a/src/utils/SetupUtil.js +++ b/src/utils/SetupUtil.js @@ -32,6 +32,10 @@ export default { }, retry (removeVM) { + metrics.track('Retried Setup', { + removeVM + }); + router.get().transitionTo('loading'); if (removeVM) { machine.rm().finally(() => { @@ -48,18 +52,31 @@ export default { }, async setup () { - metrics.track('Started Setup'); + let virtualBoxVersion = await virtualBox.version(); + let machineVersion = await machine.version(); + + metrics.track('Started Setup', { + virtualBoxVersion, + machineVersion + }); + while (true) { try { setupServerActions.started({started: false}); - if (!virtualBox.installed()) { - router.get().transitionTo('setup'); - throw new Error('VirtualBox is not installed. Please install it via the Docker Toolbox.'); - } - if (!machine.installed()) { + // Make sure virtulBox and docker-machine are installed + let virtualBoxInstalled = virtualBox.installed(); + let machineInstalled = machine.installed(); + if (!virtualBoxInstalled || !machineInstalled) { router.get().transitionTo('setup'); - throw new Error('Docker Machine is not installed. Please install it via the Docker Toolbox.'); + if (!virtualBoxInstalled) { + setupServerActions.error({error: 'VirtualBox is not installed. Please install it via the Docker Toolbox.'}); + } else { + setupServerActions.error({error: 'Docker Machine is not installed. Please install it via the Docker Toolbox.'}); + } + this.clearTimers(); + await this.pause(); + continue; } setupServerActions.started({started: true}); @@ -106,7 +123,10 @@ export default { break; } catch (error) { router.get().transitionTo('setup'); - metrics.track('Setup Failed'); + metrics.track('Setup Failed', { + virtualBoxVersion, + machineVersion + }); setupServerActions.error({error}); bugsnag.notify('SetupError', error.message, { error: error, @@ -116,6 +136,9 @@ export default { await this.pause(); } } - metrics.track('Setup Finished'); + metrics.track('Setup Finished', { + virtualBoxVersion, + machineVersion + }); } };