Skip to content

Commit

Permalink
chore: bump timeout + handle wf error (#9)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
brodeyn and brodeynewman authored Jun 14, 2023
1 parent fefd6ea commit 9c0bec9
Show file tree
Hide file tree
Showing 4 changed files with 10,651 additions and 1,560 deletions.
26 changes: 20 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ const dayjs_1 = __importDefault(__nccwpck_require__(184));
const core = __importStar(__nccwpck_require__(7733));
__nccwpck_require__(4250);
const service_1 = __nccwpck_require__(1209);
const TIMEOUT_IN_MINUTES = 5;
/**
* Now that we have more robust container build processes, we should monitor...
* whether this timeout needs to be increased.
*/
const TIMEOUT_IN_MINUTES = 15;
const BAD_INSTANCE_STATES = ["errored", "failed"];
const defaultConfigPaths = [
"paperspace.yaml",
Expand Down Expand Up @@ -168,9 +172,13 @@ function isDeploymentStable(deployment) {
const { latestSpec } = deployment;
return !!(latestSpec === null || latestSpec === void 0 ? void 0 : latestSpec.dtHealthy);
}
function maybeCheckDeploymentError(deployment) {
const { latestSpec } = deployment;
return latestSpec === null || latestSpec === void 0 ? void 0 : latestSpec.error;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function syncDeployment(projectId, yaml) {
var _a;
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
const deploymentId = yield (0, service_1.upsertDeployment)({
config: yaml,
Expand All @@ -184,8 +192,14 @@ function syncDeployment(projectId, yaml) {
while (!isDeploymentUpdated) {
core.info("Waiting for deployment to complete...");
const { runs, deployment } = yield (0, service_1.getDeploymentWithDetails)(deploymentId);
const error = maybeCheckDeploymentError(deployment);
// this means our pre-build steps failed.
if (!((_a = deployment.latestSpec) === null || _a === void 0 ? void 0 : _a.externalApplied) && error) {
const fatalError = `Deployment upsert failed. ${error}`;
throw new Error(fatalError);
}
// only look at deployments that were applied to the target cluster
if ((_a = deployment.latestSpec) === null || _a === void 0 ? void 0 : _a.externalApplied) {
if ((_b = deployment.latestSpec) === null || _b === void 0 ? void 0 : _b.externalApplied) {
if (start.isBefore((0, dayjs_1.default)().subtract(TIMEOUT_IN_MINUTES, "minutes"))) {
throwBadDeployError(runs);
}
Expand Down Expand Up @@ -349,7 +363,7 @@ const upsertDeploymentFetcher = fetcher
.method("post")
.create();
const getDeploymentByProjectFetcher = fetcher
.path("/projects/{handle}/deployments")
.path("/projects/{id}/deployments")
.method("get")
.create();
function upsertDeployment(config) {
Expand All @@ -372,10 +386,10 @@ function upsertDeployment(config) {
});
}
exports.upsertDeployment = upsertDeployment;
function getDeploymentByProjectAndName(handle, name) {
function getDeploymentByProjectAndName(id, name) {
return __awaiter(this, void 0, void 0, function* () {
const { data } = yield getDeploymentByProjectFetcher({
handle,
id,
name,
});
const deployments = data.items;
Expand Down
Loading

0 comments on commit 9c0bec9

Please sign in to comment.