Skip to content

Commit

Permalink
Pending Capacity is not internallyTrackedRequests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhford committed Aug 25, 2016
1 parent 394bfb9 commit 8b3059d
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions aws-provisioner/workertypeview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var WorkerTypeResources = React.createClass({
workerType: React.PropTypes.object.isRequired,
awsState: React.PropTypes.shape({
instances: React.PropTypes.arrayOf(React.PropTypes.object),
internalTrackedRequests: React.PropTypes.arrayOf(React.PropTypes.object),
requests: React.PropTypes.arrayOf(React.PropTypes.object),
}).isRequired
},
Expand All @@ -21,9 +20,8 @@ var WorkerTypeResources = React.createClass({
return (
<span>
<h3>Running Instances</h3>
We have&nbsp;
{this.props.awsState.instances.length}
&nbsp;instances running with total capacity of {this.runningCapacity()}.
We have a total running instance capacity of {this.runningCapacity()}.
These are instance that the provisioner counts as doing work.
<bs.Table>
<thead>
<tr>
Expand All @@ -37,14 +35,14 @@ var WorkerTypeResources = React.createClass({
</thead>
<tbody>
{
this.props.awsState.instances.map(this.renderInstanceRow)
this.props.awsState.instances.filter(x => x.state === 'running').map(this.renderInstanceRow)
}
</tbody>
</bs.Table>
<h3>Pending Instances</h3>
We have {this.props.awsState.internalTrackedRequests.length}
&nbsp;instances starting up with total capacity of&nbsp;
{this.pendingCapacity()}.
We have a total pending instance capacity of {this.pendingCapacity()}.
These are filled spot requests which are not yet doing work. These are
usually instances which are booting up.
<bs.Table>
<thead>
<tr>
Expand All @@ -58,14 +56,14 @@ var WorkerTypeResources = React.createClass({
</thead>
<tbody>
{
this.props.awsState.internalTrackedRequests.map(this.renderInstanceRow)
this.props.awsState.instances.filter(x => x.state === 'pending').map(this.renderInstanceRow)
}
</tbody>
</bs.Table>
<h3>Spot Requests</h3>
We have spot requests for&nbsp;
{this.props.awsState.requests.length}
&nbsp;instances with total capacity of {this.spotReqCapacity()}.
We have unfilled spot requests for a capacity of {this.spotReqCapacity()}.
Amazon is yet to decided on the bid, or they have not told us the
outcome yet.
<bs.Table>
<thead>
<tr>
Expand Down Expand Up @@ -195,15 +193,15 @@ var WorkerTypeResources = React.createClass({
},

runningCapacity() {
return _.sumBy(this.props.awsState.instances.map(instance => {
return _.sumBy(this.props.awsState.instances.filter(x => x.state === 'running').map(instance => {
return _.find(this.props.workerType.instanceTypes, {
instanceType: instance.type
});
}), 'capacity');
},

pendingCapacity() {
return _.sumBy(this.props.awsState.internalTrackedRequests.map(instance => {
return _.sumBy(this.props.awsState.instances.filter(x => x.state === 'pending').map(instance => {
return _.find(this.props.workerType.instanceTypes, {
instanceType: instance.type
});
Expand All @@ -224,7 +222,6 @@ var WorkerTypeStatus = React.createClass({
workerType: React.PropTypes.object.isRequired,
awsState: React.PropTypes.shape({
instances: React.PropTypes.arrayOf(React.PropTypes.object),
internalTrackedRequests: React.PropTypes.arrayOf(React.PropTypes.object),
requests: React.PropTypes.arrayOf(React.PropTypes.object),
}).isRequired
},
Expand All @@ -233,7 +230,6 @@ var WorkerTypeStatus = React.createClass({
// Find availability zones
var availabilityZones = _.union(
this.props.awsState.instances.map(_.property('zone')),
this.props.awsState.internalTrackedRequests.map(_.property('zone')),
this.props.awsState.requests.map(_.property('zone'))
);
return (
Expand Down Expand Up @@ -266,10 +262,12 @@ var WorkerTypeStatus = React.createClass({
// Find number of running, pending and spotRequests
var running = this.props.awsState.instances.filter(inst => {
return inst.type === instTypeDef.instanceType &&
inst.state === 'running' &&
inst.zone === availabilityZone;
}).length;
var pending = this.props.awsState.internalTrackedRequests.filter(inst => {
var pending = this.props.awsState.instances.filter(inst => {
return inst.type === instTypeDef.instanceType &&
inst.state === 'pending' &&
inst.zone === availabilityZone;
}).length;
var spotReq = this.props.awsState.requests.filter(spotReq => {
Expand Down

0 comments on commit 8b3059d

Please sign in to comment.