signalk-questdb 2.3.2 → 2.4.0

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.
Files changed (45) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/README.md +92 -0
  3. package/dist/container-env.js +14 -0
  4. package/dist/container-env.js.map +1 -1
  5. package/dist/drained.d.ts +2 -0
  6. package/dist/drained.js +22 -0
  7. package/dist/drained.js.map +1 -0
  8. package/dist/ilp-writer.d.ts +2 -0
  9. package/dist/ilp-writer.js +48 -13
  10. package/dist/ilp-writer.js.map +1 -1
  11. package/dist/image-refresh.d.ts +35 -0
  12. package/dist/image-refresh.js +118 -0
  13. package/dist/image-refresh.js.map +1 -0
  14. package/dist/index.js +464 -136
  15. package/dist/index.js.map +1 -1
  16. package/dist/query-client.d.ts +12 -1
  17. package/dist/query-client.js +37 -3
  18. package/dist/query-client.js.map +1 -1
  19. package/dist/questdb-ready.d.ts +21 -0
  20. package/dist/questdb-ready.js +35 -0
  21. package/dist/questdb-ready.js.map +1 -0
  22. package/dist/questdb-watchdog.d.ts +73 -0
  23. package/dist/questdb-watchdog.js +308 -0
  24. package/dist/questdb-watchdog.js.map +1 -0
  25. package/dist/watchdog-checks.d.ts +50 -0
  26. package/dist/watchdog-checks.js +279 -0
  27. package/dist/watchdog-checks.js.map +1 -0
  28. package/package.json +3 -3
  29. package/public/assets/AppPanel-C293yEHl.js +1 -0
  30. package/public/assets/{PluginConfigurationPanel-DR-y5e3d.js → PluginConfigurationPanel-7qfy8fIR.js} +1 -1
  31. package/public/assets/_virtual_mf-localSharedImportMap___mfe_internal__signalk_questdb__mf_owner__1-BH9mY6vj.js +1 -0
  32. package/public/assets/_virtual_mf___mfe_internal__signalk_questdb__mf_owner__97224418320974__loadShare__shared-H1lSL0nN.js +1 -0
  33. package/public/assets/{_virtual_mf___mfe_internal__signalk_questdb__mf_owner__196689844091135__prebuild__react__prebuild__-eQjVI-Oj.js → _virtual_mf___mfe_internal__signalk_questdb__mf_owner__97224418320974__prebuild__react__prebuild__-CTXDWPi7.js} +1 -1
  34. package/public/assets/{dist-C5M3fhBw.js → dist-BhVCbinB.js} +1 -1
  35. package/public/assets/helpers-CvnX61Ju.js +1 -0
  36. package/public/assets/{hostInit-3qWTwrQQ.js → hostInit-Ds8KD_fS.js} +1 -1
  37. package/public/assets/{index-D2iWq8nf.js → index-QJC86Uvi.js} +2 -2
  38. package/public/assets/{pendingShares-PvyVL1Z8.js → pendingShares-DemvETkM.js} +2 -2
  39. package/public/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  40. package/public/assets/{utils-v9GZlbdk.js → utils-D62kKhzq.js} +1 -1
  41. package/public/remoteEntry.js +2 -2
  42. package/public/assets/AppPanel-Fvhb8xTK.js +0 -1
  43. package/public/assets/_virtual_mf-localSharedImportMap___mfe_internal__signalk_questdb__mf_owner__1-BUtmcsA-.js +0 -1
  44. package/public/assets/_virtual_mf___mfe_internal__signalk_questdb__mf_owner__196689844091135__loadShare__shared-BRI06Lxu.js +0 -8
  45. package/public/assets/helpers-oIxDNnZJ.js +0 -1
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "2.3.2"
2
+ ".": "2.4.0"
3
3
  }
package/README.md CHANGED
@@ -132,6 +132,51 @@ rootless Podman.
132
132
  | Container network | `sk-network` | Shared Podman/Docker network QuestDB joins in managed mode, so the companion signalk-grafana reaches it by container DNS; host-port publication is separate ("Bind to 0.0.0.0") |
133
133
  | Bind to 0.0.0.0 | `false` | Publish QuestDB's ports on all interfaces (see Connectivity) |
134
134
 
135
+ ### QuestDB updates
136
+
137
+ The panel's **update check** compares the running QuestDB with its latest stable
138
+ release. **Update** pulls that release, recreates the container on it and saves
139
+ it as the image version.
140
+
141
+ After the plugin itself was updated, and at its very first start, the plugin
142
+ also checks once on its own, in the background. It does so only in managed mode,
143
+ and only where the image version is a tag that moves, such as the default
144
+ `latest`. If QuestDB runs an older release than the latest stable one, the
145
+ plugin pulls the tag again and recreates the container on it. The image version
146
+ stays `latest`. Without this check, QuestDB on `latest` would stay on whatever
147
+ release the first install pulled, because signalk-container pulls an image only
148
+ when it is missing. An image version that names one release, such as `9.4.3`,
149
+ stays as it is, and so does one that **Update** saved while the check was
150
+ waiting. QuestDB is down while it starts again, as with **Update**. Progress
151
+ goes to the debug log, and failures go to the server log. A recreate that fails
152
+ half way and leaves QuestDB stopped or without a container is followed by a
153
+ start, as the plugin's own start would do. Only if that fails too does the
154
+ status line say so.
155
+
156
+ With [signalk-internet](https://github.com/meri-imperiumi/signalk-internet)
157
+ enabled, the check waits for a free link. On a metered, captive or offline link
158
+ it asks again from time to time, for as long as the plugin runs. Without
159
+ signalk-internet, the link counts as free. Telling the two apart needs
160
+ signalk-container 1.38.0 or later; with an older one, the check does not run. A
161
+ failure to read the running or the latest version is also tried again later.
162
+
163
+ The check is done once QuestDB runs the latest release, or once its container
164
+ runs the image the pull brought, even if QuestDB still reports an older release
165
+ afterwards. It then waits for the next plugin update. The next start checks
166
+ again wherever the container keeps its old image, or where the new one cannot
167
+ be told from the old:
168
+
169
+ - the plugin stopped first;
170
+ - the download failed, or something else failed before the recreate;
171
+ - an InfluxDB import, a GPX import or an export was running;
172
+ - the string table was being rebuilt;
173
+ - the container was stopped, which the check leaves as it is;
174
+ - the container was wedged;
175
+ - the tag on Docker Hub did not name the latest release yet.
176
+
177
+ A tag that never reaches the latest release, such as `9` while the latest is
178
+ `10.1.0`, therefore costs a pull and a look at GitHub at every start.
179
+
135
180
  ## Recording
136
181
 
137
182
  ### Schema
@@ -804,6 +849,53 @@ shown on the status card as **WAL suspended**. Two causes need two remedies:
804
849
  shows those numbers and offers **Skip**; if the stuck segment is the newest
805
850
  one, skipping drops the entire pending backlog, and the panel says so.
806
851
 
852
+ ### Out of memory or not answering
853
+
854
+ QuestDB caps the native memory it tracks below the container's memory limit
855
+ and fails any allocation past the cap with `global RSS memory limit exceeded`.
856
+ When something holds memory at the cap, queries fail, the WAL apply job then
857
+ suspends the tables, and in the end QuestDB stops accepting HTTP connections. The JVM stays up throughout, so the
858
+ container's restart policy never acts.
859
+
860
+ In managed mode the plugin checks for this every minute while it runs, and
861
+ restarts the QuestDB container when:
862
+
863
+ - QuestDB recently reported its global memory limit, and over consecutive
864
+ checks its native memory is still held at that limit, it fails even the
865
+ health check with it, or it has stopped answering. A single large query
866
+ frees what it held when it ends, so it does not count, nor does a client that
867
+ keeps asking for one.
868
+ - the container is running but QuestDB has answered nothing for several
869
+ minutes, over consecutive checks. A QuestDB busy with a long statement still
870
+ answers it in the end, and no check counts while a parquet export streams
871
+ from it.
872
+
873
+ Before the restart the plugin writes QuestDB's message and its last error lines
874
+ to the server log, shows the reason on the status card, and raises the Signal K
875
+ notification `notifications.signalk-questdb.watchdog`. After the restart it
876
+ logs the outcome. Once QuestDB answers again the notification returns to normal;
877
+ when it answered right after the restart, the notification keeps the time and
878
+ the reason. Restarts are rate limited, spaced apart and capped per few hours of
879
+ the plugin running; past that the plugin logs that the restart is held back and
880
+ keeps the alert up. A restart that fails, because stopping or starting the
881
+ container failed, counts against none of these limits: the plugin tries again a
882
+ few minutes later, since the container may be left stopped. It reports the
883
+ first failure; while the retries keep failing, they go to the debug log only.
884
+
885
+ The plugin leaves a container alone if someone else stopped it, and starts one
886
+ that its own restart left stopped. One exception: a container stopped by hand
887
+ while a stop of the plugin's is still pending, or right after a restart of the
888
+ plugin's before the plugin has seen it running again, may be started again too.
889
+ While a stop of the plugin's hangs, it sends no further stop. An external
890
+ QuestDB is never restarted. A
891
+ QuestDB that is already stuck when the plugin starts, as after a Signal K
892
+ restart while it was stuck, is not covered: restarting the plugin stops the
893
+ container and starts it afresh.
894
+
895
+ The managed container runs with QuestDB's query caches off: history reads put
896
+ their time range into the SQL, so the caches never got a hit, and on older
897
+ QuestDB releases they held memory.
898
+
807
899
  ### Performance (Pi and other low-power hosts)
808
900
 
809
901
  - **Default sampling rate** of 2000 ms limits each path to one write per two
@@ -134,6 +134,20 @@ export function buildContainerEnv(config) {
134
134
  // apply memory-pressure backoff that precedes a suspension, so raise this
135
135
  // back to INFO when diagnosing a database that has stopped recording.
136
136
  QDB_LOG_W_STDOUT_LEVEL: "ERROR",
137
+ // The HTTP endpoint keeps up to 128 compiled queries (32 blocks of 4) for
138
+ // reuse by identical SQL text, and pg-wire keeps another such cache. The
139
+ // plugin's history reads put their time range into the SQL as literals,
140
+ // and so do Grafana's macros, so neither cache gets a hit — they only
141
+ // fill. On QuestDB before 10.0.0 every cached parallel GROUP BY / SAMPLE
142
+ // BY also keeps its native buffers at their peak size (fixed upstream in
143
+ // questdb#7267): about 7 MiB each over a month of data, so a full cache
144
+ // holds more than the 691 MiB the 768m cap leaves QuestDB, and it then
145
+ // fails every allocation with "global RSS memory limit exceeded". Seen
146
+ // twice on 9.4.3 within a day: 20 distinct reads added 150 MiB that only
147
+ // flush_query_cache() or a restart gave back. Without the caches, each
148
+ // read frees its buffers when it ends.
149
+ QDB_HTTP_QUERY_CACHE_ENABLED: "false",
150
+ QDB_PG_SELECT_CACHE_ENABLED: "false",
137
151
  QDB_CAIRO_O3_COLUMN_MEMORY_SIZE: "262144",
138
152
  ...(config.compression && config.compression !== "none"
139
153
  ? {
@@ -1 +1 @@
1
- {"version":3,"file":"container-env.js","sourceRoot":"","sources":["../src/container-env.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,wEAAwE;AACxE,8EAA8E;AAC9E,6EAA6E;AAC7E,0EAA0E;AAC1E,6EAA6E;AAC7E,yBAAyB;AAIzB,kEAAkE;AAClE,6EAA6E;AAC7E,0EAA0E;AAC1E,0EAA0E;AAC1E,yEAAyE;AACzE,0EAA0E;AAC1E,6EAA6E;AAC7E,2EAA2E;AAC3E,0EAA0E;AAC1E,QAAQ;AACR,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAE1C,0EAA0E;AAC1E,2EAA2E;AAC3E,8EAA8E;AAC9E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,EAAE,sBAAsB;QACrD,oCAAoC,EAAE,sBAAsB;QAC5D,sCAAsC,EAAE,sBAAsB;QAC9D,0CAA0C,EAAE,sBAAsB;QAClE,wCAAwC,EAAE,sBAAsB;QAChE,2CAA2C,EAAE,sBAAsB;QACnE,4CAA4C,EAAE,sBAAsB;QACpE,iCAAiC,EAAE,sBAAsB;QAEzD,wEAAwE;QACxE,0EAA0E;QAC1E,mEAAmE;QACnE,mEAAmE;QACnE,uEAAuE;QACvE,0EAA0E;QAC1E,sEAAsE;QACtE,sBAAsB,EAAE,OAAO;QAE/B,0EAA0E;QAC1E,yEAAyE;QACzE,wEAAwE;QACxE,sEAAsE;QACtE,yEAAyE;QACzE,yEAAyE;QACzE,wEAAwE;QACxE,uEAAuE;QACvE,uEAAuE;QACvE,yEAAyE;QACzE,uEAAuE;QACvE,uCAAuC;QACvC,4BAA4B,EAAE,OAAO;QACrC,2BAA2B,EAAE,OAAO;QAEpC,+BAA+B,EAAE,QAAQ;QACzC,GAAG,CAAC,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,KAAK,MAAM;YACrD,CAAC,CAAC;gBACE,uCAAuC,EACrC,MAAM,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK;gBAChD,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,MAAM,IAAI,MAAM,CAAC,gBAAgB;oBAC1D,CAAC,CAAC;wBACE,uCAAuC,EAAE,MAAM,CAC7C,MAAM,CAAC,gBAAgB,CACxB;qBACF;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ServerResponse } from "node:http";
2
+ export declare function drained(res: ServerResponse, signal?: AbortSignal): Promise<boolean>;
@@ -0,0 +1,22 @@
1
+ // After a write the response refused, waits until it takes more; false once
2
+ // the client is gone, or once `signal` (the export's deadline) aborts. A
3
+ // response whose client disconnected never drains, nor does one whose client
4
+ // stays connected but stops reading, and a stream loop waiting for it would
5
+ // hold its QuestDB export open for good, and with it the watchdog's export
6
+ // count (questdbExportsRunning in index.ts).
7
+ export function drained(res, signal) {
8
+ if (res.destroyed || signal?.aborted)
9
+ return Promise.resolve(false);
10
+ return new Promise((resolve) => {
11
+ const settle = () => {
12
+ res.off("drain", settle);
13
+ res.off("close", settle);
14
+ signal?.removeEventListener("abort", settle);
15
+ resolve(!res.destroyed && !signal?.aborted);
16
+ };
17
+ res.once("drain", settle);
18
+ res.once("close", settle);
19
+ signal?.addEventListener("abort", settle, { once: true });
20
+ });
21
+ }
22
+ //# sourceMappingURL=drained.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drained.js","sourceRoot":"","sources":["../src/drained.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,yEAAyE;AACzE,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,6CAA6C;AAC7C,MAAM,UAAU,OAAO,CACrB,GAAmB,EACnB,MAAoB;IAEpB,IAAI,GAAG,CAAC,SAAS,IAAI,MAAM,EAAE,OAAO;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,GAAG,EAAE;YAClB,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACzB,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACzB,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC7C,OAAO,CAAC,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC,CAAC;QACF,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC1B,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -32,6 +32,7 @@ export declare class ILPWriter {
32
32
  private readonly maxReconnectDelay;
33
33
  private readonly stableConnectionMs;
34
34
  private readonly unhealthyAfterFlaps;
35
+ private readonly disconnectTimeoutMs;
35
36
  private readonly flushIntervalMs;
36
37
  constructor(host: string, port: number, debug?: (msg: string) => void, callbacks?: {
37
38
  onUnhealthy?: (msg: string) => void;
@@ -43,6 +44,7 @@ export declare class ILPWriter {
43
44
  maxReconnectDelay?: number;
44
45
  stableConnectionMs?: number;
45
46
  unhealthyAfterFlaps?: number;
47
+ disconnectTimeoutMs?: number;
46
48
  };
47
49
  });
48
50
  connect(): Promise<void>;
@@ -22,6 +22,10 @@ const STABLE_CONNECTION_MS = 5000;
22
22
  // surface a visible plugin error, so a flapping QuestDB is not invisible behind
23
23
  // a permanently-green "Recording" status.
24
24
  const UNHEALTHY_AFTER_FLAPS = 5;
25
+ // How long disconnect() lets the socket send what is buffered. A QuestDB that
26
+ // has stopped reading never takes it, and the plugin's stop and update wait
27
+ // on disconnect() under the plugin's lifecycle lock.
28
+ const DISCONNECT_TIMEOUT_MS = 10_000;
25
29
  // Upper bound on lines retained while disconnected. QuestDB being down must not
26
30
  // grow the buffer without limit on a Pi/Cerbo. When full we drop the OLDEST
27
31
  // lines — for a live history feed the most recent samples are the ones worth
@@ -121,6 +125,7 @@ export class ILPWriter {
121
125
  maxReconnectDelay;
122
126
  stableConnectionMs;
123
127
  unhealthyAfterFlaps;
128
+ disconnectTimeoutMs;
124
129
  // How often buffered lines are committed. Unlike `timing`, this is a real
125
130
  // production knob (wired to the plugin's ilpFlushIntervalMs config) — see
126
131
  // the DEFAULT_FLUSH_INTERVAL_MS comment for the batching rationale.
@@ -140,6 +145,7 @@ export class ILPWriter {
140
145
  this.maxReconnectDelay = t.maxReconnectDelay ?? MAX_RECONNECT_DELAY_MS;
141
146
  this.stableConnectionMs = t.stableConnectionMs ?? STABLE_CONNECTION_MS;
142
147
  this.unhealthyAfterFlaps = t.unhealthyAfterFlaps ?? UNHEALTHY_AFTER_FLAPS;
148
+ this.disconnectTimeoutMs = t.disconnectTimeoutMs ?? DISCONNECT_TIMEOUT_MS;
143
149
  this.reconnectDelay = this.initialReconnectDelay;
144
150
  }
145
151
  async connect() {
@@ -150,7 +156,18 @@ export class ILPWriter {
150
156
  return new Promise((resolve, reject) => {
151
157
  const socket = new net.Socket();
152
158
  this.socket = socket;
159
+ // Once disconnect() has let go of this socket, its events are stale:
160
+ // they end this connect() and leave the writer's state alone. Its
161
+ // `close` coming after the next connect() began would otherwise end
162
+ // that attempt and count as a dropped connection. A connect that
163
+ // disconnect() cut short resolves, as one that got through before it
164
+ // did: a stop during the plugin's start is no failure of the start.
165
+ const current = () => this.socket === socket;
153
166
  socket.connect(this.port, this.host, () => {
167
+ if (!current()) {
168
+ resolve();
169
+ return;
170
+ }
154
171
  this.connected = true;
155
172
  this.connecting = false;
156
173
  this.connectedAt = Date.now();
@@ -165,10 +182,10 @@ export class ILPWriter {
165
182
  resolve();
166
183
  });
167
184
  socket.on("error", (err) => {
168
- if (this.connecting) {
185
+ // Fails a connect still in progress; a no-op once it connected.
186
+ reject(err);
187
+ if (current())
169
188
  this.connecting = false;
170
- reject(err);
171
- }
172
189
  this.debug(`ILP socket error: ${err.message}`);
173
190
  });
174
191
  // `close` is the single source of truth for a connection ending. Node
@@ -177,6 +194,11 @@ export class ILPWriter {
177
194
  // lives here — the connect() rejection path deliberately does NOT also
178
195
  // reschedule, which would double-count flaps and run two timers.
179
196
  socket.on("close", () => {
197
+ if (!current()) {
198
+ // disconnect() destroyed it before it connected: no error came.
199
+ resolve();
200
+ return;
201
+ }
180
202
  const wasStable = this.connected && !this.stableTimer;
181
203
  const upForMs = this.connectedAt ? Date.now() - this.connectedAt : 0;
182
204
  this.connected = false;
@@ -570,18 +592,31 @@ export class ILPWriter {
570
592
  if (this.bufferedLines > 0 && this.connected) {
571
593
  this.flush(true);
572
594
  }
573
- return new Promise((resolve) => {
574
- if (!this.socket) {
575
- resolve();
576
- return;
577
- }
578
- this.socket.end(() => {
579
- this.socket?.destroy();
580
- this.socket = null;
581
- this.connected = false;
582
- this.awaitingDrain = false;
595
+ // The writer is disconnected from here on, whatever the socket still
596
+ // does (see connect()), so a connect() right after this starts clean.
597
+ const socket = this.socket;
598
+ const wasConnected = this.connected;
599
+ this.socket = null;
600
+ this.connected = false;
601
+ this.connecting = false;
602
+ this.awaitingDrain = false;
603
+ if (!socket || socket.closed)
604
+ return;
605
+ // Resolves once the socket has closed, having sent what is buffered. A
606
+ // QuestDB that has stopped reading never takes the rest: past the
607
+ // deadline the socket is destroyed, and the batches it still held go
608
+ // back into the buffer (see writeBatch). A socket that never connected
609
+ // holds nothing and goes at once.
610
+ await new Promise((resolve) => {
611
+ const deadline = setTimeout(() => socket.destroy(), this.disconnectTimeoutMs);
612
+ socket.once("close", () => {
613
+ clearTimeout(deadline);
583
614
  resolve();
584
615
  });
616
+ if (wasConnected)
617
+ socket.end(() => socket.destroy());
618
+ else
619
+ socket.destroy();
585
620
  });
586
621
  }
587
622
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ilp-writer.js","sourceRoot":"","sources":["../src/ilp-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,yEAAyE;AACzE,2EAA2E;AAC3E,yEAAyE;AACzE,4EAA4E;AAC5E,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,2EAA2E;AAC3E,0DAA0D;AAC1D,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,0BAA0B,GAAG,IAAI,CAAC;AACxC,MAAM,sBAAsB,GA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IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC7C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAED,qEAAqE;QACrE,sEAAsE;QACtE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC3B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM;YAAE,OAAO;QACrC,uEAAuE;QACvE,kEAAkE;QAClE,qEAAqE;QACrE,uEAAuE;QACvE,kCAAkC;QAClC,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAClC,MAAM,QAAQ,GAAG,UAAU,CACzB,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,EACtB,IAAI,CAAC,mBAAmB,CACzB,CAAC;YACF,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;gBACxB,YAAY,CAAC,QAAQ,CAAC,CAAC;gBACvB,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;YACH,IAAI,YAAY;gBAAE,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;;gBAChD,MAAM,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,35 @@
1
+ import type { ContainerManagerApi } from "signalk-container-helper";
2
+ export interface ImageRefreshDeps {
3
+ containers: Pick<ContainerManagerApi, "pullImage" | "getImageDigest" | "listContainers" | "getState">;
4
+ /** The container's name, as given to signalk-container. */
5
+ name: string;
6
+ /** The image without its tag, such as `questdb/questdb`. */
7
+ image: string;
8
+ /** Runs `fn` under the plugin's lifecycle lock. */
9
+ withLock<T>(fn: () => Promise<T>): Promise<T>;
10
+ /** Whether the start the check belongs to still stands. */
11
+ current(): boolean;
12
+ /** The image tag configured now. */
13
+ configuredTag(): string;
14
+ /** Why no recreate may run now, or null. */
15
+ blocked(): string | null;
16
+ /**
17
+ * Has signalk-container recreate the container on what the pull brought
18
+ * for `tag`, then waits for it and reconnects.
19
+ */
20
+ recreate(tag: string): Promise<void>;
21
+ /** Starts the container on `tag` as a plugin start would, and reconnects. */
22
+ restore(tag: string): Promise<void>;
23
+ debug(msg: string): void;
24
+ error(msg: string): void;
25
+ /** For QuestDB left down: the server log and the status line. */
26
+ reportDown(msg: string): void;
27
+ }
28
+ /**
29
+ * Pulls `tag`, then recreates the container on it under the lifecycle lock.
30
+ * True once the container runs another image than before, even where a
31
+ * later step failed: the check records the plugin version only then, and an
32
+ * unrecorded recreate would run again at every start. False where nothing
33
+ * changed, or where that cannot be told; a throw also means nothing changed.
34
+ */
35
+ export declare function refreshImage(deps: ImageRefreshDeps, tag: string, signal: AbortSignal): Promise<boolean>;
@@ -0,0 +1,118 @@
1
+ // The update the image check after a plugin update runs
2
+ // (updateImageAfterPluginUpdate in signalk-container-helper): pull the
3
+ // configured floating tag again, then recreate QuestDB on what the pull
4
+ // brought. The plugin's state comes in through `deps`, so it runs against a
5
+ // fake container manager in tests.
6
+ import { matchContainerInfo } from "signalk-container-helper";
7
+ const message = (err) => err instanceof Error ? err.message : String(err);
8
+ /**
9
+ * Pulls `tag`, then recreates the container on it under the lifecycle lock.
10
+ * True once the container runs another image than before, even where a
11
+ * later step failed: the check records the plugin version only then, and an
12
+ * unrecorded recreate would run again at every start. False where nothing
13
+ * changed, or where that cannot be told; a throw also means nothing changed.
14
+ */
15
+ export async function refreshImage(deps, tag, signal) {
16
+ const { containers } = deps;
17
+ const ended = () => signal.aborted || !deps.current();
18
+ if (ended())
19
+ return false;
20
+ const ref = `${deps.image}:${tag}`;
21
+ const stateOf = async () => {
22
+ try {
23
+ return await containers.getState(deps.name);
24
+ }
25
+ catch {
26
+ return "unknown";
27
+ }
28
+ };
29
+ // The image the container runs; null where it cannot be told.
30
+ const runningImage = async () => {
31
+ try {
32
+ const live = matchContainerInfo(await containers.listContainers(), deps.name);
33
+ return live ? await containers.getImageDigest(live.name) : null;
34
+ }
35
+ catch {
36
+ return null;
37
+ }
38
+ };
39
+ // Outside the lock, so a download holds up no stop, purge or restart.
40
+ await containers.pullImage(ref);
41
+ return deps.withLock(async () => {
42
+ // Asked again under the lock: an update from the button since the check
43
+ // began moved QuestDB to the release it named, and that choice stands.
44
+ if (deps.configuredTag() !== tag) {
45
+ deps.debug(`image refresh skipped: the image version is no longer ${tag}`);
46
+ return false;
47
+ }
48
+ const blocked = deps.blocked();
49
+ if (blocked) {
50
+ deps.debug(`image refresh skipped: ${blocked}`);
51
+ return false;
52
+ }
53
+ // A container someone else stopped is left alone, as the watchdog leaves
54
+ // it; what is started again below is only what this run took down.
55
+ const stateBefore = await stateOf();
56
+ if (stateBefore !== "running") {
57
+ deps.debug(`image refresh skipped: the container is ${stateBefore}`);
58
+ return false;
59
+ }
60
+ // Docker Hub may carry the release later than GitHub announces it; the
61
+ // pull then brought the image QuestDB already runs.
62
+ const pulled = await containers.getImageDigest(ref);
63
+ const before = await runningImage();
64
+ if (pulled !== null && pulled === before) {
65
+ deps.debug(`image refresh skipped: ${ref} is the image QuestDB runs`);
66
+ return false;
67
+ }
68
+ // Asked again after the pull and these reads: stop() does not wait for
69
+ // the lock.
70
+ if (ended())
71
+ return false;
72
+ // A failure is judged by what it left: one before the container was
73
+ // handed over left the old image, as below.
74
+ let failure;
75
+ try {
76
+ await deps.recreate(tag);
77
+ }
78
+ catch (err) {
79
+ failure = err;
80
+ }
81
+ let state = await stateOf();
82
+ if ((state === "missing" || state === "stopped") && !ended()) {
83
+ // Left down, as where a failure stopped the old container but did not
84
+ // remove it, or removed it and did not create the new one: nothing
85
+ // starts it again but a plugin start, which this does instead.
86
+ try {
87
+ await deps.restore(tag);
88
+ }
89
+ catch (err) {
90
+ // After a stop, the next start's status line is not this run's.
91
+ if (!ended()) {
92
+ deps.reportDown(`Updating QuestDB's image left it down` +
93
+ (failure !== undefined ? ` (${message(failure)})` : "") +
94
+ `, and starting it again failed: ${message(err)}. Restart the plugin.`);
95
+ }
96
+ throw failure ?? err;
97
+ }
98
+ state = await stateOf();
99
+ }
100
+ // A wedged container, a refused remove or a pull held back on a link
101
+ // that turned metered all leave the old image. Where either image cannot
102
+ // be read, a change cannot be told and is not counted: the next start
103
+ // then finds QuestDB current, or the pull's image running, and stops.
104
+ const after = state === "running" ? await runningImage() : null;
105
+ const changed = before !== null && after !== null && after !== before;
106
+ if (!changed) {
107
+ if (failure !== undefined)
108
+ throw failure;
109
+ deps.debug("image refresh deferred: QuestDB does not run the new image");
110
+ return false;
111
+ }
112
+ if (failure !== undefined && !ended()) {
113
+ deps.error(`Updating QuestDB's image failed after the container was recreated: ${message(failure)}`);
114
+ }
115
+ return true;
116
+ });
117
+ }
118
+ //# sourceMappingURL=image-refresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-refresh.js","sourceRoot":"","sources":["../src/image-refresh.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,uEAAuE;AACvE,wEAAwE;AACxE,4EAA4E;AAC5E,mCAAmC;AAEnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAiC9D,MAAM,OAAO,GAAG,CAAC,GAAY,EAAE,EAAE,CAC/B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAsB,EACtB,GAAW,EACX,MAAmB;IAEnB,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAC5B,MAAM,KAAK,GAAG,GAAG,EAAE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