1
0
Fork 0
mirror of synced 2024-09-30 00:57:16 +13:00

Plumbing for showing a maintenance page when SQS is required but missing.

This commit is contained in:
Sam Rose 2024-01-30 17:31:11 +00:00
parent 9a9ac12ee5
commit a268e55607
No known key found for this signature in database
7 changed files with 67 additions and 6 deletions

View file

@ -71,6 +71,10 @@
await auth.getSelf()
await admin.init()
if ($admin.maintenance.length > 0) {
$redirect("./maintenance")
}
if ($auth.user) {
await licensing.init()
}

View file

@ -0,0 +1,27 @@
<script>
import { Page, Layout, Heading, Body, Link } from "@budibase/bbui"
import { MaintenanceType } from "@budibase/types"
import { admin } from "stores/portal"
import BudibaseLogo from "../portal/_components/BudibaseLogo.svelte"
</script>
{#each $admin.maintenance as maintenance}
{#if maintenance.type === MaintenanceType.SQS_MISSING}
<Page>
<Layout>
<BudibaseLogo />
<Heading>Please upgrade your Budibase installation</Heading>
<Body>
We've detected that the version of Budibase you're using depends on a
more recent version of the CouchDB database than what you have
installed.
</Body>
<Body>
To resolve this, you can either rollback to a previous version of
Budibase, or follow the migration guide <Link href="#">here</Link>
to update to a later version of CouchDB.
</Body>
</Layout>
</Page>
{/if}
{/each}

View file

@ -0,0 +1,13 @@
<script>
import Logo from "assets/bb-emblem.svg"
import { goto } from "@roxi/routify"
</script>
<img src={Logo} alt="Budibase Logo" on:click={() => $goto("./apps")} />
<style>
img {
width: 30px;
height: 30px;
}
</style>

View file

@ -17,6 +17,7 @@ export const DEFAULT_CONFIG = {
adminUser: { checked: false },
sso: { checked: false },
},
maintenance: [],
offlineMode: false,
}
@ -48,6 +49,7 @@ export function createAdminStore() {
store.isDev = environment.isDev
store.baseUrl = environment.baseUrl
store.offlineMode = environment.offlineMode
store.maintenance = environment.maintenance
return store
})
}

View file

@ -2,3 +2,7 @@ export enum ServiceType {
WORKER = "worker",
APPS = "apps",
}
export enum MaintenanceType {
SQS_MISSING = "sqs_missing",
}

View file

@ -1,10 +1,18 @@
import { Ctx } from "@budibase/types"
import { Ctx, MaintenanceType } from "@budibase/types"
import env from "../../../environment"
import { env as coreEnv } from "@budibase/backend-core"
import nodeFetch from "node-fetch"
// When we come to move to SQS fully and move away from Clouseau, we will need
// to flip this to true (or remove it entirely). This will then be used to
// determine if we should show the maintenance page that links to the SQS
// migration docs.
const sqsRequired = false
let sqsAvailable: boolean
async function isSqsAvailable() {
// We cache this value for the duration of the Node process because we don't
// want every page load to be making this relatively expensive check.
if (sqsAvailable !== undefined) {
return sqsAvailable
}
@ -21,6 +29,10 @@ async function isSqsAvailable() {
}
}
async function isSqsMissing() {
return sqsRequired && !(await isSqsAvailable())
}
export const fetch = async (ctx: Ctx) => {
ctx.body = {
multiTenancy: !!env.MULTI_TENANCY,
@ -33,8 +45,9 @@ export const fetch = async (ctx: Ctx) => {
}
if (env.SELF_HOSTED) {
ctx.body.infrastructure = {
sqs: await isSqsAvailable(),
ctx.body.maintenance = []
if (await isSqsMissing()) {
ctx.body.maintenance.push({ type: MaintenanceType.SQS_MISSING })
}
}
}

View file

@ -40,9 +40,7 @@ describe("/api/system/environment", () => {
multiTenancy: true,
baseUrl: "http://localhost:10000",
offlineMode: false,
infrastructure: {
sqs: false,
},
maintenance: [],
})
})
})