relayrunner 0.9.0 → 0.9.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.
- package/dist/cli.js +37 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -170,7 +170,7 @@ function parse(version) {
|
|
|
170
170
|
] : null;
|
|
171
171
|
}
|
|
172
172
|
// version.ts
|
|
173
|
-
const cliVersion = "0.9.
|
|
173
|
+
const cliVersion = "0.9.1";
|
|
174
174
|
// paths.ts
|
|
175
175
|
function relayrunnerHome() {
|
|
176
176
|
return resolve(process.env.RELAYRUNNER_HOME || join(homedir(), ".relayrunner"));
|
|
@@ -1307,6 +1307,21 @@ function vmSize(slots, wanted = {}, cores = availableParallelism(), memoryBytes
|
|
|
1307
1307
|
memoryGb: wanted.memoryGb ?? Math.min(16, Math.max(2, Math.floor(gb / 2 / slots)))
|
|
1308
1308
|
};
|
|
1309
1309
|
}
|
|
1310
|
+
const NO_DNS = 3;
|
|
1311
|
+
const DNS_CHECK = `for try in 1 2 3 4 5; do
|
|
1312
|
+
RES_OPTIONS="timeout:1 attempts:1" getent ahostsv4 github.com >/dev/null && exit 0
|
|
1313
|
+
done
|
|
1314
|
+
exit ${NO_DNS}`;
|
|
1315
|
+
const DNS_FAILURE = /Temporary failure resolving|Could not resolve host|Name or service not known/;
|
|
1316
|
+
function dnsMessage(base) {
|
|
1317
|
+
return `Linux VMs on this Mac can't look up hostnames, though the Mac itself can.
|
|
1318
|
+
VPN or DNS filtering software often causes this, even when it's disconnected or its app is closed. Quit it fully, then run \`relayrunner connect\` again.
|
|
1319
|
+
|
|
1320
|
+
To check, this should print an address:
|
|
1321
|
+
container run --rm ${base} getent ahostsv4 github.com
|
|
1322
|
+
|
|
1323
|
+
To run jobs on the Mac without VMs for now, use \`relayrunner connect --no-isolated\`.`;
|
|
1324
|
+
}
|
|
1310
1325
|
async function prepareIsolation(options) {
|
|
1311
1326
|
const command = options.command ?? "container";
|
|
1312
1327
|
const log = options.log ?? (() => {});
|
|
@@ -1336,6 +1351,15 @@ async function prepareIsolation(options) {
|
|
|
1336
1351
|
]) !== 0) throw fail("ISOLATED_IMAGE", `Could not download ${base}.`);
|
|
1337
1352
|
if (!options.image) mine.push(base);
|
|
1338
1353
|
}
|
|
1354
|
+
const noDns = () => fail("ISOLATED_DNS", dnsMessage(base));
|
|
1355
|
+
if (await tool([
|
|
1356
|
+
"run",
|
|
1357
|
+
"--rm",
|
|
1358
|
+
base,
|
|
1359
|
+
"sh",
|
|
1360
|
+
"-c",
|
|
1361
|
+
DNS_CHECK
|
|
1362
|
+
]) === NO_DNS) throw noDns();
|
|
1339
1363
|
const image = jobImage(base, !options.image);
|
|
1340
1364
|
mine.push(image);
|
|
1341
1365
|
if (!await hasImage(image)) {
|
|
@@ -1344,14 +1368,16 @@ async function prepareIsolation(options) {
|
|
|
1344
1368
|
try {
|
|
1345
1369
|
writeFileSync(join(context, "Dockerfile"), dockerfile(base, !options.image));
|
|
1346
1370
|
writeFileSync(join(context, "start.sh"), START_SCRIPT);
|
|
1347
|
-
|
|
1371
|
+
const build = await capture(command, [
|
|
1348
1372
|
"build",
|
|
1349
1373
|
"--progress",
|
|
1350
1374
|
"plain",
|
|
1351
1375
|
"--tag",
|
|
1352
1376
|
image,
|
|
1353
1377
|
context
|
|
1354
|
-
]
|
|
1378
|
+
], debug);
|
|
1379
|
+
if (build.code !== 0 && DNS_FAILURE.test(build.output)) throw noDns();
|
|
1380
|
+
if (build.code !== 0) throw fail("ISOLATED_IMAGE", `Could not build the job image from ${base}.`);
|
|
1355
1381
|
} finally {
|
|
1356
1382
|
rmSync(context, {
|
|
1357
1383
|
recursive: true,
|
|
@@ -1453,7 +1479,10 @@ function isolatedLauncher(isolation) {
|
|
|
1453
1479
|
}
|
|
1454
1480
|
};
|
|
1455
1481
|
}
|
|
1456
|
-
function call(command, args, debug, quiet = false) {
|
|
1482
|
+
async function call(command, args, debug, quiet = false) {
|
|
1483
|
+
return (await capture(command, args, debug, quiet)).code;
|
|
1484
|
+
}
|
|
1485
|
+
function capture(command, args, debug, quiet = false) {
|
|
1457
1486
|
return new Promise((resolve) => {
|
|
1458
1487
|
const child = spawn(command, args, { stdio: [
|
|
1459
1488
|
"ignore",
|
|
@@ -1468,7 +1497,10 @@ function call(command, args, debug, quiet = false) {
|
|
|
1468
1497
|
child.stderr.on("data", keep);
|
|
1469
1498
|
const done = (code, extra = "") => {
|
|
1470
1499
|
debug.write(`$ ${command} ${args.join(" ")}\n${output}${extra}exit ${code}`);
|
|
1471
|
-
resolve(
|
|
1500
|
+
resolve({
|
|
1501
|
+
code,
|
|
1502
|
+
output
|
|
1503
|
+
});
|
|
1472
1504
|
};
|
|
1473
1505
|
child.once("error", (error) => done(null, `${error.message}\n`));
|
|
1474
1506
|
child.once("close", (code) => done(code));
|