ndelitski / rancher-alarms

Will kick your ass if found unhealthy service in Rancher environment
85 stars 20 forks source link

State buffer length is always 1 #2

Closed jayhding closed 8 years ago

jayhding commented 8 years ago

Below codes in monitor.es6 tend to initialise two buffers with given length but both buffers will be created with length as 1.

class StateRingBuffer {
  get length() {
    return this._arr.length;
  }
  constructor(length) {
    this._arr = new Array(length);
  }

...

    this._unhealtyStatesBuffer = new StateRingBuffer(this.healthcheck.unhealthyThreshold);
    this._healtyStatesBuffer = new StateRingBuffer(this.healthcheck.healthyThreshold);
...
}

Need to change array initialisation method to

class StateRingBuffer {
  constructor(length) {
    this._arr = Array.apply( null, { length: length } );
  }
ndelitski commented 8 years ago

@JayHaoDing Hi Jay! On which version of node can i reproduce this issue?

jayhding commented 8 years ago

Hi, I'm using Node 4.2.1

jayhding commented 8 years ago

@ndelitski Hi Nick, not sure if this issue can be reproduced from your side?

ndelitski commented 8 years ago

seems new array is not iterable until i specify length property, merged https://github.com/ndelitski/rancher-alarms/pull/3