1
0
Fork 0
mirror of synced 2024-06-30 03:50:37 +12:00

track quota errors in deployment

This commit is contained in:
Martin McKeaveney 2020-11-12 12:58:05 +00:00
parent dee8af1332
commit 4e54f6d0d1
3 changed files with 18 additions and 12 deletions

View file

@ -7,6 +7,12 @@
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import CreateWebhookDeploymentModal from "./CreateWebhookDeploymentModal.svelte" import CreateWebhookDeploymentModal from "./CreateWebhookDeploymentModal.svelte"
const DeploymentStatus = {
SUCCESS: "SUCCESS",
PENDING: "PENDING",
FAILURE: "FAILURE",
}
const DATE_OPTIONS = { const DATE_OPTIONS = {
fullDate: { fullDate: {
weekday: "long", weekday: "long",
@ -56,7 +62,7 @@
<header> <header>
<h4>Deployment History</h4> <h4>Deployment History</h4>
<div class="deploy-div"> <div class="deploy-div">
{#if deployments.some(deployment => deployment.status === 'SUCCESS')} {#if deployments.some(deployment => deployment.status === DeploymentStatus.SUCCESS)}
<a target="_blank" href={`https://${appId}.app.budi.live/${appId}`}> <a target="_blank" href={`https://${appId}.app.budi.live/${appId}`}>
View Your Deployed App → View Your Deployed App →
</a> </a>
@ -82,6 +88,9 @@
<div class={`deployment-status ${deployment.status}`}> <div class={`deployment-status ${deployment.status}`}>
{deployment.status} {deployment.status}
</div> </div>
{#if deployment.status === DeploymentStatus.FAILURE}
<span>{deployment.err}</span>
{/if}
</div> </div>
</article> </article>
{/each} {/each}

View file

@ -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) { if (response.status !== 200) {
throw new Error( throw new Error(
`Error fetching temporary credentials for api key: ${env.BUDIBASE_API_KEY}` `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 // set credentials here, means any time we're verified we're ready to go
if (json.credentials) { if (json.credentials) {
AWS.config.update({ AWS.config.update({

View file

@ -21,18 +21,15 @@ const DeploymentStatus = {
// checks that deployments are in a good state, any pending will be updated // checks that deployments are in a good state, any pending will be updated
async function checkAllDeployments(deployments) { async function checkAllDeployments(deployments) {
let updated = false let updated = false
function update(deployment, status) {
deployment.status = status
updated = true
}
for (let deployment of Object.values(deployments.history)) { for (let deployment of Object.values(deployments.history)) {
// check that no deployments have crashed etc and are now stuck // check that no deployments have crashed etc and are now stuck
if ( if (
deployment.status === DeploymentStatus.PENDING && deployment.status === DeploymentStatus.PENDING &&
Date.now() - deployment.updatedAt > MAX_PENDING_TIME_MS Date.now() - deployment.updatedAt > MAX_PENDING_TIME_MS
) { ) {
update(deployment, DeploymentStatus.FAILURE) deployment.status = status
deployment.err = "Timed out"
updated = true
} }
} }
return { updated, deployments } return { updated, deployments }