Skip to content

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

[FE-3711] feat(studio): make compute config read-only for HA projects (#49359)

Alaister Youngb9df7aaf9e0a
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.sections.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.sections.tsx
index 3270f2a78f0..e2b51505797 100644
--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.sections.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.sections.tsx
@@ -29,6 +29,7 @@ import { DiskSpaceBar } from './ui/DiskSpaceBar'
import { NoticeBar } from './ui/NoticeBar'
import { SpendCapDisabledSection } from './ui/SpendCapDisabledSection'
import { DocsButton } from '@/components/ui/DocsButton'
+import { HighAvailabilityDisabledSectionNotice } from '@/components/ui/HighAvailability/HighAvailabilityDisabledSectionNotice'
import { RequestUpgradeToBillingOwners } from '@/components/ui/RequestUpgradeToBillingOwners'
import { DOCS_URL } from '@/lib/constants'
@@ -68,7 +69,15 @@ export function ComputeSection({
<DocsButton href={`${DOCS_URL}/guides/platform/compute-and-disk`} />
</PageSectionAside>
</PageSectionMeta>
- <PageSectionContent ref={settingsRef} id="compute" className="scroll-mt-24">
+ <PageSectionContent
+ ref={settingsRef}
+ id="compute"
+ className="scroll-mt-24 flex flex-col gap-4"
+ >
+ <HighAvailabilityDisabledSectionNotice
+ title="Compute size can't be changed on High Availability projects"
+ description="High Availability projects run on a fixed compute size during Alpha. Contact support if this is blocking your work."
+ />
<ComputeSizeField form={form} disabled={disabled} />
</PageSectionContent>
</PageSection>
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx
index e031adfa6f8..98cae8cb731 100644
--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementForm.tsx
@@ -55,6 +55,7 @@ import { AddonVariantId } from '@/data/subscriptions/types'
import { useResourceWarningsQuery } from '@/data/usage/resource-warnings-query'
import { useCheckEntitlements } from '@/hooks/misc/useCheckEntitlements'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
+import { useHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import {
useIsAwsCloudProvider,
@@ -101,6 +102,7 @@ export function DiskManagementForm({
const isAws = useIsAwsCloudProvider()
const isAwsK8s = useIsAwsK8sCloudProvider()
const isAwsNimbus = useIsAwsNimbusCloudProvider()
+ const { isHighAvailability } = useHighAvailability()
const { can: canUpdateDiskConfiguration, isSuccess: isPermissionsLoaded } =
useAsyncCheckPermissions(PermissionAction.UPDATE, 'projects', {
@@ -234,7 +236,8 @@ export function DiskManagementForm({
const disableDiskInputs = disableDiskSizeInput || isSpendCapEnabled
- const disableComputeInputs = isPlanUpgradeRequired
+ // Compute resizing is not supported for High Availability projects during Alpha
+ const disableComputeInputs = isPlanUpgradeRequired || isHighAvailability
const isDirty = !!Object.keys(form.formState.dirtyFields).length
const isProjectResizing = project?.status === PROJECT_STATUS.RESIZING
const isProjectRequestingDiskChanges = isRequestingChanges && !isProjectResizing
@@ -306,7 +309,10 @@ export function DiskManagementForm({
})
}
- if (payload.computeSize !== form.formState.defaultValues?.computeSize) {
+ if (
+ !isHighAvailability &&
+ payload.computeSize !== form.formState.defaultValues?.computeSize
+ ) {
await updateSubscriptionAddon({
projectRef: projectRef,
// cast variant to AddonVariantId to satisfy type
@@ -366,19 +372,21 @@ export function DiskManagementForm({
}, [modifiedComputeSize, form, isDialogOpen, project])
useEffect(() => {
- // Initialize field values properly when data has been loaded, preserving any user changes
- if (isDiskAttributesSuccess || isSuccess) {
+ // Initialize field values properly when data has been loaded, preserving any user changes.
+ // Disk attribute queries never run for High Availability projects (non-AWS cloud provider),
+ // so the project loading is the initialization signal there.
+ if (isDiskAttributesSuccess || isSuccess || isHighAvailability) {
form.reset(defaultValues, {})
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [isSuccess, isDiskAttributesSuccess])
+ }, [isSuccess, isDiskAttributesSuccess, isHighAvailability])
// Apply the recommendation only after the sheet's close lifecycle has completed.
useEffect(() => {
// The compute add-on supplies the option. Keep the recommendation pending
// until disk attributes have initialised the form, so a later reset cannot
// overwrite it. Other infrastructure requests are unrelated to this handoff.
- if (!recommendedCompute || !isAddonsSuccess) return
+ if (!recommendedCompute || !isAddonsSuccess || isHighAvailability) return
form.setValue('computeSize', recommendedCompute, {
shouldDirty: true,
@@ -411,6 +419,7 @@ export function DiskManagementForm({
form,
isAddonsSuccess,
isDiskAttributesSuccess,
+ isHighAvailability,
mainScrollContainer,
onRecommendedComputeApplied,
recommendedCompute,
diff --git a/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx b/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx
index b7d48f020b1..7f8b36d6ac5 100644
--- a/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/fields/ComputeSizeField.tsx
@@ -20,13 +20,18 @@ import { ComputeBadge } from 'ui-patterns/ComputeBadge'
import { DiskStorageSchemaType } from '../DiskManagement.schema'
import { ComputeInstanceAddonVariantId, InfraInstanceSize } from '../DiskManagement.types'
-import { ComputeAddonVariant, getAvailableComputeOptions } from '../DiskManagement.utils'
+import {
+ ComputeAddonVariant,
+ getAvailableComputeOptions,
+ mapComputeSizeNameToAddonVariantId,
+} from '../DiskManagement.utils'
import { BillingChangeBadge } from '../ui/BillingChangeBadge'
import FormMessage from '../ui/FormMessage'
import { useShowMicroUpgradeBadge } from './useShowMicroUpgradeBadge'
import { SupportLink } from '@/components/interfaces/Support/SupportLink'
import { InlineLink } from '@/components/ui/InlineLink'
import { useProjectAddonsQuery } from '@/data/subscriptions/project-addons-query'
+import { useHighAvailability } from '@/hooks/misc/useHighAvailability'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
@@ -75,6 +80,13 @@ export function ComputeSizeField({ form, disabled }: ComputeSizeFieldProps) {
const { data: org } = useSelectedOrganizationQuery()
const { project, isProjectLoading, isEntitlementLoading, showMicroUpgradeBadge } =
useShowMicroUpgradeBadge()
+ const { isHighAvailability } = useHighAvailability()
+
+ // High Availability projects run on a fixed compute size during Alpha,
+ // so every option other than the project's current size is locked
+ const currentComputeVariantId = project?.infra_compute_size
+ ? mapComputeSizeNameToAddonVariantId(project.infra_compute_size)
+ : undefined
const showComputePrice = useIsFeatureEnabled('project_addons:show_compute_price')
@@ -145,8 +157,11 @@ export function ComputeSizeField({ form, disabled }: ComputeSizeFieldProps) {
org?.plan.id !== 'free' &&
project?.infra_compute_size !== 'nano' &&
compute.identifier === 'ci_nano'
+ const lockedDueToHighAvailability =
+ isHighAvailability && compute.identifier !== currentComputeVariantId
- const lockedOption = lockedNanoDueToPlan || lockedMicroDueToPITR
+ const lockedOption =
+ lockedNanoDueToPlan || lockedMicroDueToPITR || lockedDueToHighAvailability
// Nano on a paid plan is billed at the Micro rate
const isNanoBilledAsMicro =
@@ -269,7 +284,13 @@ export function ComputeSizeField({ form, disabled }: ComputeSizeFieldProps) {
</div>
</div>
</TooltipTrigger>
- {lockedMicroDueToPITR && (
+ {lockedDueToHighAvailability && (
+ <TooltipContent side="bottom" className="w-64 text-center">
+ Compute size can't be changed on High Availability projects during
+ Alpha
+ </TooltipContent>
+ )}
+ {!lockedDueToHighAvailability && lockedMicroDueToPITR && (
<TooltipContent side="bottom" className="w-64 text-center">
Project has PITR enabled which requires a minimum of Small compute.
Please{' '}
@@ -284,50 +305,52 @@ export function ComputeSizeField({ form, disabled }: ComputeSizeFieldProps) {
/>
)
})}
- <div
- className={cn(
- 'relative text-sm text-left flex flex-col gap-0 px-0 py-3 w-full h-[110px]',
- 'bg-overlay rounded-md border p-2 hover:border-control-hover'
- )}
- >
- <SupportLink
- queryParams={{
- projectRef: ref,
- category: SupportCategories.SALES_ENQUIRY,
- subject: 'Enquiry about larger instance sizes',
- }}
+ {!isHighAvailability && (
+ <div
+ className={cn(
+ 'relative text-sm text-left flex flex-col gap-0 px-0 py-3 w-full h-[110px]',
+ 'bg-overlay rounded-md border p-2 hover:border-control-hover'
+ )}
>
- <div className="w-full flex flex-col gap-3 justify-between">
- <div className="relative px-3 flex justify-between">
- <ComputeBadge infraComputeSize=">16XL" />
+ <SupportLink
+ queryParams={{
+ projectRef: ref,
+ category: SupportCategories.SALES_ENQUIRY,
+ subject: 'Enquiry about larger instance sizes',
+ }}
+ >
+ <div className="w-full flex flex-col gap-3 justify-between">
+ <div className="relative px-3 flex justify-between">
+ <ComputeBadge infraComputeSize=">16XL" />
- <div className="flex items-center space-x-1 opacity-50 ">
- <span className="text-foreground-light text-sm">Contact Us</span>
- </div>
- </div>
- <div className="w-full">
- <div className="px-3 text-sm flex flex-col gap-1">
- <div className="text-foreground-light flex gap-2 items-center">
- <Microchip
- strokeWidth={1}
- size={14}
- className="text-foreground-lighter"
- />
- <span>Custom memory</span>
+ <div className="flex items-center space-x-1 opacity-50 ">
+ <span className="text-foreground-light text-sm">Contact Us</span>
</div>
- <div className="text-foreground-light flex gap-2 items-center">
- <CpuIcon
- strokeWidth={1}
- size={14}
- className="text-foreground-lighter"
- />
- <span>Custom CPU</span>
+ </div>
+ <div className="w-full">
+ <div className="px-3 text-sm flex flex-col gap-1">
+ <div className="text-foreground-light flex gap-2 items-center">
+ <Microchip
+ strokeWidth={1}
+ size={14}
+ className="text-foreground-lighter"
+ />
+ <span>Custom memory</span>
+ </div>
+ <div className="text-foreground-light flex gap-2 items-center">
+ <CpuIcon
+ strokeWidth={1}
+ size={14}
+ className="text-foreground-lighter"
+ />
+ <span>Custom CPU</span>
+ </div>
</div>
</div>
</div>
- </div>
- </SupportLink>
- </div>
+ </SupportLink>
+ </div>
+ )}
</>
)}
</RadioGroupCard>
diff --git a/apps/studio/tests/pages/project/[ref]/settings/infrastructure.test.tsx b/apps/studio/tests/pages/project/[ref]/settings/infrastructure.test.tsx
index 2ab2fae51a3..babf74a4799 100644
--- a/apps/studio/tests/pages/project/[ref]/settings/infrastructure.test.tsx
+++ b/apps/studio/tests/pages/project/[ref]/settings/infrastructure.test.tsx
@@ -384,6 +384,80 @@ describe('/project/[ref]/settings/infrastructure', () => {
})
})
+ test('renders compute as read-only for High Availability projects', async () => {
+ const user = userEvent.setup()
+
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref',
+ response: {
+ ...PROJECT,
+ cloud_provider: 'AWS_K8S',
+ high_availability: true,
+ infra_compute_size: 'large',
+ } satisfies ProjectDetailResponse,
+ })
+ addAPIMock({
+ method: 'get',
+ path: '/platform/projects/:ref/billing/addons',
+ response: {
+ available_addons: [
+ {
+ name: 'Compute Instance',
+ type: 'compute_instance',
+ variants: COMPUTE_VARIANTS,
+ },
+ ],
+ ref: PROJECT_REF,
+ selected_addons: [
+ {
+ type: 'compute_instance',
+ variant: COMPUTE_VARIANTS[2],
+ },
+ ],
+ },
+ })
+
+ renderInfrastructurePage()
+
+ expect(
+ await screen.findByText("Compute size can't be changed on High Availability projects")
+ ).toBeInTheDocument()
+
+ const largeCompute = await screen.findByRole('radio', { name: /Large/ })
+ await waitFor(() => expect(largeCompute).toBeChecked())
+
+ const microCompute = screen.getByRole('radio', { name: /Micro/ })
+ const smallCompute = screen.getByRole('radio', { name: /Small/ })
+ expect(largeCompute).toBeDisabled()
+ expect(microCompute).toBeDisabled()
+ expect(smallCompute).toBeDisabled()
+
+ // The "Contact Us" card for larger sizes is hidden for High Availability projects
+ expect(screen.queryByText('Contact Us')).not.toBeInTheDocument()
+
+ // Clicking a locked option must not dirty the form or surface the submit flow
+ await user.click(smallCompute)
+ expect(largeCompute).toBeChecked()
+ expect(screen.queryByRole('button', { name: 'Review changes' })).not.toBeInTheDocument()
+ })
+
+ test('keeps compute editable for non High Availability projects', async () => {
+ const user = userEvent.setup()
+ renderInfrastructurePage()
+
+ expect(
+ screen.queryByText("Compute size can't be changed on High Availability projects")
+ ).not.toBeInTheDocument()
+
+ const smallCompute = await screen.findByRole('radio', { name: /Small/ })
+ expect(smallCompute).toBeEnabled()
+ expect(screen.getByText('Contact Us')).toBeInTheDocument()
+
+ await user.click(smallCompute)
+ expect(screen.getByRole('button', { name: 'Review changes' })).toBeEnabled()
+ })
+
test('submits disk and autoscaling changes to both infrastructure APIs', async () => {
const user = userEvent.setup()
let diskRequest: unknown