@supacloud/admin 0.7.9 → 0.7.10
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/index.js +25 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26399,6 +26399,7 @@ async function prepareLocalUpgradeBundle(request) {
|
|
|
26399
26399
|
var REMOTE_STAGE_ROOT = "/var/lib/supacloud/upgrade-staging";
|
|
26400
26400
|
var REMOTE_RUN_ROOT = "/var/lib/supacloud/upgrade-runs";
|
|
26401
26401
|
var REMOTE_LOG_ROOT = "/var/log/supacloud";
|
|
26402
|
+
var REMOTE_UPLOAD_ROOT = "/var/tmp";
|
|
26402
26403
|
var POLL_INTERVAL_MS = 2000;
|
|
26403
26404
|
var STATE_READ_ATTEMPTS = 3;
|
|
26404
26405
|
var REMOTE_STATE_READ_TIMEOUT_MS = 15000;
|
|
@@ -26433,9 +26434,9 @@ function trustedInstalledGithubFunction() {
|
|
|
26433
26434
|
].join(`
|
|
26434
26435
|
`);
|
|
26435
26436
|
}
|
|
26436
|
-
function
|
|
26437
|
+
function buildRemoteUpgradePaths(runId) {
|
|
26437
26438
|
return {
|
|
26438
|
-
drop:
|
|
26439
|
+
drop: `${REMOTE_UPLOAD_ROOT}/.supacloud-upgrade-upload-${runId}`,
|
|
26439
26440
|
stage: `${REMOTE_STAGE_ROOT}/${runId}`,
|
|
26440
26441
|
status: `${REMOTE_RUN_ROOT}/${runId}.status`,
|
|
26441
26442
|
log: `${REMOTE_LOG_ROOT}/upgrade-${runId}.log`,
|
|
@@ -26492,9 +26493,19 @@ function requiredRemoteBytes(bundle) {
|
|
|
26492
26493
|
const transferBytes = [...bundle.files, ...bundle.verifierArchive ? [bundle.verifierArchive] : []].reduce((total, upload) => total + upload.size, 0);
|
|
26493
26494
|
return transferBytes * 3 + 512 * 1024 * 1024;
|
|
26494
26495
|
}
|
|
26496
|
+
function remoteUploadRootGate() {
|
|
26497
|
+
return [
|
|
26498
|
+
`UPLOAD_ROOT=${quoteShell2(REMOTE_UPLOAD_ROOT)}`,
|
|
26499
|
+
`test -d "$UPLOAD_ROOT" && test ! -L "$UPLOAD_ROOT" || { echo 'Remote upload root must be a directory, not a symlink' >&2; exit 1; }`,
|
|
26500
|
+
`test "$(stat -c '%u' "$UPLOAD_ROOT")" = 0 || { echo 'Remote upload root must be owned by root' >&2; exit 1; }`,
|
|
26501
|
+
`UPLOAD_ROOT_MODE=$(stat -c '%a' "$UPLOAD_ROOT")`,
|
|
26502
|
+
`case "$UPLOAD_ROOT_MODE" in [0-7]|[0-7][0-7]|[0-7][0-7][0-7]|[0-7][0-7][0-7][0-7]) ;; *) echo 'Remote upload root has invalid permission bits' >&2; exit 1 ;; esac`,
|
|
26503
|
+
"(( (8#$UPLOAD_ROOT_MODE & 01000) != 0 )) || { echo 'Remote upload root must set the sticky bit' >&2; exit 1; }",
|
|
26504
|
+
`test -w "$UPLOAD_ROOT" && test -x "$UPLOAD_ROOT" || { echo 'Remote upload root is not writable and searchable by the SSH user' >&2; exit 1; }`
|
|
26505
|
+
];
|
|
26506
|
+
}
|
|
26495
26507
|
function buildPrepareDropCommand(paths, bundle) {
|
|
26496
26508
|
const directories = [
|
|
26497
|
-
paths.drop,
|
|
26498
26509
|
`${paths.drop}/bundle`,
|
|
26499
26510
|
`${paths.drop}/bundle/management-api`,
|
|
26500
26511
|
`${paths.drop}/bundle/edge-runtime`
|
|
@@ -26505,10 +26516,12 @@ function buildPrepareDropCommand(paths, bundle) {
|
|
|
26505
26516
|
return [
|
|
26506
26517
|
"set -euo pipefail",
|
|
26507
26518
|
"umask 077",
|
|
26508
|
-
|
|
26509
|
-
|
|
26519
|
+
...remoteUploadRootGate(),
|
|
26520
|
+
`DROP=${quoteShell2(paths.drop)}`,
|
|
26521
|
+
`UPLOAD_AVAILABLE_KB=$(df -Pk "$UPLOAD_ROOT" | awk 'NR == 2 { print $4 }')`,
|
|
26510
26522
|
"VAR_AVAILABLE_KB=$(df -Pk /var/lib/supacloud | awk 'NR == 2 { print $4 }')",
|
|
26511
|
-
`test "${"$"}
|
|
26523
|
+
`test "${"$"}UPLOAD_AVAILABLE_KB" -ge ${Math.ceil(requiredBytes / 1024)} && test "${"$"}VAR_AVAILABLE_KB" -ge ${Math.ceil(requiredBytes / 1024)} || { echo 'Insufficient remote disk space for verified upgrade staging' >&2; exit 1; }`,
|
|
26524
|
+
`mkdir -m 700 -- "$DROP" || { echo 'Unable to create exclusive remote upload drop' >&2; exit 1; }`,
|
|
26512
26525
|
`install -d -m 700 ${directories.map(quoteShell2).join(" ")}`
|
|
26513
26526
|
].join(`
|
|
26514
26527
|
`);
|
|
@@ -26924,6 +26937,9 @@ function remoteEvidence(paths) {
|
|
|
26924
26937
|
function remoteReconciliationFailure(message, failures, paths) {
|
|
26925
26938
|
return new RemoteUpgradeReconciliationError(failures.map((failure) => operationError(failure, message)), `${message}; reconcile remote evidence at ${remoteEvidence(paths)}; do not retry blindly`);
|
|
26926
26939
|
}
|
|
26940
|
+
function buildUploadDropCleanupFailure(transferFailure, cleanupFailure, paths) {
|
|
26941
|
+
return remoteReconciliationFailure("Local upgrade failed and upload-drop cleanup did not complete", [transferFailure, cleanupFailure], paths);
|
|
26942
|
+
}
|
|
26927
26943
|
function failureRequiresRemoteReconciliation(error) {
|
|
26928
26944
|
return error instanceof RemoteUpgradeReconciliationError;
|
|
26929
26945
|
}
|
|
@@ -27048,7 +27064,7 @@ async function awaitRemoteUpgrade(ssh, paths) {
|
|
|
27048
27064
|
}
|
|
27049
27065
|
async function executeLocalUpgradeTransfer(ssh, request) {
|
|
27050
27066
|
const runId = randomUUID3();
|
|
27051
|
-
const paths =
|
|
27067
|
+
const paths = buildRemoteUpgradePaths(runId);
|
|
27052
27068
|
const preflight = await remoteUpgradePreflight(ssh);
|
|
27053
27069
|
const bundle = await prepareLocalUpgradeBundle({ ...preflight, ...request });
|
|
27054
27070
|
let adopted = false;
|
|
@@ -27068,7 +27084,7 @@ async function executeLocalUpgradeTransfer(ssh, request) {
|
|
|
27068
27084
|
try {
|
|
27069
27085
|
await cleanupRemoteDrop(ssh, paths);
|
|
27070
27086
|
} catch (cleanupError) {
|
|
27071
|
-
transferError =
|
|
27087
|
+
transferError = buildUploadDropCleanupFailure(transferError, cleanupError, paths);
|
|
27072
27088
|
}
|
|
27073
27089
|
}
|
|
27074
27090
|
throw transferError;
|
|
@@ -28964,7 +28980,7 @@ Actions: routes, upsert_route, update_route, delete_route, config, get_certifica
|
|
|
28964
28980
|
// package.json
|
|
28965
28981
|
var package_default = {
|
|
28966
28982
|
name: "@supacloud/admin",
|
|
28967
|
-
version: "0.7.
|
|
28983
|
+
version: "0.7.10",
|
|
28968
28984
|
description: "Platform administration CLI for SupaCloud operators",
|
|
28969
28985
|
type: "module",
|
|
28970
28986
|
main: "./dist/index.js",
|