The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Prevent deploying replicas if on pro plan with spend cap enabled (#29784)
Joshen Lim3b3e4df89328
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsxindex 8eddf4eaa81..a1e5ab6d240 100644--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/DeployNewReplicaPanel.tsx@@ -51,6 +51,7 @@ import {cn,} from 'ui'import { AVAILABLE_REPLICA_REGIONS } from './InstanceConfiguration.constants'+import { Admonition } from 'ui-patterns'// [Joshen] FYI this is purely for AWS only, need to update to support Fly eventually@@ -172,6 +173,8 @@ const DeployNewReplicaPanel = ({const currentComputeAddon = addons?.selected_addons.find((addon) => addon.type === 'compute_instance')+ const isProWithSpendCapEnabled =+ subscription?.plan.id === 'pro' && !subscription.usage_billing_enabledconst isMinimallyOnSmallCompute =currentComputeAddon?.variant.identifier !== undefined &¤tComputeAddon?.variant.identifier !== 'ci_micro'@@ -182,7 +185,8 @@ const DeployNewReplicaPanel = ({!isFreePlan &&isWalgEnabled &¤tComputeAddon !== undefined &&- !hasOverdueInvoices+ !hasOverdueInvoices &&+ !isProWithSpendCapEnabledconst computeAddons =addons?.available_addons.find((addon) => addon.type === 'compute_instance')?.variants ?? []@@ -286,18 +290,123 @@ const DeployNewReplicaPanel = ({</Button></AlertDescription_Shadcn_></Alert_Shadcn_>- ) : (- <>- {!isMinimallyOnSmallCompute && (- <Alert_Shadcn_>- <WarningIcon />- <AlertTitle_Shadcn_>- Project required to at least be on a Small compute- </AlertTitle_Shadcn_>+ ) : !isMinimallyOnSmallCompute ? (+ <Alert_Shadcn_>+ <WarningIcon />+ <AlertTitle_Shadcn_>+ Project required to at least be on a Small compute+ </AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ <span>+ This is to ensure that read replicas can keep up with the primary databases'+ activities.+ </span>+ <div className="flex items-center gap-x-2 mt-3">+ <Button asChild type="default">+ <Link+ href={+ isFreePlan+ ? `/org/${org?.slug}/billing?panel=subscriptionPlan`+ : `/project/${projectRef}/settings/addons?panel=computeInstance`+ }+ >+ {isFreePlan ? 'Upgrade to Pro' : 'Change compute size'}+ </Link>+ </Button>+ <Button asChild type="default" icon={<ExternalLink />}>+ <a+ href="https://supabase.com/docs/guides/platform/read-replicas#prerequisites"+ target="_blank"+ rel="noreferrer"+ >+ Documentation+ </a>+ </Button>+ </div>+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_>+ ) : !isWalgEnabled ? (+ <Alert_Shadcn_>+ <WarningIcon />+ <AlertTitle_Shadcn_>+ {refetchInterval !== false+ ? 'Physical backups are currently being enabled'+ : 'Physical backups are required to deploy replicas'}+ </AlertTitle_Shadcn_>+ {refetchInterval === false && (+ <AlertDescription_Shadcn_ className="mb-2">+ Physical backups are used under the hood to spin up read replicas for your project.+ </AlertDescription_Shadcn_>+ )}+ <AlertDescription_Shadcn_>+ {refetchInterval !== false+ ? 'This warning will go away once physical backups have been enabled - check back in a few minutes!'+ : 'Enabling physical backups will take a few minutes, after which you will be able to deploy read replicas.'}+ </AlertDescription_Shadcn_>+ {refetchInterval !== false ? (+ <AlertDescription_Shadcn_ className="mt-2">+ You may start deploying read replicas thereafter once this is completed.+ </AlertDescription_Shadcn_>+ ) : (+ <AlertDescription_Shadcn_ className="flex items-center gap-x-2 mt-3">+ <Button+ type="default"+ loading={isEnabling}+ disabled={isEnabling}+ onClick={() => {+ if (projectRef) enablePhysicalBackups({ ref: projectRef })+ }}+ >+ Enable physical backups+ </Button>+ <Button asChild type="default" icon={<ExternalLink />}>+ <a+ href="https://supabase.com/docs/guides/platform/read-replicas#how-are-read-replicas-made"+ target="_blank"+ rel="noreferrer"+ >+ Documentation+ </a>+ </Button>+ </AlertDescription_Shadcn_>+ )}+ </Alert_Shadcn_>+ ) : isProWithSpendCapEnabled ? (+ <Alert_Shadcn_>+ <WarningIcon />+ <AlertTitle_Shadcn_>+ Spend cap needs to be disabled to deploy replicas+ </AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ <span>+ Launching a replica incurs additional disk size that will exceed the plan's quota.+ Disable the spend cap first to allow overages before launching a replica.+ </span>+ <div className="flex items-center gap-x-2 mt-3">+ <Button asChild type="default">+ <Link href={`/org/${org?.slug}/billing?panel=costControl`}>+ Disable spend cap+ </Link>+ </Button>+ </div>+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_>+ ) : reachedMaxReplicas ? (+ <Alert_Shadcn_>+ <WarningIcon />+ <AlertTitle_Shadcn_>+ You can only deploy up to {maxNumberOfReplicas} read replicas at once+ </AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ If you'd like to spin up another read replica, please drop an existing replica first.+ </AlertDescription_Shadcn_>+ {maxNumberOfReplicas === MAX_REPLICAS_BELOW_XL && (+ <><AlertDescription_Shadcn_><span>- This is to ensure that read replicas can keep up with the primary databases'- activities.+ Alternatively, you may deploy up to{' '}+ <span className="text-foreground">{MAX_REPLICAS_ABOVE_XL}</span> replicas if+ your project is on an XL compute or higher.</span><div className="flex items-center gap-x-2 mt-3"><Button asChild type="default">@@ -308,110 +417,15 @@ const DeployNewReplicaPanel = ({: `/project/${projectRef}/settings/addons?panel=computeInstance`}>- {isFreePlan ? 'Upgrade to Pro' : 'Change compute size'}+ Upgrade compute size</Link></Button>- <Button asChild type="default" icon={<ExternalLink />}>- <a- href="https://supabase.com/docs/guides/platform/read-replicas#prerequisites"- target="_blank"- rel="noreferrer"- >- Documentation- </a>- </Button></div></AlertDescription_Shadcn_>- </Alert_Shadcn_>- )}-- {isMinimallyOnSmallCompute && !isWalgEnabled && (- <Alert_Shadcn_>- <WarningIcon />- <AlertTitle_Shadcn_>- {refetchInterval !== false- ? 'Physical backups are currently being enabled'- : 'Physical backups are required to deploy replicas'}- </AlertTitle_Shadcn_>- {refetchInterval === false && (- <AlertDescription_Shadcn_ className="mb-2">- Physical backups are used under the hood to spin up read replicas for your- project.- </AlertDescription_Shadcn_>- )}- <AlertDescription_Shadcn_>- {refetchInterval !== false- ? 'This warning will go away once physical backups have been enabled - check back in a few minutes!'- : 'Enabling physical backups will take a few minutes, after which you will be able to deploy read replicas.'}- </AlertDescription_Shadcn_>- {refetchInterval !== false ? (- <AlertDescription_Shadcn_ className="mt-2">- You may start deploying read replicas thereafter once this is completed.- </AlertDescription_Shadcn_>- ) : (- <AlertDescription_Shadcn_ className="flex items-center gap-x-2 mt-3">- <Button- type="default"- loading={isEnabling}- disabled={isEnabling}- onClick={() => {- if (projectRef) enablePhysicalBackups({ ref: projectRef })- }}- >- Enable physical backups- </Button>- <Button asChild type="default" icon={<ExternalLink />}>- <a- href="https://supabase.com/docs/guides/platform/read-replicas#how-are-read-replicas-made"- target="_blank"- rel="noreferrer"- >- Documentation- </a>- </Button>- </AlertDescription_Shadcn_>- )}- </Alert_Shadcn_>- )}-- {reachedMaxReplicas && (- <Alert_Shadcn_>- <WarningIcon />- <AlertTitle_Shadcn_>- You can only deploy up to {maxNumberOfReplicas} read replicas at once- </AlertTitle_Shadcn_>- <AlertDescription_Shadcn_>- If you'd like to spin up another read replica, please drop an existing replica- first.- </AlertDescription_Shadcn_>- {maxNumberOfReplicas === MAX_REPLICAS_BELOW_XL && (- <>- <AlertDescription_Shadcn_>- <span>- Alternatively, you may deploy up to{' '}- <span className="text-foreground">{MAX_REPLICAS_ABOVE_XL}</span> replicas if- your project is on an XL compute or higher.- </span>- <div className="flex items-center gap-x-2 mt-3">- <Button asChild type="default">- <Link- href={- isFreePlan- ? `/org/${org?.slug}/billing?panel=subscriptionPlan`- : `/project/${projectRef}/settings/addons?panel=computeInstance`- }- >- Upgrade compute size- </Link>- </Button>- </div>- </AlertDescription_Shadcn_>- </>- )}- </Alert_Shadcn_>+ </>)}- </>- )}+ </Alert_Shadcn_>+ ) : null}<div className="flex flex-col gap-y-6 mt-2"><Listbox