Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Disable read replica creation CTAs for HA projects (#49629)

Joshen Lim0b5be1fadaf6
diff --git a/apps/studio/components/interfaces/QuerySources/DatabaseParametersSubMenu.tsx b/apps/studio/components/interfaces/QuerySources/DatabaseParametersSubMenu.tsx
index 16490bf0156..16c7e3a09ba 100644
--- a/apps/studio/components/interfaces/QuerySources/DatabaseParametersSubMenu.tsx
+++ b/apps/studio/components/interfaces/QuerySources/DatabaseParametersSubMenu.tsx
@@ -1,4 +1,4 @@
-import { useParams } from 'common'
+import { IS_PLATFORM, useParams } from 'common'
import { Check, Plus } from 'lucide-react'
import Link from 'next/link'
import {
@@ -13,6 +13,7 @@ import { getAddReadReplicaPath } from '@/components/interfaces/Settings/Infrastr
import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'
import { formatDatabaseID, formatDatabaseRegion } from '@/data/read-replicas/replicas.utils'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
+import { useIsHighAvailability } from '@/hooks/misc/useSelectedProject'
/** The label a database row/summary shows: the primary, or a replica by region + id. */
function databaseLabel(identifier: string, region: string, projectRef: string | undefined) {
@@ -28,6 +29,7 @@ export const DatabaseParametersSubMenu = ({
onIdentifierChange: (identifier: string) => void
}) => {
const { ref: projectRef } = useParams()
+ const isHighAvailability = useIsHighAvailability()
const { infrastructureReadReplicas } = useIsFeatureEnabled(['infrastructure:read_replicas'])
const { data } = useReadReplicasQuery({ projectRef })
@@ -68,7 +70,7 @@ export const DatabaseParametersSubMenu = ({
</DropdownMenuItem>
)
})}
- {infrastructureReadReplicas && (
+ {IS_PLATFORM && infrastructureReadReplicas && !isHighAvailability && (
<>
<DropdownMenuSeparator />
<DropdownMenuItem asChild className="gap-x-2">
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
index fd0f561a1c4..970c1dcd999 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/ReadReplicaEligibilityWarnings.tsx
@@ -47,6 +47,7 @@ export const ReadReplicaEligibilityWarnings = ({
isBelowSmallCompute,
isWalgNotEnabled,
isProWithSpendCapEnabled,
+ isHighAvailability,
isReachedMaxReplicas,
maxNumberOfReplicas,
} = eligibility
@@ -88,6 +89,20 @@ export const ReadReplicaEligibilityWarnings = ({
)
}
+ if (isHighAvailability) {
+ return (
+ <Admonition
+ type="warning"
+ title="Read replicas are unavailable for High Availability projects"
+ >
+ <p>
+ We're working to bring this feature to High Availability projects. Contact support if this
+ is blocking your work.
+ </p>
+ </Admonition>
+ )
+ }
+
if (!isAWSProvider) {
return (
<Admonition
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts b/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts
index 6e8e7311314..9ce814aacc8 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicaForm/useCheckEligibilityDeployReplica.ts
@@ -9,7 +9,11 @@ import {
import { useProjectAddonsQuery } from '@/data/subscriptions/project-addons-query'
import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
-import { useIsAwsK8sCloudProvider, useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
+import {
+ useIsAwsK8sCloudProvider,
+ useIsHighAvailability,
+ useSelectedProjectQuery,
+} from '@/hooks/misc/useSelectedProject'
export const useCheckEligibilityDeployReplica = () => {
const { ref: projectRef } = useParams()
@@ -21,6 +25,7 @@ export const useCheckEligibilityDeployReplica = () => {
const isWalgEnabled = project?.is_physical_backups_enabled
const isNotOnHigherPlan = !['team', 'enterprise', 'platform'].includes(org?.plan.id ?? '')
const isProWithSpendCapEnabled = org?.plan.id === 'pro' && !org.usage_billing_enabled
+ const isHighAvailability = useIsHighAvailability()
const { data: allOverdueInvoices } = useOverdueInvoicesQuery({
enabled: isNotOnHigherPlan,
@@ -59,7 +64,8 @@ export const useCheckEligibilityDeployReplica = () => {
!hasOverdueInvoices &&
!isAwsK8s &&
!isProWithSpendCapEnabled &&
- !isBelowSmallCompute
+ !isBelowSmallCompute &&
+ !isHighAvailability
return {
can: canDeployReplica,
@@ -71,6 +77,7 @@ export const useCheckEligibilityDeployReplica = () => {
isWalgNotEnabled: !isWalgEnabled,
isProWithSpendCapEnabled,
isReachedMaxReplicas,
+ isHighAvailability,
maxNumberOfReplicas,
}
}
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx
index 32810ad8afc..324e44439dc 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/ReadReplicas/ReadReplicasSection.tsx
@@ -22,8 +22,10 @@ import { REPLICA_STATUS } from './ReadReplicas.constants'
import type { RecommendedComputeForReadReplicas } from './recommendCompute'
import { AlertError } from '@/components/ui/AlertError'
import { DocsButton } from '@/components/ui/DocsButton'
+import { HighAvailabilityDisabledSectionNotice } from '@/components/ui/HighAvailability/HighAvailabilityDisabledSectionNotice'
import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
+import { useIsHighAvailability } from '@/hooks/misc/useSelectedProject'
import { DOCS_URL } from '@/lib/constants'
interface ReadReplicasSectionProps {
@@ -32,6 +34,8 @@ interface ReadReplicasSectionProps {
export const ReadReplicasSection = ({ onRecommendCompute }: ReadReplicasSectionProps) => {
const { ref: projectRef } = useParams()
+ const isHighAvailability = useIsHighAvailability()
+
const { infrastructureReadReplicas } = useIsFeatureEnabled(['infrastructure:read_replicas'])
const [isAddReplicaOpen, setAddReplica] = useQueryState(
'addReplica',
@@ -87,19 +91,24 @@ export const ReadReplicasSection = ({ onRecommendCompute }: ReadReplicasSectionP
Scale reads or serve queries closer to users.
</PageSectionDescription>
</PageSectionSummary>
+
<PageSectionAside>
<DocsButton href={`${DOCS_URL}/guides/platform/read-replicas`} />
- <Button
- type="button"
- variant="primary"
- icon={<Plus />}
- onClick={() => setAddReplica(true)}
- >
- Add read replica
- </Button>
+ {!isHighAvailability && (
+ <Button
+ type="button"
+ variant="primary"
+ icon={<Plus />}
+ onClick={() => setAddReplica(true)}
+ >
+ Add read replica
+ </Button>
+ )}
</PageSectionAside>
</PageSectionMeta>
+ <HighAvailabilityDisabledSectionNotice title="Read replicas are unavailable on High Availability projects" />
+
<PageSectionContent className="flex flex-col gap-y-4">
{isDatabasesError && (
<AlertError error={databasesError} subject="Failed to retrieve read replicas" />
@@ -140,14 +149,16 @@ export const ReadReplicasSection = ({ onRecommendCompute }: ReadReplicasSectionP
title="No read replicas"
description="All reads and writes currently go to the primary."
>
- <Button
- type="button"
- variant="default"
- icon={<Plus />}
- onClick={() => setAddReplica(true)}
- >
- Add read replica
- </Button>
+ {!isHighAvailability && (
+ <Button
+ type="button"
+ variant="default"
+ icon={<Plus />}
+ onClick={() => setAddReplica(true)}
+ >
+ Add read replica
+ </Button>
+ )}
</EmptyStatePresentational>
)}
</PageSectionContent>
diff --git a/apps/studio/components/ui/DatabaseSelector.tsx b/apps/studio/components/ui/DatabaseSelector.tsx
index d00e98d2661..b31eac61d47 100644
--- a/apps/studio/components/ui/DatabaseSelector.tsx
+++ b/apps/studio/components/ui/DatabaseSelector.tsx
@@ -30,6 +30,7 @@ import { CommandItemLink } from '@/components/ui/CommandItemLink'
import { useReadReplicasQuery } from '@/data/read-replicas/replicas-query'
import { formatDatabaseID, formatDatabaseRegion } from '@/data/read-replicas/replicas.utils'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
+import { useIsHighAvailability } from '@/hooks/misc/useSelectedProject'
import { IS_PLATFORM } from '@/lib/constants'
import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector'
@@ -55,6 +56,8 @@ export const DatabaseSelector = ({
isForm = false,
}: DatabaseSelectorProps) => {
const { ref: projectRef } = useParams()
+ const isHighAvailability = useIsHighAvailability()
+
const [open, setOpen] = useState(false)
const [, setShowConnect] = useQueryState('showConnect', parseAsBoolean.withDefault(false))
@@ -216,7 +219,7 @@ export const DatabaseSelector = ({
</ScrollArea>
</CommandGroup>
- {IS_PLATFORM && infrastructureReadReplicas && (
+ {IS_PLATFORM && infrastructureReadReplicas && !isHighAvailability && (
<CommandGroup className="border-t">
<CommandItemLink
href={newReplicaURL}
diff --git a/apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx b/apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx
index 5bd41bd2c31..cb125d3e4ef 100644
--- a/apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx
+++ b/apps/studio/tests/components/Settings/Infrastructure/ReadReplicaEligibilityWarnings.test.tsx
@@ -29,6 +29,7 @@ const eligibility = (delta: Record<string, unknown>) => ({
isWalgNotEnabled: false,
isProWithSpendCapEnabled: false,
isReachedMaxReplicas: false,
+ isHighAvailability: false,
maxNumberOfReplicas: READ_REPLICAS_MAX_COUNT,
...delta,
})