From 6ce5da9a78c49f612c1c70c1e0623079fdf3f0ad Mon Sep 17 00:00:00 2001 From: Jeff Morgan Date: Sun, 14 Dec 2014 21:03:08 -0800 Subject: [PATCH] Fixing bugs that occur with sync when containers fail to run --- meteor/client/lib/apputil.js | 21 +++++++++++++++---- meteor/client/lib/docker.js | 4 ++-- meteor/client/lib/imageutil.js | 2 +- meteor/client/lib/metrics.js | 4 +++- .../apps/dashboard-apps-settings.html | 20 ++++++++++-------- .../dashboard/components/modal-create-app.js | 4 +--- meteor/collections/apps.js | 2 +- script/setup.sh | 1 + 8 files changed, 37 insertions(+), 21 deletions(-) diff --git a/meteor/client/lib/apputil.js b/meteor/client/lib/apputil.js index ffec535e41..dc72553703 100644 --- a/meteor/client/lib/apputil.js +++ b/meteor/client/lib/apputil.js @@ -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); }); diff --git a/meteor/client/lib/docker.js b/meteor/client/lib/docker.js index 55a3b078ba..5a406723fd 100644 --- a/meteor/client/lib/docker.js +++ b/meteor/client/lib/docker.js @@ -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; diff --git a/meteor/client/lib/imageutil.js b/meteor/client/lib/imageutil.js index 6f8e83fa08..384c1bff64 100644 --- a/meteor/client/lib/imageutil.js +++ b/meteor/client/lib/imageutil.js @@ -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); } }); diff --git a/meteor/client/lib/metrics.js b/meteor/client/lib/metrics.js index e5f1d23fb2..2321e17381 100644 --- a/meteor/client/lib/metrics.js +++ b/meteor/client/lib/metrics.js @@ -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 }); }); }); diff --git a/meteor/client/views/dashboard/apps/dashboard-apps-settings.html b/meteor/client/views/dashboard/apps/dashboard-apps-settings.html index 79de63052d..324a5b85f3 100755 --- a/meteor/client/views/dashboard/apps/dashboard-apps-settings.html +++ b/meteor/client/views/dashboard/apps/dashboard-apps-settings.html @@ -1,14 +1,16 @@