Skip to content
Permalink
Browse files

[fix] Start the app if it isn't started when Apps.datacenter is called.

  • Loading branch information...
Southern committed Mar 6, 2013
1 parent 150b99f commit 7c2ed319dc4d83f4f360bd117de7cb7e81b105c7
Showing with 22 additions and 8 deletions.
  1. +22 −8 node.js/lib/client/apps.js
@@ -221,14 +221,28 @@ Apps.prototype.datacenter = function (appName, cloud, callback) {
//
this.clouds[appName] = cloud;

this.cloud({ method: 'POST', uri: argv, body: cloud, appName: appName }, this.request, function (err, result) {
//
// Assume that this call invalidates our cached datacenter endpoint, so
// remove it, and it will be fetched again on the next call
//
delete self.clouds[appName];
// Ensure the app is started before we try to set the datacenter.
this.view(appName, function (err, current) {
if (err) throw err;

if (err) return callback(err);
callback(err, result);
if (!current.config.cloud) {
self.start(appName, executeCloud);
}
else {
executeCloud();
}
});

function executeCloud() {
self.cloud({ method: 'POST', uri: argv, body: cloud, appName: appName }, self.request, function (err, result) {
//
// Assume that this call invalidates our cached datacenter endpoint, so
// remove it, and it will be fetched again on the next call
//
delete self.clouds[appName];

if (err) return callback(err);
callback(err, result);
});
}
};

5 comments on commit 7c2ed31

@3rd-Eden

This comment has been minimized.

Copy link
Member

replied Mar 6, 2013

Could use a test

@indexzero

This comment has been minimized.

Copy link
Member

replied Mar 6, 2013

This feels wrong in several ways, but it fixes things for now. We will revert this in the next week or two once the upstream fix lands in the API server.

@Southern

This comment has been minimized.

Copy link
Contributor Author

replied Mar 6, 2013

@indexzero This was definitely a quick fix, because there was a user having problems with scaling. Rerouting the scaling in jitsu where I did caused it to throw an error when the app is freshly created because it hasn't been started yet. @AvianFlu and I agreed that it was better to start it than throw the error message about it not being started, at least for the time being. Not sure exactly what caused jitsu to break yet.

@3rd-Eden There actually aren't any tests at all for cloud in this repo. I'll work on those once we get this whole situation straightened out with it and get this change reverted. If we can just figure out what caused the break in the first place, we can go ahead and revert these changes.

@indexzero

This comment has been minimized.

Copy link
Member

replied Mar 7, 2013

@Southern What's the "break"? Is there an issue somewhere I can look at?

@Southern

This comment has been minimized.

Copy link
Contributor Author

replied Mar 7, 2013

@indexzero @AvianFlu and I weren't able to figure out what broke it, so I ended up having to throw in this quick fix. I didn't see any changes in the recent jitsu commits that looked like they would break that functionality, so I'm not exactly sure what's going on with it.

Please sign in to comment.
You can’t perform that action at this time.