ardent-cli 0.0.20 → 0.0.22
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 +75 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -307,6 +307,19 @@ function isPermissionError(err) {
|
|
|
307
307
|
}
|
|
308
308
|
return false;
|
|
309
309
|
}
|
|
310
|
+
var API_ERROR_PREFIX = /^api error \d{3}:/;
|
|
311
|
+
function isGatewayTimeoutError(err) {
|
|
312
|
+
if (err instanceof Error) {
|
|
313
|
+
const msg = err.message.toLowerCase();
|
|
314
|
+
if (msg.includes("api error 502") || msg.includes("api error 503") || msg.includes("api error 504")) {
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
if (API_ERROR_PREFIX.test(msg)) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return isNetworkError(err);
|
|
322
|
+
}
|
|
310
323
|
|
|
311
324
|
// src/lib/telemetry.ts
|
|
312
325
|
import { randomUUID } from "crypto";
|
|
@@ -729,6 +742,52 @@ Example:
|
|
|
729
742
|
}
|
|
730
743
|
|
|
731
744
|
// src/commands/connector/create.ts
|
|
745
|
+
var EngineSetupTimeoutError = class extends Error {
|
|
746
|
+
constructor(message) {
|
|
747
|
+
super(message);
|
|
748
|
+
this.name = "EngineSetupTimeoutError";
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
async function runEngineSetupWithPolling(connectorId) {
|
|
752
|
+
try {
|
|
753
|
+
await api.post(`/v1/connectors/${connectorId}/engine-setup`, {});
|
|
754
|
+
return;
|
|
755
|
+
} catch (err) {
|
|
756
|
+
if (!isGatewayTimeoutError(err)) {
|
|
757
|
+
throw err;
|
|
758
|
+
}
|
|
759
|
+
console.log(
|
|
760
|
+
" Backend engine setup is long-running; the gateway dropped the request but the work continues server-side. Polling for completion..."
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
const startedAt = Date.now();
|
|
764
|
+
const maxWaitMs = 20 * 60 * 1e3;
|
|
765
|
+
const pollIntervalMs = 30 * 1e3;
|
|
766
|
+
while (Date.now() - startedAt < maxWaitMs) {
|
|
767
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
768
|
+
let status;
|
|
769
|
+
try {
|
|
770
|
+
status = await api.get(`/v1/connectors/${connectorId}`);
|
|
771
|
+
} catch (pollErr) {
|
|
772
|
+
if (isGatewayTimeoutError(pollErr)) continue;
|
|
773
|
+
throw pollErr;
|
|
774
|
+
}
|
|
775
|
+
const engineStatus = status.branching_engine_status;
|
|
776
|
+
if (engineStatus === "healthy" || engineStatus === "degraded") {
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
if (engineStatus === "configuration_failed" || engineStatus === "failed_validation") {
|
|
780
|
+
throw new Error(
|
|
781
|
+
`Engine setup failed (status: ${engineStatus}). Check connector status: ardent connector list`
|
|
782
|
+
);
|
|
783
|
+
}
|
|
784
|
+
const elapsedSec = Math.round((Date.now() - startedAt) / 1e3);
|
|
785
|
+
console.log(` Still setting up... (${elapsedSec}s elapsed, status=${engineStatus ?? "unknown"})`);
|
|
786
|
+
}
|
|
787
|
+
throw new EngineSetupTimeoutError(
|
|
788
|
+
`Engine setup did not complete within ${maxWaitMs / 6e4} minutes. Setup may still be running server-side \u2014 do NOT delete the connector. Check status with: ardent connector list`
|
|
789
|
+
);
|
|
790
|
+
}
|
|
732
791
|
function parsePostgresUrl(url) {
|
|
733
792
|
const atIndex = url.lastIndexOf("@");
|
|
734
793
|
const credentialsPart = atIndex > 0 ? url.substring(0, atIndex) : url;
|
|
@@ -853,10 +912,12 @@ async function createAction2(type, url, options) {
|
|
|
853
912
|
if (isByoc) {
|
|
854
913
|
console.log("Setting up branching engine...");
|
|
855
914
|
try {
|
|
856
|
-
await
|
|
915
|
+
await runEngineSetupWithPolling(connectorId);
|
|
857
916
|
} catch (setupErr) {
|
|
858
|
-
|
|
859
|
-
|
|
917
|
+
if (!(setupErr instanceof EngineSetupTimeoutError)) {
|
|
918
|
+
console.error("\u2717 Engine setup failed. To retry, delete and recreate:");
|
|
919
|
+
console.error(` ardent connector delete ${connectorName}`);
|
|
920
|
+
}
|
|
860
921
|
throw setupErr;
|
|
861
922
|
}
|
|
862
923
|
} else {
|
|
@@ -882,7 +943,7 @@ async function createAction2(type, url, options) {
|
|
|
882
943
|
const connector = await api.get(`/v1/connectors/${connectorId}`);
|
|
883
944
|
if (connector.branching_engine_status === "configuration_verified") {
|
|
884
945
|
console.log("Setting up branching engine...");
|
|
885
|
-
await
|
|
946
|
+
await runEngineSetupWithPolling(connectorId);
|
|
886
947
|
}
|
|
887
948
|
}
|
|
888
949
|
const finalConnector = await api.get(`/v1/connectors/${connectorId}`);
|
|
@@ -976,19 +1037,27 @@ async function listAction2() {
|
|
|
976
1037
|
const dim2 = "\x1B[2m";
|
|
977
1038
|
const yellow = "\x1B[33m";
|
|
978
1039
|
const reset2 = "\x1B[0m";
|
|
1040
|
+
const red = "\x1B[31m";
|
|
979
1041
|
console.log("Connectors:\n");
|
|
980
1042
|
for (const connector of connectors) {
|
|
981
1043
|
const isCurrent = connector.id === currentConnectorId;
|
|
982
1044
|
const icon = connector.status === "healthy" ? "\u25CF" : "\u25CB";
|
|
983
1045
|
const warnings = connector.warnings ?? [];
|
|
984
1046
|
const warningSuffix = warnings.length > 0 ? ` ${yellow}\u26A0 ${warnings.length}${reset2}` : "";
|
|
1047
|
+
const statusSuffix = connector.status === "healthy" ? "" : ` ${red}[${connector.status}]${reset2}`;
|
|
985
1048
|
if (isCurrent) {
|
|
986
|
-
console.log(`${green2}* ${icon} ${connector.name}${reset2}${warningSuffix}`);
|
|
1049
|
+
console.log(`${green2}* ${icon} ${connector.name}${reset2}${warningSuffix}${statusSuffix}`);
|
|
987
1050
|
console.log(`${green2} ${connector.service_name}${reset2}`);
|
|
988
1051
|
} else {
|
|
989
|
-
console.log(` ${icon} ${connector.name}${warningSuffix}`);
|
|
1052
|
+
console.log(` ${icon} ${connector.name}${warningSuffix}${statusSuffix}`);
|
|
990
1053
|
console.log(`${dim2} ${connector.service_name}${reset2}`);
|
|
991
1054
|
}
|
|
1055
|
+
if (connector.status !== "healthy" && connector.connection_error) {
|
|
1056
|
+
for (const line of connector.connection_error.split("\n")) {
|
|
1057
|
+
if (line.trim().length === 0) continue;
|
|
1058
|
+
console.log(`${red} ${line}${reset2}`);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
992
1061
|
for (const warning of warnings) {
|
|
993
1062
|
console.log(`${yellow} \u26A0 ${warning}${reset2}`);
|
|
994
1063
|
}
|