Skip to content

Commit c2303cc

Browse files
committed
Merge pull request #115 from vincent99/lb
Load Balancer bug fixes
2 parents 969a0a4 + fd17051 commit c2303cc

10 files changed

Lines changed: 83 additions & 15 deletions

File tree

app/authenticated/route.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,26 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
204204
this._includeChanged('loadBalancer', 'loadBalancerListeners', 'loadBalancerListeners', change.data.resource);
205205
},
206206

207+
loadBalancerChanged: function(change) {
208+
var balancer = change.data.resource;
209+
var config = balancer.get('loadBalancerConfig');
210+
var balancers = config.get('loadBalancers');
211+
if ( !balancers )
212+
{
213+
balancers = [];
214+
config.set('loadBalancers',balancers);
215+
}
216+
217+
if ( config.get('state') === 'removed' )
218+
{
219+
balancers.removeObject(balancer);
220+
}
221+
else
222+
{
223+
balancers.addObject(balancer);
224+
}
225+
},
226+
207227
mountChanged: function(change) {
208228
var mount = change.data.resource;
209229
var volume = this.get('store').getById('volume', mount.get('volumeId'));

app/loadbalancer/controller.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import Ember from 'ember';
22
import Cattle from 'ui/utils/cattle';
33

44
var LoadBalancerController = Cattle.TransitioningResourceController.extend({
5+
actions: {
6+
newTarget: function() {
7+
this.transitionToRoute('loadbalancer.targets.new', this.get('id'));
8+
},
9+
},
10+
511
availableActions: function() {
612
var a = this.get('actions');
713

app/loadbalancerconfigs/index/template.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
</td>
2929
<td>
3030
{{#if config.appCookieStickinessPolicy}}
31-
Create Cookie
31+
Use existing cookie
3232
{{else}}
3333
{{#if config.lbCookieStickinessPolicy}}
34-
Use existing cookie
34+
Create cookie
3535
{{else}}
3636
None
3737
{{/if}}

app/loadbalancerlistener/model.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ var LoadBalancerListener = Cattle.TransitioningResource.extend({
55
});
66

77
LoadBalancerListener.reopenClass({
8+
pollTransitioningDelay: 1000,
9+
pollTransitioningInterval: 5000,
810
});
911

1012
export default LoadBalancerListener;

app/loadbalancers/new/controller.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ export default Ember.ObjectController.extend(Cattle.NewOrEditMixin, EditLoadBala
9797
});
9898
}.property('targetsArray.@each.{isIp,isContainer,value}'),
9999

100+
activeConfigs: function() {
101+
return this.get('allConfigs').filter((config) => {
102+
return config.get('state') === 'active';
103+
});
104+
}.property('allConfigs.@each.state'),
105+
100106
willSave: function() {
101107
if ( !this._super() )
102108
{

app/loadbalancers/new/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
<label>Choose an existing Balancer Configuration</label>
8989
{{view "select"
9090
class="form-control"
91-
content=allConfigs
91+
content=activeConfigs
9292
optionLabelPath="content.name"
9393
optionValuePath="content.id"
9494
value=existingConfigId

app/loadbalancertarget/model.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ var LoadBalancerTarget = Cattle.TransitioningResource.extend({
2323
});
2424

2525
LoadBalancerTarget.reopenClass({
26+
pollTransitioningDelay: 1000,
27+
pollTransitioningInterval: 5000,
2628
});
2729

2830
export default LoadBalancerTarget;

app/utils/cattle.js

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,40 +148,66 @@ var TransitioningResource = Resource.extend({
148148
isError: Ember.computed.equal('transitioning','error'),
149149

150150
replaceWith: function() {
151+
//console.log('1 replaceWith', this.get('id'));
151152
this._super.apply(this,arguments);
152153
this.transitioningChanged();
153154
},
154155

156+
wasAdded: function() {
157+
this.transitioningChanged();
158+
},
159+
160+
wasRemoved: function() {
161+
this.transitioningChanged();
162+
},
163+
155164
pollDelayTimer: null,
156165
pollTimer: null,
157166
reservedKeys: ['pollDelayTimer','pollTimer','waitInterval','waitTimeout'],
158167
transitioningChanged: function() {
159-
//console.log('Transitioning changed', this.toString(), this.get('transitioning'), this.get('pollDelayTimer'),this.get('pollTimer'));
168+
//console.log('Transitioning changed', this.toString(), this.get('transitioning'), this.get('pollDelayTimer'), this.get('pollTimer'));
160169

161-
clearTimeout(this.get('pollDelayTimer'));
162-
clearTimeout(this.get('pollTimer'));
170+
if ( this.get('transitioning') !== 'yes' || !this.isInStore() )
171+
{
172+
clearTimeout(this.get('pollDelayTimer'));
173+
clearTimeout(this.get('pollTimer'));
174+
return;
175+
}
163176

164-
if ( !this.isInStore() )
177+
if ( this.get('pollDelayTimer') )
165178
{
166-
//console.log('This resource is not in the store');
179+
// Already polling or waiting, just let that one finish
167180
return;
168181
}
169182

183+
170184
var delay = this.constructor.pollTransitioningDelay;
171185
var interval = this.constructor.pollTransitioningInterval;
172186
if ( delay > 0 && interval > 0 && this.get('transitioning') === 'yes' )
173187
{
174188
//console.log('Starting poll timer', this.toString());
175189
this.set('pollDelayTimer', setTimeout(function() {
176-
//console.log('1 expired');
190+
//console.log('1 expired', this.toString());
177191
this.transitioningPoll();
178192
}.bind(this), delay));
179193
}
194+
else
195+
{
196+
//console.log('Not polling', this.toString());
197+
clearTimeout(this.get('pollDelayTimer'));
198+
this.set('pollDelayTimer', null);
199+
}
180200
}.observes('transitioning'),
181201

182202
transitioningPoll: function() {
183-
clearTimeout(this.get('pollTimer'));
203+
var self = this;
204+
function reset() {
205+
clearTimeout(self.get('pollDelayTimer'));
206+
self.set('pollDelayTimer',null);
207+
}
184208

209+
clearTimeout(this.get('pollTimer'));
210+
this.set('pollTimer',null);
185211
//console.log('Checking', this.toString());
186212

187213
if ( this.get('transitioning') !== 'yes' || !this.isInStore() )
@@ -196,10 +222,16 @@ var TransitioningResource = Resource.extend({
196222
{
197223
//console.log('Rescheduling', this.toString());
198224
this.set('pollTimer', setTimeout(function() {
199-
//console.log('2 expired');
225+
//console.log('2 expired', this.toString());
200226
this.transitioningPoll();
201227
}.bind(this), this.constructor.pollTransitioningInterval));
202228
}
229+
else
230+
{
231+
reset();
232+
}
233+
}).catch(() => {
234+
reset();
203235
});
204236
},
205237

@@ -241,7 +273,7 @@ var TransitioningResource = Resource.extend({
241273

242274
waitForAction: function(name) {
243275
return this._waitForTestFn(function() {
244-
console.log('waitForAction('+name+'):', this.hasAction(name));
276+
//console.log('waitForAction('+name+'):', this.hasAction(name));
245277
return this.hasAction(name);
246278
}, 'Wait for action='+name);
247279
},

app/views/confirm-delete.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export default Overlay.extend({
99

1010
actions: {
1111
overlayClose: function() {
12-
this.get('controller').send('cancel');
12+
this.get('controller').send('cancelDelete');
1313
},
1414

1515
overlayEnter: function() {
16-
this.get('controller').send('confirm');
16+
this.get('controller').send('confirmDelete');
1717
}
1818
}
1919
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"broccoli-asset-rev": "^2.0.0",
2525
"broccoli-sass": "0.6.2",
2626
"connect-restreamer": "^1.0.1",
27-
"ember-api-store": "1.0.14",
27+
"ember-api-store": "1.0.15",
2828
"ember-browserify": "^0.6.4",
2929
"ember-cli": "0.2.0",
3030
"ember-cli-app-version": "0.3.3",

0 commit comments

Comments
 (0)