Merge pull request #1300 from docker/fix-vtx-exec

Dont track VTX as an error & fix bugs relating to exec on windows
This commit is contained in:
Jeffrey Morgan 2015-12-13 18:21:19 -08:00
Родитель 07c3c67bf5 13537af0bc
Коммит fe50b66c88
5 изменённых файлов: 39 добавлений и 53 удалений

Просмотреть файл

@ -2,7 +2,6 @@ import React from 'react/addons';
import remote from 'remote';
import RetinaImage from 'react-retina-image';
import ipc from 'ipc';
var autoUpdater = remote.require('auto-updater');
import util from '../utils/Util';
import metrics from '../utils/MetricsUtil';
var Menu = remote.require('menu');
@ -32,7 +31,6 @@ var Header = React.createClass({
updateAvailable: true
});
});
autoUpdater.checkForUpdates();
},
componentWillUnmount: function () {
document.removeEventListener('keyup', this.handleDocumentKeyUp, false);

Просмотреть файл

@ -22,7 +22,7 @@ var DockerMachine = {
return fs.existsSync(this.command());
},
version: function () {
return util.exec([this.command(), '-v']).then(stdout => {
return util.execFile([this.command(), '-v']).then(stdout => {
try {
var matchlist = stdout.match(/(\d+\.\d+\.\d+).*/);
if (!matchlist || matchlist.length < 2) {
@ -57,40 +57,40 @@ var DockerMachine = {
});
},
create: function (machineName = this.name()) {
return util.exec([this.command(), '-D', 'create', '-d', 'virtualbox', '--virtualbox-memory', '2048', machineName]);
return util.execFile([this.command(), '-D', 'create', '-d', 'virtualbox', '--virtualbox-memory', '2048', machineName]);
},
start: function (machineName = this.name()) {
return util.exec([this.command(), '-D', 'start', machineName]);
return util.execFile([this.command(), '-D', 'start', machineName]);
},
stop: function (machineName = this.name()) {
return util.exec([this.command(), 'stop', machineName]);
return util.execFile([this.command(), 'stop', machineName]);
},
upgrade: function (machineName = this.name()) {
return util.exec([this.command(), 'upgrade', machineName]);
return util.execFile([this.command(), 'upgrade', machineName]);
},
rm: function (machineName = this.name()) {
return util.exec([this.command(), 'rm', '-f', machineName]);
return util.execFile([this.command(), 'rm', '-f', machineName]);
},
ip: function (machineName = this.name()) {
return util.exec([this.command(), 'ip', machineName]).then(stdout => {
return util.execFile([this.command(), 'ip', machineName]).then(stdout => {
return Promise.resolve(stdout.trim().replace('\n', ''));
});
},
url: function (machineName = this.name()) {
return util.exec([this.command(), 'url', machineName]).then(stdout => {
return util.execFile([this.command(), 'url', machineName]).then(stdout => {
return Promise.resolve(stdout.trim().replace('\n', ''));
});
},
regenerateCerts: function (machineName = this.name()) {
return util.exec([this.command(), 'tls-regenerate-certs', '-f', machineName]);
return util.execFile([this.command(), 'tls-regenerate-certs', '-f', machineName]);
},
status: function (machineName = this.name()) {
return util.exec([this.command(), 'status', machineName]).then(stdout => {
return util.execFile([this.command(), 'status', machineName]).then(stdout => {
return Promise.resolve(stdout.trim().replace('\n', ''));
});
},
disk: function (machineName = this.name()) {
return util.exec([this.command(), 'ssh', machineName, 'df']).then(stdout => {
return util.execFile([this.command(), 'ssh', machineName, 'df']).then(stdout => {
try {
var lines = stdout.split('\n');
var dataline = _.find(lines, function (line) {
@ -114,7 +114,7 @@ var DockerMachine = {
});
},
memory: function (machineName = this.name()) {
return util.exec([this.command(), 'ssh', machineName, 'free -m']).then(stdout => {
return util.execFile([this.command(), 'ssh', machineName, 'free -m']).then(stdout => {
try {
var lines = stdout.split('\n');
var dataline = _.find(lines, function (line) {
@ -155,11 +155,11 @@ var DockerMachine = {
cmd = cmd || process.env.SHELL;
var terminal = util.linuxTerminal();
if (terminal)
util.exec(terminal.concat([cmd])).then(() => {});
util.execFile(terminal.concat([cmd])).then(() => {});
} else {
cmd = cmd || process.env.SHELL;
this.url(machineName).then(machineUrl => {
util.exec([path.join(process.env.RESOURCES_PATH, 'terminal'), `DOCKER_HOST=${machineUrl} DOCKER_CERT_PATH=${path.join(util.home(), '.docker/machine/machines/' + machineName)} DOCKER_TLS_VERIFY=1 ${cmd}`]).then(() => {});
util.execFile([path.join(process.env.RESOURCES_PATH, 'terminal'), `DOCKER_HOST=${machineUrl} DOCKER_CERT_PATH=${path.join(util.home(), '.docker/machine/machines/' + machineName)} DOCKER_TLS_VERIFY=1 ${cmd}`]).then(() => {});
});
}
},

Просмотреть файл

@ -137,9 +137,9 @@ export default {
let tries = 80, ip = null;
while (!ip && tries > 0) {
try {
tries -= 1;
console.log('Trying to fetch machine IP, tries left: ' + tries);
ip = await machine.ip();
tries -= 1;
await Promise.delay(1000);
} catch (err) {}
}
@ -153,11 +153,12 @@ export default {
break;
} catch (error) {
router.get().transitionTo('setup');
metrics.track('Setup Failed', {
let novtx = error.message.indexOf('This computer doesn\'t have VT-X/AMD-v enabled') !== -1;
metrics.track(novtx ? 'Setup Halted' : 'Setup Failed', {
virtualBoxVersion,
machineVersion
});
setupServerActions.error({error});
let message = error.message.split('\n');
let lastLine = message.length > 1 ? message[message.length - 2] : 'Docker Machine encountered an error.';
@ -170,6 +171,8 @@ export default {
groupingHash: machineVersion
}, 'info');
setupServerActions.error({error: new Error(lastLine)});
this.clearTimers();
await this.pause();
}

Просмотреть файл

@ -8,20 +8,20 @@ var dialog = remote.require('dialog');
var app = remote.require('app');
module.exports = {
exec: function (args, options) {
options = options || {};
// Add resources dir to exec path for Windows
if (this.isWindows()) {
options.env = options.env || {};
if (!options.env.PATH) {
options.env.PATH = process.env.RESOURCES_PATH + ';' + process.env.PATH;
}
}
execFile: function (args, options) {
return new Promise((resolve, reject) => {
var cmd = Array.isArray(args) ? args.join(' ') : args;
child_process.exec(cmd, options, (error, stdout, stderr) => {
child_process.execFile(args[0], args.slice(1), options, (error, stdout, stderr) => {
if (error) {
reject(new Error('Encountered an error: ' + error));
} else {
resolve(stdout);
}
});
});
},
exec: function (args, options) {
return new Promise((resolve, reject) => {
child_process.exec(args, options, (error, stdout, stderr) => {
if (error) {
reject(new Error('Encountered an error: ' + error));
} else {

Просмотреть файл

@ -16,13 +16,16 @@ var VirtualBox = {
}
},
installed: function () {
if (util.isWindows() && !process.env.VBOX_INSTALL_PATH && !process.env.VBOX_MSI_INSTALL_PATH) {
return false;
}
return fs.existsSync(this.command());
},
active: function () {
return fs.existsSync('/dev/vboxnetctl');
},
version: function () {
return util.exec([this.command(), '-v']).then(stdout => {
return util.execFile([this.command(), '-v']).then(stdout => {
let matchlist = stdout.match(/(\d+\.\d+\.\d+).*/);
if (!matchlist || matchlist.length < 2) {
Promise.reject('VBoxManage -v output format not recognized.');
@ -32,29 +35,11 @@ var VirtualBox = {
return Promise.resolve(null);
});
},
poweroffall: function () {
return util.exec(this.command() + ' list runningvms | sed -E \'s/.*\\{(.*)\\}/\\1/\' | xargs -L1 -I {} ' + this.command() + ' controlvm {} poweroff');
},
mountSharedDir: function (vmName, pathName, hostPath) {
return util.exec([this.command(), 'sharedfolder', 'add', vmName, '--name', pathName, '--hostpath', hostPath, '--automount']);
},
killall: function () {
if (util.isWindows()) {
return this.poweroffall().then(() => {
return util.exec(['powershell.exe', '\"get-process VBox* | stop-process\"']);
}).catch(() => {});
} else {
return this.poweroffall().then(() => {
return util.exec(['pkill', 'VirtualBox']);
}).then(() => {
return util.exec(['pkill', 'VBox']);
}).catch(() => {
});
}
return util.execFile([this.command(), 'sharedfolder', 'add', vmName, '--name', pathName, '--hostpath', hostPath, '--automount']);
},
vmExists: function (name) {
return util.exec([this.command(), 'showvminfo', name]).then(() => {
return util.execFile([this.command(), 'showvminfo', name]).then(() => {
return true;
}).catch((err) => {
return false;