Merge pull request #1168 from kitematic/better-tracking

Better error & retry metrics in Kitematic
This commit is contained in:
Michael Chiang 2015-11-02 18:43:33 -08:00
commit 191045351b
2 changed files with 47 additions and 9 deletions

View File

@ -21,6 +21,21 @@ var DockerMachine = {
} }
return fs.existsSync(this.command()); 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()) { isoversion: function (machineName = this.name()) {
try { try {
var data = fs.readFileSync(path.join(util.home(), '.docker', 'machine', 'machines', machineName, 'boot2docker.iso'), 'utf8'); var data = fs.readFileSync(path.join(util.home(), '.docker', 'machine', 'machines', machineName, 'boot2docker.iso'), 'utf8');

View File

@ -32,6 +32,10 @@ export default {
}, },
retry (removeVM) { retry (removeVM) {
metrics.track('Retried Setup', {
removeVM
});
router.get().transitionTo('loading'); router.get().transitionTo('loading');
if (removeVM) { if (removeVM) {
machine.rm().finally(() => { machine.rm().finally(() => {
@ -48,18 +52,31 @@ export default {
}, },
async setup () { async setup () {
metrics.track('Started Setup'); let virtualBoxVersion = await virtualBox.version();
let machineVersion = await machine.version();
metrics.track('Started Setup', {
virtualBoxVersion,
machineVersion
});
while (true) { while (true) {
try { try {
setupServerActions.started({started: false}); 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'); 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}); setupServerActions.started({started: true});
@ -106,7 +123,10 @@ export default {
break; break;
} catch (error) { } catch (error) {
router.get().transitionTo('setup'); router.get().transitionTo('setup');
metrics.track('Setup Failed'); metrics.track('Setup Failed', {
virtualBoxVersion,
machineVersion
});
setupServerActions.error({error}); setupServerActions.error({error});
bugsnag.notify('SetupError', error.message, { bugsnag.notify('SetupError', error.message, {
error: error, error: error,
@ -116,6 +136,9 @@ export default {
await this.pause(); await this.pause();
} }
} }
metrics.track('Setup Finished'); metrics.track('Setup Finished', {
virtualBoxVersion,
machineVersion
});
} }
}; };