Merge pull request #139 from kitematic/jmorgan_fix_app_image_sync

Fixing bugs that occur with sync when containers fail to run
This commit is contained in:
Jeffrey Morgan 2014-12-14 21:04:21 -08:00
commit 9a92f1cf35
8 changed files with 37 additions and 21 deletions

View File

@ -14,9 +14,23 @@ AppUtil.run = function (app, callback) {
}});
Docker.removeContainer(app.name, function (err) {
Docker.runContainer(app, image, function (err, container) {
if (err) { callback(err); }
if (err) {
Apps.update(app._id, {$set: {
status: 'ERROR',
logs: [err.message]
}});
callback(err);
return;
}
Docker.getContainerData(container.id, function (err, data) {
if (err) { callback(err); }
if (err) {
callback(err);
Apps.update(app._id, {$set: {
status: 'ERROR',
logs: [err.message]
}});
return;
}
// Set a delay for app to spin up
Apps.update(app._id, {$set: {
docker: data,
@ -153,7 +167,7 @@ AppUtil.sync = function (callback) {
var diffApps = _.difference(guiIds, containerIds);
_.each(diffApps, function (appContainerId) {
var app = Apps.findOne({'docker.Id': appContainerId});
if (app && app.status !== 'STARTING') {
if (app && app.status === 'READY') {
AppUtil.remove(app._id);
}
});
@ -211,7 +225,6 @@ AppUtil.sync = function (callback) {
} else {
appObj.volumesEnabled = false;
}
console.log(appObj);
Apps.insert(appObj);
});

View File

@ -105,7 +105,7 @@ Docker.runContainer = function (app, image, callback) {
};
if (app.docker && app.docker.NetworkSettings.Ports) {
if (app.docker && app.docker.NetworkSettings && app.docker.NetworkSettings.Ports) {
containerOpts.ExposedPorts = app.docker.NetworkSettings.Ports;
}
@ -129,7 +129,7 @@ Docker.runContainer = function (app, image, callback) {
Binds: binds
};
if (app.docker && app.docker.NetworkSettings.Ports) {
if (app.docker && app.docker.NetworkSettings && app.docker.NetworkSettings.Ports) {
startOpts.PortBindings = app.docker.NetworkSettings.Ports;
} else {
startOpts.PublishAllPorts = true;

View File

@ -259,7 +259,7 @@ ImageUtil.sync = function (callback) {
var diffImages = _.difference(kitematicIds, daemonIds);
_.each(diffImages, function (imageId) {
var image = Images.findOne({'docker.Id': imageId});
if (image && image.status !== 'BUILDING') {
if (image && image.status === 'READY') {
Images.remove(image._id);
}
});

View File

@ -38,10 +38,12 @@ Metrics.trackEvent = function (name) {
if (err) {
return;
}
var osVersion = navigator.userAgent.match(/Mac OS X (\d+_\d+_\d+)/)[1].replace(/_/g, '.');
mixpanel.track(name, {
distinct_id: uuid,
version: app.getVersion(),
product: 'Docker GUI'
product: 'Docker GUI',
'Operating System Version': osVersion
});
});
});

View File

@ -1,14 +1,16 @@
<template name="dashboardAppsSettings">
<div class="section">
<div class="left-section">
<h4>Ports</h4>
{{#if ports}}
<div class="section">
<div class="left-section">
<h4>Ports</h4>
</div>
<div class="right-section">
<ul class="list-unstyled">
{{> dashboardAppsPorts}}
</ul>
</div>
</div>
<div class="right-section">
<ul class="list-unstyled">
{{> dashboardAppsPorts}}
</ul>
</div>
</div>
{{/if}}
<div class="section">
<div class="left-section">
<h4>Environment Variables</h4>

View File

@ -40,9 +40,7 @@ Template.modalCreateApp.events({
var image = Images.findOne(app.imageId);
Util.copyVolumes(image.path, app.name, function (err) {
if (err) { console.error(err); }
AppUtil.run(app, function (err) {
if (err) { console.error(err); }
});
AppUtil.run(app, function (err) {});
});
$('#modal-create-app').bind('hidden.bs.modal', function () {
$('#slug-create-app-name').html('');

View File

@ -32,7 +32,7 @@ Apps.helpers({
},
ports: function () {
var app = this;
if (!app.docker || !app.docker.NetworkSettings.Ports) {
if (!app.docker || !app.docker.NetworkSettings || !app.docker.NetworkSettings || !app.docker.NetworkSettings.Ports) {
return [];
}

View File

@ -46,6 +46,7 @@ cd resources
if [ ! -f $BOOT2DOCKER_CLI_VERSION_FILE ]; then
cecho "-----> Downloading Boot2docker CLI..." $purple
rm -rf boot2docker-*
curl -L -o $BOOT2DOCKER_CLI_VERSION_FILE https://github.com/boot2docker/boot2docker-cli/releases/download/v${BOOT2DOCKER_CLI_VERSION}/boot2docker-v${BOOT2DOCKER_CLI_VERSION}-darwin-amd64
fi