consul-templaterb 1.17.0 → 1.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: f5db899f30382d8fe310ab54f5c8d7ca8c7f2a46a1dc0e1f66522d5eb6c5bf7c
4
- data.tar.gz: 2b5a94664f2ab8409b1d1e763d8aca620138f11546a6c610e9baad711ad30988
2
+ SHA1:
3
+ metadata.gz: 188b824f4573d3c8483b279e7e73705ee4e48628
4
+ data.tar.gz: 0f781084e76bfe687402ebb9c0ebce0df986cd30
5
5
  SHA512:
6
- metadata.gz: 97c454b170b61ac2ec93a84aefbf006a6e90cfe0369caab1d321d1aa0e5761686036e693603a67ec051207b48665981c4e1d6c31a11d9c2ad403dfc0e7e966b5
7
- data.tar.gz: 21fd3ad5e6c602a6bfc6b9edea7a85bf9415605869d5a9f13595bb23940a974d525a0b70c3c418be5959bdd4b1469a887b49d7a01797869e1e884a50801be043
6
+ metadata.gz: 399422eb1ec5564bbb09abf9ed3a82eb2a4647df095350928c372be06e6d6eac65c5dd251ce66bbc72a50863282333aa11bc980f2fb386de305706207055c680
7
+ data.tar.gz: 70b630427515451230d14a3a17ac3c44caa3e58b241aa51d51953f74722f0f5c23f66a35b7580fe37fca6806a5483295b6b0577933db52856ea612f37203251a
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## (UNRELEASED)
4
4
 
5
+ ## 1.17.1 (July 15, 2019)
6
+
7
+ NEW FEATURES:
8
+
9
+ * consul-ui now supports displaying coordinates and evaluating RTT for any node
10
+
5
11
  ## 1.17.0 (July 15, 2019)
6
12
 
7
13
  IMPROVEMENTS:
@@ -60,6 +60,9 @@ options = {
60
60
  '/v1/catalog/nodes': {
61
61
  min_duration: 15, # Do not wake up before 15 seconds when node appear/disappear
62
62
  },
63
+ '/v1/coordinate/nodes': {
64
+ min_duration: 60, # Since coordinates change a lot, refresh coordinates every 30 seconds
65
+ },
63
66
  '/v1/catalog/datacenters': {
64
67
  min_duration: 60, # Datacenters are not added every minute, right?
65
68
  },
@@ -1,5 +1,5 @@
1
1
  module Consul
2
2
  module Async
3
- VERSION = '1.17.0'.freeze
3
+ VERSION = '1.17.1'.freeze
4
4
  end
5
5
  end
@@ -15,6 +15,7 @@
15
15
  services_blacklist = services_blacklist_raw.map { |v| Regexp.new(v) } # Compute the health of a Service
16
16
 
17
17
  service_per_node = {}
18
+ all_coordinates = coordinate.nodes.map { |c| [c['Node'], c['Coord']] }.to_h
18
19
  services.each do |service_name, tags|
19
20
  if ! services_blacklist.any? {|r| r.match(service_name)}
20
21
  service(service_name, tag: service_tag_filter).sort {|a,b| a['Node']['Node'] <=> b['Node']['Node'] }.each do |snode|
@@ -55,6 +56,7 @@
55
56
  Service: node_services_data,
56
57
  # Only put Checks on a Node
57
58
  checks: snode["Checks"].select{|c| c['ServiceID'].empty? }.map{|c| {output: c['Output'], notes: c['Notes'], name: c['Name'], checkid: c['CheckID'], status: c['Status']}},
59
+ Coord: all_coordinates[node_node_data[:Name]],
58
60
  }
59
61
 
60
62
  service_per_node[snode['Node']['Node']] = node_data
@@ -211,6 +211,10 @@ html, body {
211
211
  display: flex;
212
212
  }
213
213
 
214
+ .distancesButton {
215
+ float: right;
216
+ }
217
+
214
218
  .instance-content-header h5 {
215
219
  margin-right: 10px;
216
220
  }
@@ -60,12 +60,99 @@ class ConsulNodes {
60
60
  })
61
61
  }
62
62
 
63
+ // taken from https://www.consul.io/docs/internals/coordinates.html#working-with-coordinates
64
+ compute_dist(a, b) {
65
+ var sumsq = 0.0
66
+ for (var i = 0; i < a.Vec.length; i++) {
67
+ var diff = a.Vec[i] - b.Vec[i]
68
+ sumsq += diff * diff
69
+ }
70
+ var rtt = Math.sqrt(sumsq) + a.Height + b.Height
71
+
72
+ // Apply the adjustment components, guarding against negatives.
73
+ var adjusted = rtt + a.Adjustment + b.Adjustment
74
+ if (adjusted > 0.0) {
75
+ rtt = adjusted
76
+ }
77
+
78
+ // Go's times are natively nanoseconds, so we convert from seconds.
79
+ const secondsToNanoseconds = 1.0e9
80
+ return rtt
81
+ }
82
+
83
+ compute_all_distances(instances, node) {
84
+ const asc = function(arr) { return arr.sort((a, b) => a - b); }
85
+ // sample standard deviation
86
+ const std = function (arr) {
87
+ const mu = mean(arr);
88
+ const diffArr = arr.map(a => (a - mu) ** 2);
89
+ return Math.sqrt(sum(diffArr) / (arr.length - 1));
90
+ };
91
+
92
+ const quantile = function(sorted, q) {
93
+ //const sorted = asc(arr);
94
+ const pos = ((sorted.length) - 1) * q;
95
+ //console.log("pos", pos, "for", q);
96
+ const base = Math.floor(pos);
97
+ const rest = pos - base;
98
+ if ((sorted[base + 1] !== undefined)) {
99
+ return sorted[base] + rest * (sorted[base + 1] - sorted[base]);
100
+ } else {
101
+ return sorted[base];
102
+ }
103
+ };
104
+
105
+ var sum = 0;
106
+ var count = 0;
107
+ var ret = {
108
+ min: 3600,
109
+ min_node: null,
110
+ max: 0,
111
+ max_node: null,
112
+ };
113
+ var all_values = [];
114
+ var myCoords = instances[node]['Coord']
115
+ if (myCoords == null) {
116
+ console.log("Coords are not defined for ", node)
117
+ return null;
118
+ } else {
119
+ for (var key in instances) {
120
+ var instance = instances[key];
121
+ if (key != node && instance != null && instance['Coord'] != null) {
122
+ count++
123
+ var coord = instance['Coord'];
124
+ if (coord != null) {
125
+ const rtt = this.compute_dist(myCoords, coord);
126
+ all_values.push(rtt);
127
+ if (rtt < ret.min) {
128
+ ret.min = rtt;
129
+ ret.min_node = key
130
+ }
131
+ if (rtt > ret.max) {
132
+ ret.max = rtt;
133
+ ret.max_node = key;
134
+ }
135
+ sum += rtt;
136
+ }
137
+ }
138
+ }
139
+ }
140
+ all_values = all_values.sort();
141
+ ret.avg = sum / count;
142
+ ret.q50 = quantile(all_values, .50);
143
+ ret.q90 = quantile(all_values, .90);
144
+ ret.q99 = quantile(all_values, .99);
145
+ ret.q999 = quantile(all_values, .999);
146
+ ret.q9999 = quantile(all_values, .9999);
147
+ return ret;
148
+ }
149
+
63
150
  displayInstances(instances) {
64
151
  $("#instances-list").html("");
65
152
 
66
153
  // var serviceStatus = buildServiceStatus(service);
67
154
  this.displayedCount = 0;
68
-
155
+ var nodesInfo = this;
69
156
  for (var key in instances) {
70
157
  var instance = instances[key];
71
158
 
@@ -95,6 +182,40 @@ class ConsulNodes {
95
182
  contentHead.appendChild(nodeAddressGenator(instance['Node']['Address']));
96
183
  contentHead.appendChild(nodeMetaGenerator(instance['Node']['Meta']));
97
184
  content.appendChild(contentHead);
185
+ var distances = document.createElement('div');
186
+ var distancesRefresh = document.createElement("button");
187
+ distancesRefresh.appendChild(document.createTextNode("Show/Hide Node Latency"));
188
+ distancesRefresh.setAttribute("class", "distancesButton");
189
+ distances.appendChild(distancesRefresh);
190
+ var distancesContent = document.createElement("div");
191
+ distances.appendChild(distancesContent);
192
+ (function() {
193
+ var nodeName = instance['Node']['Name'];
194
+ var distancesContentToUpdate = distancesContent;
195
+ var buttonToHide = $(distancesRefresh);
196
+ $(distancesRefresh).click(function(){
197
+ if (distancesContentToUpdate.children.length == 0){
198
+ var x = nodesInfo.compute_all_distances(instances, nodeName);
199
+ var dl = document.createElement(dl);
200
+ dl.className = 'row';
201
+ for (var i in x) {
202
+ var dt = document.createElement("dt");
203
+ dt.appendChild(document.createTextNode(i));
204
+ dt.className = 'col-sm-4';
205
+ dl.appendChild(dt);
206
+ var dd = document.createElement("dd");
207
+ dd.appendChild(document.createTextNode(x[i]));
208
+ dd.className = 'col-sm-8';
209
+ dl.appendChild(dd);
210
+ }
211
+ distancesContentToUpdate.appendChild(dl);
212
+ } else {
213
+ distancesContentToUpdate.innerHTML = '';
214
+ }
215
+ });
216
+ })();
217
+ content.appendChild(distances);
218
+ //distances.appendChild()
98
219
  var nodesChecks = document.createElement('div');
99
220
  nodesChecks.setAttribute('class','nodes-checks');
100
221
  nodesChecks.appendChild(checksStatusGenerator(instance, instance['Node']['Name']));
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consul-templaterb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.0
4
+ version: 1.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SRE Core Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-15 00:00:00.000000000 Z
11
+ date: 2019-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request
@@ -242,7 +242,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
242
  - !ruby/object:Gem::Version
243
243
  version: '0'
244
244
  requirements: []
245
- rubygems_version: 3.0.4
245
+ rubyforge_project:
246
+ rubygems_version: 2.6.14.4
246
247
  signing_key:
247
248
  specification_version: 4
248
249
  summary: Implementation of Consul template using Ruby and .erb templating language