@mark1russell7/harness 0.16.16 → 0.16.18
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 +60 -0
- package/build/{cell-CYOKWfwg.d.ts → cell-C8M2J7Ya.d.ts} +247 -1
- package/build/{image-BE9H5gIv.js → image-CjrmLPA7.js} +339 -4
- package/build/image-CjrmLPA7.js.map +1 -0
- package/build/index.d.ts +24 -4
- package/build/index.js +78 -7
- package/build/index.js.map +1 -1
- package/build/layers.d.ts +1 -1
- package/build/schema.d.ts +1 -1
- package/build/schema.js +1 -1
- package/image/Dockerfile +5 -4
- package/image/native/src/bin/resources.rs +187 -0
- package/package.json +2 -2
- package/build/image-BE9H5gIv.js.map +0 -1
package/build/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as targetSourceOf, B as versionsOf, C as programOf, D as subjectClient, E as sources, F as goVersions, G as requestFirst, H as environmentProblems, I as jarVersions, L as locksOf, M as unpinnedBases, N as LOCK_NAMES, O as subjectProblems, P as cargoVersions, R as npmDrift, S as planOf, T as shippedSource, U as isHopPlace, V as CLIENT_CAPABILITIES, W as latestEndOf, _ as kafkaClientImage, a as SHIPPED_NAMES, b as nodeHttpImage, c as buildRecordOf, d as harnessImage, f as harnessVersion, g as inContext, h as imageProblems, i as SHIPPED_CLIENTS, j as unlockedManifests, k as targetImageOf, l as goHttpImage, m as imageOf, n as PINNED, o as amqpClientImage, p as hikariClientImage, r as REPOSITORY, s as basesOf, t as CLIENT_NAMES, u as grpcClientImage, v as mongoClientImage, w as routerImage, x as pgClientImage, y as nodeClientImage, z as npmVersions } from "./image-
|
|
1
|
+
import { $ as hostLimitsOf, A as targetSourceOf, B as versionsOf, C as programOf, D as subjectClient, E as sources, F as goVersions, G as requestFirst, H as environmentProblems, I as jarVersions, J as cgroupKeyed, K as RESOURCES_EVENT, L as locksOf, M as unpinnedBases, N as LOCK_NAMES, O as subjectProblems, P as cargoVersions, Q as cpuStatOf, R as npmDrift, S as planOf, T as shippedSource, U as isHopPlace, V as CLIENT_CAPABILITIES, W as latestEndOf, X as cgroupNumber, Y as cgroupLimit, Z as cpuMaxOf, _ as kafkaClientImage, a as SHIPPED_NAMES, at as resourceReadingIn, b as nodeHttpImage, c as buildRecordOf, d as harnessImage, et as limitsProblems, f as harnessVersion, g as inContext, h as imageProblems, i as SHIPPED_CLIENTS, it as resourceChange, j as unlockedManifests, k as targetImageOf, l as goHttpImage, m as imageOf, n as PINNED, nt as networkOf, o as amqpClientImage, ot as resourceReadingOf, p as hikariClientImage, q as RESOURCES_PROGRAM, r as REPOSITORY, rt as resourceArgs, s as basesOf, t as CLIENT_NAMES, tt as memoryStatOf, u as grpcClientImage, v as mongoClientImage, w as routerImage, x as pgClientImage, y as nodeClientImage, z as npmVersions } from "./image-CjrmLPA7.js";
|
|
2
2
|
import { LAYERS, LAYER_FACTS, LIMITS, layerOf, limitsOf } from "./layers.js";
|
|
3
3
|
import { quantity, valueIn } from "@mark1russell7/quantity";
|
|
4
4
|
import { median, medianInterval as medianInterval$1, quantile, quantileSorted } from "@mark1russell7/rigor-statistics";
|
|
@@ -4535,6 +4535,46 @@ const writeCgroup = async (admin, id, files) => {
|
|
|
4535
4535
|
if (reads !== value) throw new Error(`${name} of the cgroup reads ${reads} after the write, not ${value}`);
|
|
4536
4536
|
}
|
|
4537
4537
|
};
|
|
4538
|
+
/** This function gives a container its limits: its CPU quota, its CPUs and its memory, with no swap (`hostLimitsOf`). */
|
|
4539
|
+
const withLimits = (container, limits) => {
|
|
4540
|
+
if (limits !== void 0) Object.assign(container.hostConfig, hostLimitsOf(limits));
|
|
4541
|
+
return container;
|
|
4542
|
+
};
|
|
4543
|
+
/** This time is how long a new reader waits for the first reading of its series, in milliseconds. */
|
|
4544
|
+
const FIRST_READING_MS = 15e3;
|
|
4545
|
+
/**
|
|
4546
|
+
* This function starts a reader of the resources of one container, by the full id of the
|
|
4547
|
+
* container. The sidecar of the reader is in the network namespace of the container `network`,
|
|
4548
|
+
* which is the same container without it. A container that shares the namespace of a holder names
|
|
4549
|
+
* that holder. With a period, the series starts before the function gives the reader.
|
|
4550
|
+
*/
|
|
4551
|
+
const resourceReader = async (id, options = {}, network = id) => {
|
|
4552
|
+
const { GenericContainer } = await containers();
|
|
4553
|
+
const dirs = cgroupDirs(id);
|
|
4554
|
+
const series = [];
|
|
4555
|
+
const events = lines((line) => {
|
|
4556
|
+
const reading = resourceReadingOf(line);
|
|
4557
|
+
if (reading !== null) series.push(reading);
|
|
4558
|
+
});
|
|
4559
|
+
const stock = withLimits(withCgroupns(new GenericContainer(await harnessImage()).withNetworkMode(`container:${network}`).withPrivilegedMode(), "host"), options.cpuset === void 0 ? void 0 : { cpuset: options.cpuset });
|
|
4560
|
+
const sidecar = await (options.period === void 0 ? stock : stock.withCommand(resourceArgs(dirs, options.period)).withLogConsumer(events.consume)).start();
|
|
4561
|
+
const stop = () => sidecar.stop(STOP).then(() => void 0).catch(() => void 0);
|
|
4562
|
+
if (options.period !== void 0) {
|
|
4563
|
+
const first = await events.until([RESOURCES_EVENT, "error"], FIRST_READING_MS, "reader of the resources").catch(async (error) => {
|
|
4564
|
+
await stop();
|
|
4565
|
+
throw error;
|
|
4566
|
+
});
|
|
4567
|
+
if (first.ev === "error") {
|
|
4568
|
+
await stop();
|
|
4569
|
+
throw new Error(`the reader of the resources of the container ${id}: ${String(first["what"])}`);
|
|
4570
|
+
}
|
|
4571
|
+
}
|
|
4572
|
+
return {
|
|
4573
|
+
series,
|
|
4574
|
+
read: async () => resourceReadingIn(await output(sidecar, resourceArgs(dirs))),
|
|
4575
|
+
stop
|
|
4576
|
+
};
|
|
4577
|
+
};
|
|
4538
4578
|
/** This container class can share the process namespace of another container. */
|
|
4539
4579
|
const shared = (Base) => class extends Base {
|
|
4540
4580
|
withPidMode(mode) {
|
|
@@ -4714,12 +4754,14 @@ const openLab = async (target, kind = "tcp", topology, setup = []) => {
|
|
|
4714
4754
|
const runtime = await getContainerRuntimeClient();
|
|
4715
4755
|
const opened = [];
|
|
4716
4756
|
const networks = [];
|
|
4757
|
+
const readers = [];
|
|
4717
4758
|
const serverLines = lines();
|
|
4718
4759
|
let restoreHost = () => Promise.resolve([]);
|
|
4719
4760
|
let fabric;
|
|
4720
4761
|
const close = async () => {
|
|
4721
4762
|
const restored = await restoreHost().then(() => null, (error) => error);
|
|
4722
4763
|
await fabric?.close();
|
|
4764
|
+
for (const reader of readers.splice(0)) await reader.stop();
|
|
4723
4765
|
for (const container of opened.reverse()) await container.stop(STOP).catch(() => void 0);
|
|
4724
4766
|
for (const network of networks.reverse()) await network.stop().catch(() => void 0);
|
|
4725
4767
|
if (restored !== null) throw restored;
|
|
@@ -4740,7 +4782,7 @@ const openLab = async (target, kind = "tcp", topology, setup = []) => {
|
|
|
4740
4782
|
for (let at = 0; at <= hops.length; at += 1) networks.push(await new Network().start());
|
|
4741
4783
|
const last = networks[hops.length];
|
|
4742
4784
|
const targetImage = await targetImageOf(target);
|
|
4743
|
-
let stock = new GenericContainer(targetImage).withNetwork(last).withWaitStrategy(Wait.forLogMessage(target.ready));
|
|
4785
|
+
let stock = withLimits(new GenericContainer(targetImage), target.limits).withNetwork(last).withWaitStrategy(Wait.forLogMessage(target.ready));
|
|
4744
4786
|
if (target.files !== void 0) stock = stock.withCopyContentToContainer(Object.entries(target.files).map(([path, content]) => ({
|
|
4745
4787
|
content,
|
|
4746
4788
|
target: path
|
|
@@ -5384,9 +5426,10 @@ const openLab = async (target, kind = "tcp", topology, setup = []) => {
|
|
|
5384
5426
|
query
|
|
5385
5427
|
]);
|
|
5386
5428
|
},
|
|
5387
|
-
async probe(args, files = [], cgroup) {
|
|
5429
|
+
async probe(args, files = [], cgroup, limits) {
|
|
5388
5430
|
const events = lines();
|
|
5389
|
-
const
|
|
5431
|
+
const own = [];
|
|
5432
|
+
const prober = withLimits(new GenericContainer(clientImage), limits).withNetworkMode(`container:${client.getId()}`).withCommand([...command, ...args]).withCopyContentToContainer(files.map((file) => ({ ...file }))).withLogConsumer(events.consume);
|
|
5390
5433
|
const container = await (capabilities === void 0 ? prober : prober.withAddedCapabilities(...capabilities)).start();
|
|
5391
5434
|
if (cgroup !== void 0) {
|
|
5392
5435
|
if (cgroupAdmin === void 0) {
|
|
@@ -5403,9 +5446,23 @@ const openLab = async (target, kind = "tcp", topology, setup = []) => {
|
|
|
5403
5446
|
freeze: () => runtime.container.getById(container.getId()).pause().then(() => void 0),
|
|
5404
5447
|
thaw: () => runtime.container.getById(container.getId()).unpause().then(() => void 0),
|
|
5405
5448
|
kill: () => runtime.container.getById(container.getId()).kill({ signal: "SIGKILL" }).then(() => void 0),
|
|
5406
|
-
|
|
5449
|
+
async resources(options) {
|
|
5450
|
+
const reader = await resourceReader(container.getId(), options, client.getId());
|
|
5451
|
+
own.push(reader);
|
|
5452
|
+
readers.push(reader);
|
|
5453
|
+
return reader;
|
|
5454
|
+
},
|
|
5455
|
+
async stop() {
|
|
5456
|
+
for (const reader of own.splice(0)) await reader.stop();
|
|
5457
|
+
await container.stop(STOP).catch(() => void 0);
|
|
5458
|
+
}
|
|
5407
5459
|
};
|
|
5408
5460
|
},
|
|
5461
|
+
async resources(options) {
|
|
5462
|
+
const reader = await resourceReader(server.getId(), options);
|
|
5463
|
+
readers.push(reader);
|
|
5464
|
+
return reader;
|
|
5465
|
+
},
|
|
5409
5466
|
async settle() {
|
|
5410
5467
|
const after = records.seen.length;
|
|
5411
5468
|
const clock = await new Promise((resolve) => {
|
|
@@ -9347,7 +9404,7 @@ const once = async (lab, cell, environment, index, dry = false) => {
|
|
|
9347
9404
|
content: load.content,
|
|
9348
9405
|
target: LOAD_PATH
|
|
9349
9406
|
}]];
|
|
9350
|
-
const probe = await lab.probe(probeArgs(cell, lab), files.length === 0 ? void 0 : files, cell.cgroup);
|
|
9407
|
+
const probe = await lab.probe(probeArgs(cell, lab), files.length === 0 ? void 0 : files, cell.cgroup, cell.clientLimits);
|
|
9351
9408
|
const server = cell.observer === "server";
|
|
9352
9409
|
const peer = server ? {
|
|
9353
9410
|
freeze: () => probe.freeze(),
|
|
@@ -9385,8 +9442,15 @@ const once = async (lab, cell, environment, index, dry = false) => {
|
|
|
9385
9442
|
let heal = null;
|
|
9386
9443
|
const signalled = !server && cell.target.program !== void 0;
|
|
9387
9444
|
let thawing = null;
|
|
9445
|
+
let reader;
|
|
9446
|
+
let start;
|
|
9447
|
+
let end;
|
|
9388
9448
|
try {
|
|
9389
9449
|
await probe.until(["ready"], 15e3);
|
|
9450
|
+
if (cell.resources !== void 0) {
|
|
9451
|
+
reader = await lab.resources(cell.resources);
|
|
9452
|
+
start = await reader.read();
|
|
9453
|
+
}
|
|
9390
9454
|
if (dry) {
|
|
9391
9455
|
if (cell.probe.mode !== "idle") await go();
|
|
9392
9456
|
await setTimeout$1(500);
|
|
@@ -9595,8 +9659,10 @@ const once = async (lab, cell, environment, index, dry = false) => {
|
|
|
9595
9659
|
await setTimeout$1(TAIL_MS);
|
|
9596
9660
|
}
|
|
9597
9661
|
}
|
|
9662
|
+
if (reader !== void 0) end = await reader.read();
|
|
9598
9663
|
} finally {
|
|
9599
9664
|
await probe.stop();
|
|
9665
|
+
await reader?.stop();
|
|
9600
9666
|
}
|
|
9601
9667
|
const settled = await lab.settle();
|
|
9602
9668
|
const lost = settled === null ? null : settled - lostBefore;
|
|
@@ -9619,6 +9685,11 @@ const once = async (lab, cell, environment, index, dry = false) => {
|
|
|
9619
9685
|
before: sessions,
|
|
9620
9686
|
after: await lab.fabric.sessions()
|
|
9621
9687
|
}
|
|
9688
|
+
} },
|
|
9689
|
+
...reader === void 0 || start === void 0 || end === void 0 ? {} : { resources: {
|
|
9690
|
+
start,
|
|
9691
|
+
end,
|
|
9692
|
+
series: [...reader.series]
|
|
9622
9693
|
} }
|
|
9623
9694
|
};
|
|
9624
9695
|
};
|
|
@@ -9904,6 +9975,6 @@ const runCell = async (cell, say = () => {}) => {
|
|
|
9904
9975
|
target = larger;
|
|
9905
9976
|
}
|
|
9906
9977
|
};
|
|
9907
|
-
export { AWS_FROM, CLIENT_CAPABILITIES, CLIENT_NAMES, CLOSED_TOLERANCE, CLOUDS, CLUSTER_STAGES, CONVERGE_MS, DAEMONS, DEBUG, DIRTY, DISK_MOUNT, DISK_RECORD_FORMAT, DISK_ROOT, DISK_SUBJECT, DROP_HANDLING, FABRIC_CLIENT, FABRIC_DEVICE, FABRIC_TARGET, FRR_IMAGE, GIVES_AWAY, HASH_SCRIPT, INJECT, INSERT, KAFKA_TAIL_MS, KEPT, LAYERS, LAYER_FACTS, LIMITS, LINGER_MS, LISTING, LOAD_FORMAT, LOAD_PATH, LOCK_NAMES, LOSS_MARGIN, MEMBER_MARKS, MONITOR_DOWN, NODE_MARKS, NOISE, PINNED, PUMP, PUMP_SLACK, QUIET_MS, RELATIVE, REPLICA_SET_STAGES, REPOSITORY, RESTART, ROUTERS, SCHEDULE_PATH, SEED_DOCUMENT, SHIPPED_CLIENTS, SHIPPED_NAMES, STAGES, STANDBY_READY, STATUS_SCRIPT, STEPS, STEP_DOWN, amqpClientImage, basesOf, bootstrapOf, brokerEnv, buildOf, buildRecordOf, callOf, cancelsOf, cargoVersions, clockOffsetOf, closeOrExit, cloudOf, clusterArgs, clusterConf, clusterCutOf, clusterHostsOf, clusterOnce, clusterStagesOf, clusterViewOf, commitProblems, commitVoid, comparable, controllerEnv, crossingsOf, cutOf, deadlineOf, delayVoids, deliveryFinding, deliveryOf, deviceOf, diskRecordProblems, diskSubjectProblems, drillOnce, drillSpan, dropFinding, dropOf, endpointAfter, envOf, environmentCounts, environmentProblems, errorsOf, estimateOf, estimateVerdict, exitOf, fieldOf, fieldsOf, firstUnanswered, folderDigest, frrConf, goHttpImage, goVersions, groupOnce, groupVerdictOf, grpcClientImage, harnessImage, harnessRecord, harnessVersion, hashOf, highestHeld, hikariClientImage, hzOf, imageOf, imagePinProblems, imageProblems, inContext, infoOf, initiateScript, isFenceLine, isHopPlace, jarVersions, jitterOf, jitterOfLines, judge, kafkaArgs, kafkaClientImage, kafkaCutOf, kafkaOnce, kafkaPauseOnce, kafkaViewOf, lagsOf, laterMove, latestEndOf, layerOf, leafLacks, leftAfter, limitsOf, loadOf, loadPlanOf, loadVerdict, locksOf, logNameOf, logTimeOf, manifestProblems, matches, measure, measureConntrack, measureDriver, measureEgress, measureGroup, measureMemory, measurePause, measurePorts, measureQueue, medianInterval, memAvailableOf, memberCommand, memberConfig, memberLineOf, mongoClientImage, monotonicAt, monotonicOf, namesGroup, nodeClientImage, nodeCommand, nodeHttpImage, nodeIdOf, nodeLineOf, nodeNameOf, nodesOnMonotonic, noiseOf, npmDrift, npmVersions, numbersOf, onMonotonic, openClusterLab, openDiskLab, openFabric, openGroupLab, openKafkaLab, openLab, openReplicaSetLab, openStandby, pairArgs, pairOnce, pairingOf, pairingsOf, pauseReady, peersOf, pgClientImage, pingsOf, plainOf, planOf, pongsOf, poolOf, programLines, programOf, quantileOf, readCpu, readHost, readOplog, reconnectFinding, reconnectOf, recordProblems, recoveryFindings, recoveryOf, referenceOf, reorderingOf, replicaSetArgs, replicaSetOnce, replicaSetStagesOf, requestOf, requestWords, restamped, roomNeeded, roomVoidOf, routeLine, routerImage, routesOf, runCell, runDiskFault, seedScript, sentinelConfig, sessionsOf, shippedClientRecord, shippedSource, sliceQuery, socketAt, socketOf, socketsOf, spread, spreadOf, stagesOf, standaloneCommand, standbyCommand, statusViewOf, stealShare, stepBand, stopScript, streamEnded, streamOf, streamsLoadOf, subjectClient, subjectProblems, subscriptionsOf, substrateHere, substrateKey, substrateOf, substrateOn, targetImageOf, targetSourceOf, templated, toolJsonOf, topicOf, topologyOf, toxicBody, unlockedManifests, unpinnedBases, unpoolable, verdictOf, versionsOf, viewOf, writesOf };
|
|
9978
|
+
export { AWS_FROM, CLIENT_CAPABILITIES, CLIENT_NAMES, CLOSED_TOLERANCE, CLOUDS, CLUSTER_STAGES, CONVERGE_MS, DAEMONS, DEBUG, DIRTY, DISK_MOUNT, DISK_RECORD_FORMAT, DISK_ROOT, DISK_SUBJECT, DROP_HANDLING, FABRIC_CLIENT, FABRIC_DEVICE, FABRIC_TARGET, FRR_IMAGE, GIVES_AWAY, HASH_SCRIPT, INJECT, INSERT, KAFKA_TAIL_MS, KEPT, LAYERS, LAYER_FACTS, LIMITS, LINGER_MS, LISTING, LOAD_FORMAT, LOAD_PATH, LOCK_NAMES, LOSS_MARGIN, MEMBER_MARKS, MONITOR_DOWN, NODE_MARKS, NOISE, PINNED, PUMP, PUMP_SLACK, QUIET_MS, RELATIVE, REPLICA_SET_STAGES, REPOSITORY, RESOURCES_EVENT, RESOURCES_PROGRAM, RESTART, ROUTERS, SCHEDULE_PATH, SEED_DOCUMENT, SHIPPED_CLIENTS, SHIPPED_NAMES, STAGES, STANDBY_READY, STATUS_SCRIPT, STEPS, STEP_DOWN, amqpClientImage, basesOf, bootstrapOf, brokerEnv, buildOf, buildRecordOf, callOf, cancelsOf, cargoVersions, cgroupKeyed, cgroupLimit, cgroupNumber, clockOffsetOf, closeOrExit, cloudOf, clusterArgs, clusterConf, clusterCutOf, clusterHostsOf, clusterOnce, clusterStagesOf, clusterViewOf, commitProblems, commitVoid, comparable, controllerEnv, cpuMaxOf, cpuStatOf, crossingsOf, cutOf, deadlineOf, delayVoids, deliveryFinding, deliveryOf, deviceOf, diskRecordProblems, diskSubjectProblems, drillOnce, drillSpan, dropFinding, dropOf, endpointAfter, envOf, environmentCounts, environmentProblems, errorsOf, estimateOf, estimateVerdict, exitOf, fieldOf, fieldsOf, firstUnanswered, folderDigest, frrConf, goHttpImage, goVersions, groupOnce, groupVerdictOf, grpcClientImage, harnessImage, harnessRecord, harnessVersion, hashOf, highestHeld, hikariClientImage, hostLimitsOf, hzOf, imageOf, imagePinProblems, imageProblems, inContext, infoOf, initiateScript, isFenceLine, isHopPlace, jarVersions, jitterOf, jitterOfLines, judge, kafkaArgs, kafkaClientImage, kafkaCutOf, kafkaOnce, kafkaPauseOnce, kafkaViewOf, lagsOf, laterMove, latestEndOf, layerOf, leafLacks, leftAfter, limitsOf, limitsProblems, loadOf, loadPlanOf, loadVerdict, locksOf, logNameOf, logTimeOf, manifestProblems, matches, measure, measureConntrack, measureDriver, measureEgress, measureGroup, measureMemory, measurePause, measurePorts, measureQueue, medianInterval, memAvailableOf, memberCommand, memberConfig, memberLineOf, memoryStatOf, mongoClientImage, monotonicAt, monotonicOf, namesGroup, networkOf, nodeClientImage, nodeCommand, nodeHttpImage, nodeIdOf, nodeLineOf, nodeNameOf, nodesOnMonotonic, noiseOf, npmDrift, npmVersions, numbersOf, onMonotonic, openClusterLab, openDiskLab, openFabric, openGroupLab, openKafkaLab, openLab, openReplicaSetLab, openStandby, pairArgs, pairOnce, pairingOf, pairingsOf, pauseReady, peersOf, pgClientImage, pingsOf, plainOf, planOf, pongsOf, poolOf, programLines, programOf, quantileOf, readCpu, readHost, readOplog, reconnectFinding, reconnectOf, recordProblems, recoveryFindings, recoveryOf, referenceOf, reorderingOf, replicaSetArgs, replicaSetOnce, replicaSetStagesOf, requestOf, requestWords, resourceArgs, resourceChange, resourceReader, resourceReadingIn, resourceReadingOf, restamped, roomNeeded, roomVoidOf, routeLine, routerImage, routesOf, runCell, runDiskFault, seedScript, sentinelConfig, sessionsOf, shippedClientRecord, shippedSource, sliceQuery, socketAt, socketOf, socketsOf, spread, spreadOf, stagesOf, standaloneCommand, standbyCommand, statusViewOf, stealShare, stepBand, stopScript, streamEnded, streamOf, streamsLoadOf, subjectClient, subjectProblems, subscriptionsOf, substrateHere, substrateKey, substrateOf, substrateOn, targetImageOf, targetSourceOf, templated, toolJsonOf, topicOf, topologyOf, toxicBody, unlockedManifests, unpinnedBases, unpoolable, verdictOf, versionsOf, viewOf, writesOf };
|
|
9908
9979
|
|
|
9909
9980
|
//# sourceMappingURL=index.js.map
|