Skip to content

Commit 9c0bec9

Browse files
chore: bump timeout + handle wf error (#9)
* chore: bump timeout + handle wf error * chore: build * chore: log * chore: log * chore: handle error * chore: throw fatal error * fix: rm core error --------- Co-authored-by: Brodey Newman <[email protected]>
1 parent fefd6ea commit 9c0bec9

File tree

4 files changed

+10651
-1560
lines changed

4 files changed

+10651
-1560
lines changed

dist/index.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ const dayjs_1 = __importDefault(__nccwpck_require__(184));
9292
const core = __importStar(__nccwpck_require__(7733));
9393
__nccwpck_require__(4250);
9494
const service_1 = __nccwpck_require__(1209);
95-
const TIMEOUT_IN_MINUTES = 5;
95+
/**
96+
* Now that we have more robust container build processes, we should monitor...
97+
* whether this timeout needs to be increased.
98+
*/
99+
const TIMEOUT_IN_MINUTES = 15;
96100
const BAD_INSTANCE_STATES = ["errored", "failed"];
97101
const defaultConfigPaths = [
98102
"paperspace.yaml",
@@ -168,9 +172,13 @@ function isDeploymentStable(deployment) {
168172
const { latestSpec } = deployment;
169173
return !!(latestSpec === null || latestSpec === void 0 ? void 0 : latestSpec.dtHealthy);
170174
}
175+
function maybeCheckDeploymentError(deployment) {
176+
const { latestSpec } = deployment;
177+
return latestSpec === null || latestSpec === void 0 ? void 0 : latestSpec.error;
178+
}
171179
// eslint-disable-next-line @typescript-eslint/no-explicit-any
172180
function syncDeployment(projectId, yaml) {
173-
var _a;
181+
var _a, _b;
174182
return __awaiter(this, void 0, void 0, function* () {
175183
const deploymentId = yield (0, service_1.upsertDeployment)({
176184
config: yaml,
@@ -184,8 +192,14 @@ function syncDeployment(projectId, yaml) {
184192
while (!isDeploymentUpdated) {
185193
core.info("Waiting for deployment to complete...");
186194
const { runs, deployment } = yield (0, service_1.getDeploymentWithDetails)(deploymentId);
195+
const error = maybeCheckDeploymentError(deployment);
196+
// this means our pre-build steps failed.
197+
if (!((_a = deployment.latestSpec) === null || _a === void 0 ? void 0 : _a.externalApplied) && error) {
198+
const fatalError = `Deployment upsert failed. ${error}`;
199+
throw new Error(fatalError);
200+
}
187201
// only look at deployments that were applied to the target cluster
188-
if ((_a = deployment.latestSpec) === null || _a === void 0 ? void 0 : _a.externalApplied) {
202+
if ((_b = deployment.latestSpec) === null || _b === void 0 ? void 0 : _b.externalApplied) {
189203
if (start.isBefore((0, dayjs_1.default)().subtract(TIMEOUT_IN_MINUTES, "minutes"))) {
190204
throwBadDeployError(runs);
191205
}
@@ -349,7 +363,7 @@ const upsertDeploymentFetcher = fetcher
349363
.method("post")
350364
.create();
351365
const getDeploymentByProjectFetcher = fetcher
352-
.path("/projects/{handle}/deployments")
366+
.path("/projects/{id}/deployments")
353367
.method("get")
354368
.create();
355369
function upsertDeployment(config) {
@@ -372,10 +386,10 @@ function upsertDeployment(config) {
372386
});
373387
}
374388
exports.upsertDeployment = upsertDeployment;
375-
function getDeploymentByProjectAndName(handle, name) {
389+
function getDeploymentByProjectAndName(id, name) {
376390
return __awaiter(this, void 0, void 0, function* () {
377391
const { data } = yield getDeploymentByProjectFetcher({
378-
handle,
392+
id,
379393
name,
380394
});
381395
const deployments = data.items;

0 commit comments

Comments
 (0)