Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 7c2ed31
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions node.js/lib/client/apps.js
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use a test

@indexzero
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Southern
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.