@zukhruf/testing 0.8.18 → 0.8.20
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.
- package/README.md +47 -37
- package/dist/databases/collector.d.ts +23 -20
- package/dist/databases/collector.d.ts.map +1 -1
- package/dist/databases/collector.js +9 -6
- package/dist/databases/collector.js.map +1 -1
- package/dist/databases/mysql-family-collector.d.ts +1 -6
- package/dist/databases/mysql-family-collector.d.ts.map +1 -1
- package/dist/databases/mysql-family-collector.js +12 -20
- package/dist/databases/mysql-family-collector.js.map +1 -1
- package/dist/databases/mysql-family-server.d.ts.map +1 -1
- package/dist/databases/mysql-family-server.js +2 -6
- package/dist/databases/mysql-family-server.js.map +1 -1
- package/dist/databases/postgres-collector.d.ts +1 -6
- package/dist/databases/postgres-collector.d.ts.map +1 -1
- package/dist/databases/postgres-collector.js +13 -20
- package/dist/databases/postgres-collector.js.map +1 -1
- package/dist/databases/postgres.d.ts.map +1 -1
- package/dist/databases/postgres.js +2 -3
- package/dist/databases/postgres.js.map +1 -1
- package/dist/databases/sqlserver-collector.d.ts +2 -5
- package/dist/databases/sqlserver-collector.d.ts.map +1 -1
- package/dist/databases/sqlserver-collector.js +20 -37
- package/dist/databases/sqlserver-collector.js.map +1 -1
- package/dist/databases/sqlserver.d.ts +5 -2
- package/dist/databases/sqlserver.d.ts.map +1 -1
- package/dist/databases/sqlserver.js +11 -18
- package/dist/databases/sqlserver.js.map +1 -1
- package/dist/docker/reaper.d.ts +96 -0
- package/dist/docker/reaper.d.ts.map +1 -0
- package/dist/docker/reaper.js +557 -0
- package/dist/docker/reaper.js.map +1 -0
- package/dist/docker/run-records.d.ts +3 -10
- package/dist/docker/run-records.d.ts.map +1 -1
- package/dist/docker/run-records.js +3 -14
- package/dist/docker/run-records.js.map +1 -1
- package/dist/docker/testbed.d.ts +6 -7
- package/dist/docker/testbed.d.ts.map +1 -1
- package/dist/docker/testbed.js +52 -20
- package/dist/docker/testbed.js.map +1 -1
- package/dist/scripts/docker-global-setup.d.ts +6 -1
- package/dist/scripts/docker-global-setup.d.ts.map +1 -1
- package/dist/scripts/docker-global-setup.js +42 -97
- package/dist/scripts/docker-global-setup.js.map +1 -1
- package/dist/scripts/run-cleanup.d.ts +5 -13
- package/dist/scripts/run-cleanup.d.ts.map +1 -1
- package/dist/scripts/run-cleanup.js +24 -259
- package/dist/scripts/run-cleanup.js.map +1 -1
- package/package.json +3 -3
- package/dist/scripts/docker-cleanup-worker.d.ts +0 -21
- package/dist/scripts/docker-cleanup-worker.d.ts.map +0 -1
- package/dist/scripts/docker-cleanup-worker.js +0 -31
- package/dist/scripts/docker-cleanup-worker.js.map +0 -1
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import pMemoize, { pMemoizeClear } from 'p-memoize';
|
|
2
|
+
import { poll, timeout, untilAborted } from '@zukhruf/async';
|
|
3
|
+
import { ContainerNotFoundError, ContainerNotRunningError, ImageNotFoundError, IncompleteOutputError, } from '@zukhruf/docker';
|
|
4
|
+
import { KIND_LABEL, ownedNames, } from "../databases/collector.js";
|
|
5
|
+
import { mariadb, mysql } from "../databases/mysql-family-collector.js";
|
|
6
|
+
import { postgres } from "../databases/postgres-collector.js";
|
|
7
|
+
import { sqlserver } from "../databases/sqlserver-collector.js";
|
|
8
|
+
import { LEASED_SERVER_LABEL, LEASE_IMAGE, LEASE_LABEL, sweepLeaseName, } from "./engine-lease.js";
|
|
9
|
+
import { TEST_RUN_LABEL } from "./run-records.js";
|
|
10
|
+
/** An official Docker CLI image, pinned (ADR 0020, item 10). */
|
|
11
|
+
export const REAPER_IMAGE = 'docker:28.5.2-cli';
|
|
12
|
+
/** Marks the reaper of a run, with the run's id. It is not the run's label: the reaper would remove itself. */
|
|
13
|
+
export const REAPER_LABEL = 'dev.zukhruf.testing.reaper';
|
|
14
|
+
/** Marks a server that `reuse()` shares (ADR 0019). */
|
|
15
|
+
export const SERVER_LABEL = 'dev.zukhruf.testing.server';
|
|
16
|
+
/** The values of the probe and of Ryuk, and of ADR 0014 and ADR 0019. */
|
|
17
|
+
export const REAPER_DEFAULTS = {
|
|
18
|
+
grace: 2_000,
|
|
19
|
+
interval: 1_000,
|
|
20
|
+
passes: 5,
|
|
21
|
+
requestTimeout: 10_000,
|
|
22
|
+
retries: 10,
|
|
23
|
+
firstHolder: 60_000,
|
|
24
|
+
serverTtl: 7 * 24 * 60 * 60 * 1000,
|
|
25
|
+
sweepWait: 30_000,
|
|
26
|
+
sweepTries: 3,
|
|
27
|
+
leasePatience: 5_000,
|
|
28
|
+
};
|
|
29
|
+
/** The name of the reaper of the run `runId` on an engine: one reaper for each run (ADR 0020, item 7). */
|
|
30
|
+
export const reaperName = (runId) => `zukhruf-testing-reaper-${runId}`;
|
|
31
|
+
/** The collector of each kind of shared server (ADR 0011). */
|
|
32
|
+
const COLLECTORS = [postgres, mysql, mariadb, sqlserver];
|
|
33
|
+
/** The lock file of the reaper: a holder holds it shared, and the reaper closes it exclusive (ADR 0020, item 7). */
|
|
34
|
+
const DOOR = '/tmp/door';
|
|
35
|
+
/**
|
|
36
|
+
* The exec of a holder. Its answer is its first line: `held` once it holds
|
|
37
|
+
* the door shared, then its `cat` keeps the lock until the hold ends, or
|
|
38
|
+
* `closing` when the reaper closed its door.
|
|
39
|
+
*/
|
|
40
|
+
const HOLD = [
|
|
41
|
+
'sh',
|
|
42
|
+
'-c',
|
|
43
|
+
`exec 8>>${DOOR}; flock -n -s 8 || { echo closing; exit 0; }; echo held; exec cat`,
|
|
44
|
+
];
|
|
45
|
+
/** A word of `sh` in double quotes. Each `\u0000name\u0000` in `text` becomes the variable `name`. */
|
|
46
|
+
function word(text) {
|
|
47
|
+
const escaped = text.replaceAll(/[\\"$`]/g, (character) => `\\${character}`);
|
|
48
|
+
return `"${escaped.replaceAll(/\0(\w+)\0/g, (_, name) => `\${${name}}`)}"`;
|
|
49
|
+
}
|
|
50
|
+
const variable = (name) => `\0${name}\0`;
|
|
51
|
+
/** The `case` branch of a collector: lists the run's databases on the server `$1` and drops each one. */
|
|
52
|
+
function dropBranch(collector) {
|
|
53
|
+
const { variable: name, fallback } = collector.credential;
|
|
54
|
+
const run = (sql) => collector
|
|
55
|
+
.command(variable('credential'), variable(sql))
|
|
56
|
+
.map((part) => word(part))
|
|
57
|
+
.join(' ');
|
|
58
|
+
return `
|
|
59
|
+
${collector.kind})
|
|
60
|
+
credential=$(value ${name})
|
|
61
|
+
${fallback === undefined ? '' : `[ -n "$credential" ] || credential=${word(fallback)}`}
|
|
62
|
+
list=${word(collector.list)}
|
|
63
|
+
names=$(once docker exec "$1" ${run('list')}) || return 0
|
|
64
|
+
for name in $(echo "$names" | tr -d '\\r' | grep -E ${word(ownedNames(variable('hex')))}); do
|
|
65
|
+
drop=${word(collector.drop(variable('name')))}
|
|
66
|
+
once docker exec "$1" ${run('drop')} >/dev/null || return 0
|
|
67
|
+
done ;;`;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The command of the reaper. Each holder is one `cat` exec that holds the
|
|
71
|
+
* door shared. After the last holder ended, it waits the grace, and a holder
|
|
72
|
+
* that comes back stops the countdown. Then it closes the door, removes the
|
|
73
|
+
* run's containers and volumes, drops the run's databases, does the re-check
|
|
74
|
+
* passes and removes the expired shared servers, with the door closed.
|
|
75
|
+
*/
|
|
76
|
+
function script() {
|
|
77
|
+
return `
|
|
78
|
+
set -u
|
|
79
|
+
exec 9>>${DOOR}
|
|
80
|
+
filter="label=${TEST_RUN_LABEL}=$REAPER_RUN"
|
|
81
|
+
hex=$(echo "$REAPER_RUN" | tr -d -)
|
|
82
|
+
tick=0.05
|
|
83
|
+
# Milliseconds since boot. Not %d: BusyBox awk caps it at 2^31 - 1 ms, which
|
|
84
|
+
# an engine host passes after 24.8 days of uptime; the shell's arithmetic is
|
|
85
|
+
# 64-bit.
|
|
86
|
+
now() { awk '{ printf "%.0f", $1 * 1000 }' /proc/uptime; }
|
|
87
|
+
holders() { pgrep -x cat | wc -l; }
|
|
88
|
+
seconds() { awk -v ms="$1" 'BEGIN { print ms / 1000 }'; }
|
|
89
|
+
limit=$(seconds "$REAPER_REQUEST_TIMEOUT")
|
|
90
|
+
once() { timeout -s KILL "$limit" "$@"; }
|
|
91
|
+
# Tries a removal, and again REAPER_RETRIES times, one interval apart.
|
|
92
|
+
call() {
|
|
93
|
+
attempt=0
|
|
94
|
+
until once "$@"; do
|
|
95
|
+
attempt=$((attempt + 1))
|
|
96
|
+
[ "$attempt" -gt "$REAPER_RETRIES" ] && return 1
|
|
97
|
+
sleep "$(seconds "$REAPER_INTERVAL")"
|
|
98
|
+
done
|
|
99
|
+
}
|
|
100
|
+
# Waits $1 ms. Fails when a holder comes. It counts the cat processes and
|
|
101
|
+
# never tries the lock: a try would refuse a holder that comes in that moment.
|
|
102
|
+
quiet() {
|
|
103
|
+
end=$(($(now) + $1))
|
|
104
|
+
while [ "$(now)" -lt "$end" ]; do
|
|
105
|
+
[ "$(holders)" -gt 0 ] && return 1
|
|
106
|
+
sleep $tick
|
|
107
|
+
done
|
|
108
|
+
[ "$(holders)" -eq 0 ]
|
|
109
|
+
}
|
|
110
|
+
value() { echo "$env" | sed -n "s/^$1=//p" | head -n 1; }
|
|
111
|
+
|
|
112
|
+
drop_in() {
|
|
113
|
+
env=$(once docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' "$1") || return 0
|
|
114
|
+
case $2 in${COLLECTORS.map((collector) => dropBranch(collector)).join('')}
|
|
115
|
+
esac
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
pass() {
|
|
119
|
+
listed=$(call docker ps -a --no-trunc --filter "$filter" --format '{{.ID}} {{.Label "${SERVER_LABEL}"}}') || return 1
|
|
120
|
+
ids=$(echo "$listed" | awk 'NF == 1 { print $1 }')
|
|
121
|
+
[ -z "$ids" ] || call docker rm -f -v $ids >/dev/null || return 1
|
|
122
|
+
volumes=$(call docker volume ls -q --filter "$filter") || return 1
|
|
123
|
+
[ -z "$volumes" ] || call docker volume rm -f $volumes >/dev/null || return 1
|
|
124
|
+
servers=$(once docker ps --no-trunc --filter "label=${SERVER_LABEL}" --filter "label=${KIND_LABEL}" --format '{{.ID}} {{.Label "${KIND_LABEL}"}}') || return 0
|
|
125
|
+
echo "$servers" | while read -r id kind; do
|
|
126
|
+
[ -n "$id" ] && drop_in "$id" "$kind"
|
|
127
|
+
done
|
|
128
|
+
return 0
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# Resolves when the lease $1 is gone, as EngineLease.gone does; fails at $deadline.
|
|
132
|
+
gone() {
|
|
133
|
+
seen=
|
|
134
|
+
while :; do
|
|
135
|
+
state=$(once docker inspect -f '{{.State.Status}}' "$1" 2>/dev/null) || return 0
|
|
136
|
+
case $state in exited|dead) once docker rm "$1" >/dev/null 2>&1; return 0 ;; esac
|
|
137
|
+
if [ "$seen" = created ] && [ "$state" = created ]; then
|
|
138
|
+
once docker rm "$1" >/dev/null 2>&1
|
|
139
|
+
return 0
|
|
140
|
+
fi
|
|
141
|
+
seen=$state
|
|
142
|
+
patience=$(($(now) + REAPER_LEASE_PATIENCE))
|
|
143
|
+
while [ "$(now)" -lt "$patience" ]; do
|
|
144
|
+
[ "$(now)" -ge "$deadline" ] && return 1
|
|
145
|
+
once docker inspect "$1" >/dev/null 2>&1 || return 0
|
|
146
|
+
sleep $tick
|
|
147
|
+
done
|
|
148
|
+
done
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
# Takes the sweep lease of the fingerprint $1: a cat that ends with this reaper.
|
|
152
|
+
lease() {
|
|
153
|
+
name="${sweepLeaseName('$1')}"
|
|
154
|
+
fifo=/tmp/lease-$1
|
|
155
|
+
deadline=$(($(now) + REAPER_SWEEP_WAIT))
|
|
156
|
+
tries=0
|
|
157
|
+
while [ "$tries" -lt "$REAPER_SWEEP_TRIES" ]; do
|
|
158
|
+
tries=$((tries + 1))
|
|
159
|
+
rm -f "$fifo" "$fifo.id" "$fifo.err"
|
|
160
|
+
mkfifo "$fifo"
|
|
161
|
+
docker run -i --rm --name "$name" --cidfile "$fifo.id" --label "${LEASE_LABEL}=sweep" --label "${LEASED_SERVER_LABEL}=$1" --entrypoint cat ${LEASE_IMAGE} < "$fifo" > /dev/null 2> "$fifo.err" &
|
|
162
|
+
job=$!
|
|
163
|
+
exec 9> "$fifo"
|
|
164
|
+
started=$(($(now) + REAPER_REQUEST_TIMEOUT))
|
|
165
|
+
while kill -0 "$job" 2>/dev/null && [ "$(now)" -lt "$started" ]; do
|
|
166
|
+
[ -s "$fifo.id" ] && [ "$(once docker inspect -f '{{.State.Status}}' "$(head -n 1 "$fifo.id")" 2>/dev/null)" = running ] && return 0
|
|
167
|
+
sleep $tick
|
|
168
|
+
done
|
|
169
|
+
exec 9>&-
|
|
170
|
+
wait "$job"
|
|
171
|
+
grep -q Conflict "$fifo.err" || return 1
|
|
172
|
+
gone "$name" || return 1
|
|
173
|
+
done
|
|
174
|
+
return 1
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
sweep() {
|
|
178
|
+
lease "$2" || return 0
|
|
179
|
+
if held=$(once docker ps -q --filter "label=${LEASE_LABEL}=process" --filter "label=${LEASED_SERVER_LABEL}=$2") && [ -z "$held" ]; then
|
|
180
|
+
once docker rm -f -v "$1" >/dev/null 2>&1
|
|
181
|
+
fi
|
|
182
|
+
exec 9>&-
|
|
183
|
+
wait "$job"
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
expire() {
|
|
187
|
+
servers=$(once docker ps -a --no-trunc --filter "label=${SERVER_LABEL}" --format '{{.ID}} {{.Label "${SERVER_LABEL}"}}') || return 0
|
|
188
|
+
echo "$servers" | while read -r id fingerprint; do
|
|
189
|
+
[ -n "$fingerprint" ] || continue
|
|
190
|
+
created=$(once docker inspect -f '{{.Created}}' "$id") || continue
|
|
191
|
+
created=\${created%%.*}
|
|
192
|
+
born=$(date -u -D '%Y-%m-%dT%H:%M:%S' -d "\${created%Z}" +%s) || continue
|
|
193
|
+
[ $((($(date -u +%s) - born) * 1000)) -gt "$REAPER_SERVER_TTL" ] || continue
|
|
194
|
+
sweep "$id" "$fingerprint"
|
|
195
|
+
done
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
# Starts each reaper of another run that stayed created for longer than its
|
|
199
|
+
# creator's start window: one inspect and one start, each within the request
|
|
200
|
+
# time limit in that reaper's own environment (ADR 0020, item 13). A reaper
|
|
201
|
+
# that is not created is never touched.
|
|
202
|
+
revive() {
|
|
203
|
+
stale=$(once docker ps -aq --no-trunc --filter "label=${REAPER_LABEL}" --filter status=created) || return 0
|
|
204
|
+
for id in $stale; do
|
|
205
|
+
env=$(once docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' "$id") || continue
|
|
206
|
+
[ "$(value REAPER_RUN)" != "$REAPER_RUN" ] || continue
|
|
207
|
+
window=$(value REAPER_REQUEST_TIMEOUT)
|
|
208
|
+
[ -n "$window" ] || continue
|
|
209
|
+
created=$(once docker inspect -f '{{.Created}}' "$id") || continue
|
|
210
|
+
created=\${created%%.*}
|
|
211
|
+
born=$(date -u -D '%Y-%m-%dT%H:%M:%S' -d "\${created%Z}" +%s) || continue
|
|
212
|
+
# Whole seconds: the age is at most 1 s more than it reads.
|
|
213
|
+
[ $((($(date -u +%s) - born - 1) * 1000)) -gt $((2 * window)) ] || continue
|
|
214
|
+
once docker start "$id" >/dev/null 2>&1
|
|
215
|
+
done
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
first=$(($(now) + REAPER_FIRST_HOLDER))
|
|
219
|
+
until [ "$(holders)" -gt 0 ] || [ "$(now)" -ge "$first" ]; do sleep $tick; done
|
|
220
|
+
while :; do
|
|
221
|
+
while [ "$(holders)" -gt 0 ]; do sleep $tick; done
|
|
222
|
+
quiet "$REAPER_GRACE" || continue
|
|
223
|
+
# Closes the door: it fails when a holder came, and then the reaper waits
|
|
224
|
+
# again. The lock stays until the exit, so a holder that comes later is
|
|
225
|
+
# refused and holds the next reaper of the run.
|
|
226
|
+
flock -n -x 9 || continue
|
|
227
|
+
pass
|
|
228
|
+
checked=0
|
|
229
|
+
while [ "$checked" -lt "$REAPER_PASSES" ]; do
|
|
230
|
+
sleep "$(seconds "$REAPER_INTERVAL")"
|
|
231
|
+
checked=$((checked + 1))
|
|
232
|
+
pass
|
|
233
|
+
done
|
|
234
|
+
expire
|
|
235
|
+
revive
|
|
236
|
+
exit 0
|
|
237
|
+
done
|
|
238
|
+
`;
|
|
239
|
+
}
|
|
240
|
+
/** The body of the reaper of the run `runId`, with its inputs in its environment. */
|
|
241
|
+
export function reaperRequest(runId, settings) {
|
|
242
|
+
return {
|
|
243
|
+
Image: REAPER_IMAGE,
|
|
244
|
+
Entrypoint: ['sh', '-c', script()],
|
|
245
|
+
Cmd: [],
|
|
246
|
+
Env: [
|
|
247
|
+
`REAPER_RUN=${runId}`,
|
|
248
|
+
`REAPER_GRACE=${settings.grace}`,
|
|
249
|
+
`REAPER_INTERVAL=${settings.interval}`,
|
|
250
|
+
`REAPER_PASSES=${settings.passes}`,
|
|
251
|
+
`REAPER_REQUEST_TIMEOUT=${settings.requestTimeout}`,
|
|
252
|
+
`REAPER_RETRIES=${settings.retries}`,
|
|
253
|
+
`REAPER_FIRST_HOLDER=${settings.firstHolder}`,
|
|
254
|
+
`REAPER_SERVER_TTL=${settings.serverTtl}`,
|
|
255
|
+
`REAPER_SWEEP_WAIT=${settings.sweepWait}`,
|
|
256
|
+
`REAPER_SWEEP_TRIES=${settings.sweepTries}`,
|
|
257
|
+
`REAPER_LEASE_PATIENCE=${settings.leasePatience}`,
|
|
258
|
+
],
|
|
259
|
+
Labels: { [REAPER_LABEL]: runId },
|
|
260
|
+
HostConfig: {
|
|
261
|
+
AutoRemove: true,
|
|
262
|
+
Binds: ['/var/run/docker.sock:/var/run/docker.sock'],
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* The longest that a reaper can run after it closed its door: its first pass
|
|
268
|
+
* and its re-check passes, `interval` apart, its expiry pass with one sweep,
|
|
269
|
+
* and the start of one reaper left `created`. A pass makes four removals (the list and the removal of the
|
|
270
|
+
* containers, then of the volumes), each with its first try and `retries`
|
|
271
|
+
* more, `interval` apart and each within `requestTimeout`, and one list of the
|
|
272
|
+
* shared servers. The expiry pass lists the servers and, for one expired
|
|
273
|
+
* server, inspects it, waits `sweepWait` at most for its sweep lease, lists
|
|
274
|
+
* its process leases and removes it. The start of a reaper left `created`
|
|
275
|
+
* lists them, inspects one twice and starts it. Each database to drop, each
|
|
276
|
+
* other expired server and each other reaper to start adds to this, so a hold
|
|
277
|
+
* that waits longer fails.
|
|
278
|
+
*/
|
|
279
|
+
export function closingTime(settings) {
|
|
280
|
+
const { requestTimeout, retries, interval, passes, sweepWait } = settings;
|
|
281
|
+
const removal = (retries + 1) * requestTimeout + retries * interval;
|
|
282
|
+
const pass = 4 * removal + requestTimeout;
|
|
283
|
+
const expiry = 4 * requestTimeout + sweepWait;
|
|
284
|
+
const revival = 4 * requestTimeout;
|
|
285
|
+
return (passes + 1) * pass + passes * interval + expiry + revival;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Resolves when the engine removed `reaper`, which closed its door. Its waits
|
|
289
|
+
* keep no process running. Fails after the closing time of the reaper.
|
|
290
|
+
*/
|
|
291
|
+
async function closed(docker, reaper, settings, clock) {
|
|
292
|
+
const ms = closingTime(settings);
|
|
293
|
+
const removed = await poll(async () => (await docker.containers.find(reaper.id)) === undefined
|
|
294
|
+
? true
|
|
295
|
+
: undefined, {
|
|
296
|
+
interval: settings.interval,
|
|
297
|
+
signal: undefined,
|
|
298
|
+
clock,
|
|
299
|
+
deadline: clock.performance.now() + ms,
|
|
300
|
+
ref: false,
|
|
301
|
+
});
|
|
302
|
+
if (removed === undefined)
|
|
303
|
+
throw new Error(`The reaper ${reaper.id} closed and was not removed within ${ms} ms`);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The reaper of `runId`, created when it does not exist, and started when it
|
|
307
|
+
* did not start. Gives undefined once a reaper that ends is gone: a later call
|
|
308
|
+
* gets a new one. A missing image is pulled. A reaper that ended and stays,
|
|
309
|
+
* for example one whose removal by the engine failed, is removed here: nobody
|
|
310
|
+
* else removes it.
|
|
311
|
+
*/
|
|
312
|
+
async function running(docker, runId, settings, clock) {
|
|
313
|
+
const request = reaperRequest(runId, settings);
|
|
314
|
+
const name = reaperName(runId);
|
|
315
|
+
let reaper;
|
|
316
|
+
try {
|
|
317
|
+
({ container: reaper } = await docker.containers.createOrGet(request, {
|
|
318
|
+
name,
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
if (!(error instanceof ImageNotFoundError))
|
|
323
|
+
throw error;
|
|
324
|
+
await docker.images.pull(error.image);
|
|
325
|
+
({ container: reaper } = await docker.containers.createOrGet(request, {
|
|
326
|
+
name,
|
|
327
|
+
}));
|
|
328
|
+
}
|
|
329
|
+
let state;
|
|
330
|
+
try {
|
|
331
|
+
state = (await reaper.inspect()).State?.Status;
|
|
332
|
+
if (state === 'created') {
|
|
333
|
+
await reaper.start();
|
|
334
|
+
state = 'running';
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
if (error instanceof ContainerNotFoundError)
|
|
339
|
+
return undefined;
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
if (state === 'running')
|
|
343
|
+
return reaper;
|
|
344
|
+
if (state === 'exited' || state === 'dead')
|
|
345
|
+
await reaper.remove({ force: true });
|
|
346
|
+
else
|
|
347
|
+
await closed(docker, reaper, settings, clock);
|
|
348
|
+
return undefined;
|
|
349
|
+
}
|
|
350
|
+
/** The codes of a connection to the engine that ended under a read: a dead peer. */
|
|
351
|
+
const CONNECTION_ENDS = new Set(['ETIMEDOUT', 'EPIPE']);
|
|
352
|
+
/** True for an error that ends the output of an exec when its connection ends. */
|
|
353
|
+
const connectionEnded = (error) => error instanceof IncompleteOutputError ||
|
|
354
|
+
(Error.isError(error) &&
|
|
355
|
+
'code' in error &&
|
|
356
|
+
typeof error.code === 'string' &&
|
|
357
|
+
CONNECTION_ENDS.has(error.code));
|
|
358
|
+
/** The first line of the standard output, or undefined when the output ended first. */
|
|
359
|
+
async function firstLine(output) {
|
|
360
|
+
const decoder = new TextDecoder();
|
|
361
|
+
let text = '';
|
|
362
|
+
try {
|
|
363
|
+
for (;;) {
|
|
364
|
+
const chunk = await output.next();
|
|
365
|
+
if (chunk.done === true)
|
|
366
|
+
return undefined;
|
|
367
|
+
if (chunk.value.stream !== 'stdout')
|
|
368
|
+
continue;
|
|
369
|
+
text += decoder.decode(chunk.value.data, { stream: true });
|
|
370
|
+
const end = text.indexOf('\n');
|
|
371
|
+
if (end !== -1)
|
|
372
|
+
return text.slice(0, end);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
catch (error) {
|
|
376
|
+
if (connectionEnded(error))
|
|
377
|
+
return undefined;
|
|
378
|
+
throw error;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/** Resolves when the output ends, also when its connection ends. */
|
|
382
|
+
async function drained(output) {
|
|
383
|
+
try {
|
|
384
|
+
while ((await output.next()).done !== true)
|
|
385
|
+
;
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
if (!connectionEnded(error))
|
|
389
|
+
throw error;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* The hold of this process on the reaper of its run: one `cat` exec with
|
|
394
|
+
* `ref: false` that holds the door of the reaper (ADR 0020, item 7). It ends
|
|
395
|
+
* when this process exits, for any reason. When it ends while this process
|
|
396
|
+
* lives, it is taken again at once: on the same reaper, or on the next one
|
|
397
|
+
* when that reaper closed.
|
|
398
|
+
*/
|
|
399
|
+
export class ReaperHold {
|
|
400
|
+
#docker;
|
|
401
|
+
#runId;
|
|
402
|
+
#settings;
|
|
403
|
+
#clock;
|
|
404
|
+
constructor(docker, runId, settings, clock) {
|
|
405
|
+
this.#docker = docker;
|
|
406
|
+
this.#runId = runId;
|
|
407
|
+
this.#settings = settings;
|
|
408
|
+
this.#clock = clock;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Holds the reaper of `runId`, and creates it when the run has none on this
|
|
412
|
+
* engine. A reaper that closed is waited for until the engine removed it,
|
|
413
|
+
* and one that ends while the hold starts is tried again: at most
|
|
414
|
+
* `settings.retries` more times.
|
|
415
|
+
*/
|
|
416
|
+
static async take(docker, runId, settings, clock) {
|
|
417
|
+
const hold = new ReaperHold(docker, runId, settings, clock);
|
|
418
|
+
await hold.held();
|
|
419
|
+
return hold;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Resolves when this process holds the reaper: at once while the hold
|
|
423
|
+
* lasts, and after the new hold when it ended. A hold that failed is tried
|
|
424
|
+
* again by the next call.
|
|
425
|
+
*/
|
|
426
|
+
async held() {
|
|
427
|
+
// The waits of a hold keep no process running, as its exec does not. A
|
|
428
|
+
// caller that waits for the hold keeps this process running while it
|
|
429
|
+
// waits, as the request that it waits to make would, for at most each
|
|
430
|
+
// try of the hold: one exec and the closing time of a reaper.
|
|
431
|
+
const ms = (this.#settings.retries + 1) *
|
|
432
|
+
(this.#settings.requestTimeout + closingTime(this.#settings));
|
|
433
|
+
using alive = timeout(ms, { clock: this.#clock });
|
|
434
|
+
try {
|
|
435
|
+
await untilAborted(this.#hold(), alive.signal);
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
if (!alive.signal.aborted)
|
|
439
|
+
throw error;
|
|
440
|
+
throw new Error(`The hold of the reaper ${reaperName(this.#runId)} did not end within ${ms} ms`, { cause: error });
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/** The hold, once at a time: it is cleared when the hold ends, and a failed one is not kept. */
|
|
444
|
+
#hold = pMemoize(async () => {
|
|
445
|
+
const { retries } = this.#settings;
|
|
446
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
447
|
+
const reaper = await running(this.#docker, this.#runId, this.#settings, this.#clock);
|
|
448
|
+
if (reaper === undefined)
|
|
449
|
+
continue;
|
|
450
|
+
const answer = await this.#ask(reaper);
|
|
451
|
+
if (answer === 'held')
|
|
452
|
+
return;
|
|
453
|
+
if (answer === 'closing')
|
|
454
|
+
await closed(this.#docker, reaper, this.#settings, this.#clock);
|
|
455
|
+
}
|
|
456
|
+
throw new Error(`The reaper ${reaperName(this.#runId)} ended or closed on each of ${retries + 1} tries to hold it`);
|
|
457
|
+
});
|
|
458
|
+
/** Asks `reaper` for a hold, and gives its answer. A hold that it gives is watched. */
|
|
459
|
+
async #ask(reaper) {
|
|
460
|
+
let holder;
|
|
461
|
+
try {
|
|
462
|
+
holder = await reaper.spawn({ Cmd: HOLD }, { stdin: true, ref: false });
|
|
463
|
+
}
|
|
464
|
+
catch (error) {
|
|
465
|
+
// The reaper ended between the inspect and the exec.
|
|
466
|
+
if (error instanceof ContainerNotRunningError ||
|
|
467
|
+
error instanceof ContainerNotFoundError)
|
|
468
|
+
return undefined;
|
|
469
|
+
throw error;
|
|
470
|
+
}
|
|
471
|
+
const output = holder[Symbol.asyncIterator]();
|
|
472
|
+
const answer = await firstLine(output);
|
|
473
|
+
if (answer === 'held')
|
|
474
|
+
void this.#watch(output);
|
|
475
|
+
return answer;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Takes the hold again at once when its output ends while this process
|
|
479
|
+
* lives. A failure of that hold is not kept: the next held() tries again.
|
|
480
|
+
*/
|
|
481
|
+
async #watch(output) {
|
|
482
|
+
await drained(output);
|
|
483
|
+
pMemoizeClear(this.#hold);
|
|
484
|
+
await this.#hold().catch(() => { });
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Starts the reaper of the dead run `runId` with no wait for a first holder,
|
|
489
|
+
* and does not wait for it (ADR 0020, item 9). A reaper of the run that still
|
|
490
|
+
* runs keeps the run. One that ended is replaced, at most `settings.retries`
|
|
491
|
+
* more times.
|
|
492
|
+
*/
|
|
493
|
+
export async function startReaper(docker, runId, settings = REAPER_DEFAULTS) {
|
|
494
|
+
const immediate = { ...settings, firstHolder: 0 };
|
|
495
|
+
for (let attempt = 0; attempt <= settings.retries; attempt++)
|
|
496
|
+
if ((await running(docker, runId, immediate, globalThis)) !== undefined)
|
|
497
|
+
return;
|
|
498
|
+
throw new Error(`The reaper ${reaperName(runId)} ended on each of ${settings.retries + 1} tries to start it`);
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* The names that start with `test` in each running shared server: the
|
|
502
|
+
* superset of a run's databases that the reaper's pass filters (ADR 0011,
|
|
503
|
+
* item 4). A server that does not run, or does not answer its list within
|
|
504
|
+
* `settings.requestTimeout`, counts as one with none (ADR 0011, item 6).
|
|
505
|
+
*/
|
|
506
|
+
export async function sharedDatabases(docker, settings, clock) {
|
|
507
|
+
const names = [];
|
|
508
|
+
for (const { Id, Labels } of await docker.containers.list({
|
|
509
|
+
filters: { label: [SERVER_LABEL, KIND_LABEL] },
|
|
510
|
+
})) {
|
|
511
|
+
const collector = COLLECTORS.find(({ kind }) => kind === Labels?.[KIND_LABEL]);
|
|
512
|
+
const server = await docker.containers.find(Id);
|
|
513
|
+
if (collector === undefined || server === undefined)
|
|
514
|
+
continue;
|
|
515
|
+
const { variable, fallback } = collector.credential;
|
|
516
|
+
const credential = (await server.inspect()).Config?.Env?.find((entry) => entry.startsWith(`${variable}=`))?.slice(variable.length + 1) || fallback;
|
|
517
|
+
if (credential === undefined)
|
|
518
|
+
continue;
|
|
519
|
+
using limit = timeout(settings.requestTimeout, { clock });
|
|
520
|
+
let listed;
|
|
521
|
+
try {
|
|
522
|
+
listed = await server.exec({ Cmd: collector.command(credential, collector.list) }, { signal: limit.signal });
|
|
523
|
+
}
|
|
524
|
+
catch (error) {
|
|
525
|
+
if (limit.signal.aborted ||
|
|
526
|
+
error instanceof ContainerNotRunningError ||
|
|
527
|
+
error instanceof ContainerNotFoundError)
|
|
528
|
+
continue;
|
|
529
|
+
throw error;
|
|
530
|
+
}
|
|
531
|
+
if (listed.exitCode !== 0)
|
|
532
|
+
continue;
|
|
533
|
+
names.push(...listed.stdout
|
|
534
|
+
.split('\n')
|
|
535
|
+
.map((line) => line.trim())
|
|
536
|
+
.filter(Boolean));
|
|
537
|
+
}
|
|
538
|
+
return names;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Whether the engine holds nothing of the run `runId`: no reaper of it, and
|
|
542
|
+
* nothing that one would remove, its containers but its shared servers, its
|
|
543
|
+
* volumes, and its databases among `databases` (ADR 0020, item 9).
|
|
544
|
+
*/
|
|
545
|
+
export async function reaped(docker, runId, databases) {
|
|
546
|
+
if ((await docker.containers.find(reaperName(runId))) !== undefined)
|
|
547
|
+
return false;
|
|
548
|
+
const filters = { label: [`${TEST_RUN_LABEL}=${runId}`] };
|
|
549
|
+
const containers = await docker.containers.list({ all: true, filters });
|
|
550
|
+
if (containers.some(({ Labels }) => Labels?.[SERVER_LABEL] === undefined))
|
|
551
|
+
return false;
|
|
552
|
+
if ((await docker.volumes.list({ filters })).length > 0)
|
|
553
|
+
return false;
|
|
554
|
+
const owned = new RegExp(ownedNames(runId.replaceAll('-', '')));
|
|
555
|
+
return !(await databases()).some((name) => owned.test(name));
|
|
556
|
+
}
|
|
557
|
+
//# sourceMappingURL=reaper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reaper.js","sourceRoot":"","sources":["../../src/docker/reaper.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,EAAE,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAc,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAEL,sBAAsB,EACtB,wBAAwB,EAGxB,kBAAkB,EAClB,qBAAqB,GAEtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,UAAU,EACV,UAAU,GACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO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S;QACjE,OAAO,KAAK,CAAC;IACf,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,cAAc,IAAI,KAAK,EAAE,CAAC,EAAE,CAAC;IAC1D,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACxE,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,KAAK,SAAS,CAAC;QACvE,OAAO,KAAK,CAAC;IACf,IAAI,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACtE,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAChE,OAAO,CAAC,CAAC,MAAM,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -6,9 +6,9 @@ export declare const TEST_RUN_DIRECTORY = "ZUKHRUF_TESTING_RUN_DIR";
|
|
|
6
6
|
export declare const TEST_RUN_LABEL = "dev.zukhruf.testing.run";
|
|
7
7
|
/**
|
|
8
8
|
* The records of one `node --test` invocation with the Docker global setup,
|
|
9
|
-
* in the run's directory. While a recorded process lives,
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* in the run's directory. While a recorded process lives, the global
|
|
10
|
+
* teardown keeps the run, and the recovery of a later run removes the
|
|
11
|
+
* recorded paths that a killed process left.
|
|
12
12
|
*/
|
|
13
13
|
export declare class RunRecords {
|
|
14
14
|
readonly directory: string;
|
|
@@ -26,13 +26,6 @@ export declare class RunRecords {
|
|
|
26
26
|
* another Docker client.
|
|
27
27
|
*/
|
|
28
28
|
recordThisProcess(): void;
|
|
29
|
-
/**
|
|
30
|
-
* Writes a creating record while this process asks the engine to create a
|
|
31
|
-
* container. The engine can finish a create after the process that sent it
|
|
32
|
-
* died. While a creating record remains, the global teardown keeps the
|
|
33
|
-
* run's records, and the recovery of a later run sweeps the run again.
|
|
34
|
-
*/
|
|
35
|
-
recordCreating(): Promise<AsyncDisposable>;
|
|
36
29
|
/**
|
|
37
30
|
* Records a path that the global teardown removes if this process dies first.
|
|
38
31
|
* Disposing the record forgets the path once the process removed it itself.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-records.d.ts","sourceRoot":"","sources":["../../src/docker/run-records.ts"],"names":[],"mappings":"AAKA,0EAA0E;AAC1E,eAAO,MAAM,WAAW,2BAA2B,CAAC;AACpD,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,4BAA4B,CAAC;AAC5D,4EAA4E;AAC5E,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAKxD;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,SAAS,EAAE,MAAM;IAI7B;;;;;OAKG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAM1D;;;;OAIG;IACH,iBAAiB,IAAI,IAAI;IASzB
|
|
1
|
+
{"version":3,"file":"run-records.d.ts","sourceRoot":"","sources":["../../src/docker/run-records.ts"],"names":[],"mappings":"AAKA,0EAA0E;AAC1E,eAAO,MAAM,WAAW,2BAA2B,CAAC;AACpD,+EAA+E;AAC/E,eAAO,MAAM,kBAAkB,4BAA4B,CAAC;AAC5D,4EAA4E;AAC5E,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAKxD;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,SAAS,EAAE,MAAM;IAI7B;;;;;OAKG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAM1D;;;;OAIG;IACH,iBAAiB,IAAI,IAAI;IASzB;;;OAGG;IACG,MAAM,CACV,IAAI,EAAE,SAAS,GAAG,WAAW,EAC7B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,CAAC;CAK5B;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,OAAO,CACrB,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GACxD,UAAU,GAAG,SAAS,CASxB;AAED,6EAA6E;AAC7E,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,GAAG,SAAS,KAAG,MACf,CAAC;AAE3C,2EAA2E;AAC3E,eAAO,MAAM,aAAa,GAAI,IAAI,MAAM,GAAG,SAAS,KAAG,MACA,CAAC"}
|
|
@@ -12,9 +12,9 @@ export const TEST_RUN_LABEL = 'dev.zukhruf.testing.run';
|
|
|
12
12
|
const recordedRuns = new Set();
|
|
13
13
|
/**
|
|
14
14
|
* The records of one `node --test` invocation with the Docker global setup,
|
|
15
|
-
* in the run's directory. While a recorded process lives,
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* in the run's directory. While a recorded process lives, the global
|
|
16
|
+
* teardown keeps the run, and the recovery of a later run removes the
|
|
17
|
+
* recorded paths that a killed process left.
|
|
18
18
|
*/
|
|
19
19
|
export class RunRecords {
|
|
20
20
|
directory;
|
|
@@ -43,17 +43,6 @@ export class RunRecords {
|
|
|
43
43
|
writeFileSync(join(this.directory, `process-${process.pid}-${randomUUID()}.json`), JSON.stringify({ pid: process.pid }));
|
|
44
44
|
recordedRuns.add(this.directory);
|
|
45
45
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Writes a creating record while this process asks the engine to create a
|
|
48
|
-
* container. The engine can finish a create after the process that sent it
|
|
49
|
-
* died. While a creating record remains, the global teardown keeps the
|
|
50
|
-
* run's records, and the recovery of a later run sweeps the run again.
|
|
51
|
-
*/
|
|
52
|
-
async recordCreating() {
|
|
53
|
-
const file = join(this.directory, `creating-${randomUUID()}.json`);
|
|
54
|
-
await writeFile(file, JSON.stringify({ pid: process.pid }));
|
|
55
|
-
return { [Symbol.asyncDispose]: () => rm(file, { force: true }) };
|
|
56
|
-
}
|
|
57
46
|
/**
|
|
58
47
|
* Records a path that the global teardown removes if this process dies first.
|
|
59
48
|
* Disposing the record forgets the path once the process removed it itself.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-records.js","sourceRoot":"","sources":["../../src/docker/run-records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAwB,CAAC;AACpD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC;AAC5D,4EAA4E;AAC5E,MAAM,CAAC,MAAM,cAAc,GAAG,yBAAyB,CAAC;AAExD,sEAAsE;AACtE,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACZ,SAAS,CAAS;IAE3B,YAAY,SAAiB;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,aAAa,CAAC,GAAW;QAC7B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