From 4e54f6d0d105dcc34ffecd8a54d9411be9663b27 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 12 Nov 2020 12:58:05 +0000 Subject: [PATCH] track quota errors in deployment --- .../src/components/deploy/DeploymentHistory.svelte | 11 ++++++++++- packages/server/src/api/controllers/deploy/aws.js | 10 +++++----- packages/server/src/api/controllers/deploy/index.js | 9 +++------ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/builder/src/components/deploy/DeploymentHistory.svelte b/packages/builder/src/components/deploy/DeploymentHistory.svelte index 05a2e40fa6..ed7439eef9 100644 --- a/packages/builder/src/components/deploy/DeploymentHistory.svelte +++ b/packages/builder/src/components/deploy/DeploymentHistory.svelte @@ -7,6 +7,12 @@ import { notifier } from "builderStore/store/notifications" import CreateWebhookDeploymentModal from "./CreateWebhookDeploymentModal.svelte" + const DeploymentStatus = { + SUCCESS: "SUCCESS", + PENDING: "PENDING", + FAILURE: "FAILURE", + } + const DATE_OPTIONS = { fullDate: { weekday: "long", @@ -56,7 +62,7 @@

Deployment History

- {#if deployments.some(deployment => deployment.status === 'SUCCESS')} + {#if deployments.some(deployment => deployment.status === DeploymentStatus.SUCCESS)} View Your Deployed App → @@ -82,6 +88,9 @@
{deployment.status}
+ {#if deployment.status === DeploymentStatus.FAILURE} + {deployment.err} + {/if}
{/each} diff --git a/packages/server/src/api/controllers/deploy/aws.js b/packages/server/src/api/controllers/deploy/aws.js index 9e62f135a1..d478c4efde 100644 --- a/packages/server/src/api/controllers/deploy/aws.js +++ b/packages/server/src/api/controllers/deploy/aws.js @@ -55,17 +55,17 @@ exports.verifyDeployment = async function({ appId, quota }) { }), }) + const json = await response.json() + if (json.errors) { + throw new Error(json.errors) + } + if (response.status !== 200) { throw new Error( `Error fetching temporary credentials for api key: ${env.BUDIBASE_API_KEY}` ) } - const json = await response.json() - if (json.errors) { - throw new Error(json.errors) - } - // set credentials here, means any time we're verified we're ready to go if (json.credentials) { AWS.config.update({ diff --git a/packages/server/src/api/controllers/deploy/index.js b/packages/server/src/api/controllers/deploy/index.js index c3919ebbae..03f91430db 100644 --- a/packages/server/src/api/controllers/deploy/index.js +++ b/packages/server/src/api/controllers/deploy/index.js @@ -21,18 +21,15 @@ const DeploymentStatus = { // checks that deployments are in a good state, any pending will be updated async function checkAllDeployments(deployments) { let updated = false - function update(deployment, status) { - deployment.status = status - updated = true - } - for (let deployment of Object.values(deployments.history)) { // check that no deployments have crashed etc and are now stuck if ( deployment.status === DeploymentStatus.PENDING && Date.now() - deployment.updatedAt > MAX_PENDING_TIME_MS ) { - update(deployment, DeploymentStatus.FAILURE) + deployment.status = status + deployment.err = "Timed out" + updated = true } } return { updated, deployments }