-
+ {/*
Throughput must be between {minThroughput.toLocaleString()}{' '}
and {maxThroughput?.toLocaleString()} MB/s based on your IOPS.
Min throughput is at 125MB/s, while max throughput is at
0.25MB/s * IOPS or 1,000, whichever is lower
-
+ */}
{!form.formState.errors.throughput &&
field.value !== undefined &&
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelSchema.ts b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelSchema.ts
index 91d51cf4194..df3e2a66690 100644
--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelSchema.ts
+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelSchema.ts
@@ -1,6 +1,14 @@
import { z } from 'zod'
-import { DISK_LIMITS, DiskType } from './DiskManagement.constants'
-import { calculateMaxIopsAllowed } from './DiskManagement.utils'
+import { DISK_LIMITS, DiskType, THROUGHPUT_RANGE, IOPS_RANGE } from './DiskManagement.constants'
+import {
+ calculateComputeSizeRequiredForIops,
+ calculateDiskSizeRequiredForIopsWithGp3,
+ calculateDiskSizeRequiredForIopsWithIo2,
+ calculateIopsRequiredForThroughput,
+ calculateMaxIopsAllowedForComputeSize,
+ calculateMaxIopsAllowedForDiskSizeWithGp3,
+ calculateMaxIopsAllowedForDiskSizeWithio2,
+} from './DiskManagement.utils'
const baseSchema = z.object({
storageType: z.enum(['io2', 'gp3']).describe('Type of storage: io2 or gp3'),
@@ -17,6 +25,8 @@ export const CreateDiskStorageSchema = (defaultTotalSize: number) => {
const schema = baseSchema.superRefine((data, ctx) => {
const { storageType, totalSize, provisionedIOPS, throughput, computeSize } = data
+ const computeLabel = computeSize.toUpperCase().replace('CI_', '')
+
if (totalSize < defaultTotalSize) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
@@ -27,7 +37,17 @@ export const CreateDiskStorageSchema = (defaultTotalSize: number) => {
if (storageType === 'io2') {
// Validation rules for io2
- const maxIOPS = calculateMaxIopsAllowed(totalSize)
+
+ if (provisionedIOPS > 256000) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message:
+ 'IOPS can not exceed 256,000 for io2 Disk type. Please reach out to support if you need higher IOPS than this.',
+ path: ['provisionedIOPS'],
+ })
+ }
+
+ const maxIOPSforDiskSizeWithio2 = calculateMaxIopsAllowedForDiskSizeWithio2(totalSize)
if (provisionedIOPS < 100) {
ctx.addIssue({
@@ -35,11 +55,14 @@ export const CreateDiskStorageSchema = (defaultTotalSize: number) => {
message: 'Provisioned IOPS must be at least 100',
path: ['provisionedIOPS'],
})
- } else if (provisionedIOPS > maxIOPS) {
+ } else if (provisionedIOPS > maxIOPSforDiskSizeWithio2) {
if (totalSize >= 8) {
+ const diskSizeRequiredForIopsWithIo2 =
+ calculateDiskSizeRequiredForIopsWithIo2(provisionedIOPS)
+
ctx.addIssue({
code: z.ZodIssueCode.custom,
- message: `Provisioned IOPS must be at most ${maxIOPS}.`,
+ message: `Larger Disk size of at least ${diskSizeRequiredForIopsWithIo2}GB required. Current max is ${maxIOPSforDiskSizeWithio2} IOPS.`,
path: ['provisionedIOPS'],
})
} else {
@@ -66,22 +89,34 @@ export const CreateDiskStorageSchema = (defaultTotalSize: number) => {
path: ['totalSize'],
})
}
- } else if (storageType === 'gp3') {
- // Validation rules for gp3
- const maxIOPS = Math.min(500 * totalSize, 16000)
- const maxThroughput = Math.min(0.25 * provisionedIOPS, 1000)
+ }
- if (provisionedIOPS < 3000) {
+ if (storageType === 'gp3') {
+ const maxIopsAllowedForDiskSizeWithGp3 = calculateMaxIopsAllowedForDiskSizeWithGp3(totalSize)
+
+ if (provisionedIOPS > IOPS_RANGE[DiskType.GP3].max) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message:
+ 'IOPS can not exceed 16,000 for GP3 Disk. Change the Disk type to io2 for higher IOPS support.',
+ path: ['provisionedIOPS'],
+ })
+ }
+
+ if (provisionedIOPS < IOPS_RANGE[DiskType.GP3].min) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `Provisioned IOPS must be at least 3000`,
path: ['provisionedIOPS'],
})
- } else if (provisionedIOPS > maxIOPS) {
+ } else if (provisionedIOPS > maxIopsAllowedForDiskSizeWithGp3) {
if (totalSize >= 8) {
+ const diskSizeRequiredForIopsWithGp3 =
+ calculateDiskSizeRequiredForIopsWithGp3(provisionedIOPS)
+
ctx.addIssue({
code: z.ZodIssueCode.custom,
- message: `Provisioned IOPS must be at most ${maxIOPS}`,
+ message: `Larger Disk size of at least ${diskSizeRequiredForIopsWithGp3}GB required. Current max is ${maxIopsAllowedForDiskSizeWithGp3} IOPS.`,
path: ['provisionedIOPS'],
})
} else {
@@ -93,13 +128,26 @@ export const CreateDiskStorageSchema = (defaultTotalSize: number) => {
}
}
- if (throughput !== undefined && (throughput < 125 || throughput > maxThroughput)) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- message: `Throughput must be set between 125 and ${maxThroughput?.toLocaleString()} MB/s.`,
- path: ['throughput'],
- })
+ if (throughput !== undefined) {
+ const maxThroughput = Math.min(0.25 * provisionedIOPS, 1000)
+
+ if (throughput < THROUGHPUT_RANGE[DiskType.GP3].min) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: `Throughput must be at least 125`,
+ path: ['throughput'],
+ })
+ }
+ if (throughput > maxThroughput) {
+ const iopsRequiredForThroughput = calculateIopsRequiredForThroughput(throughput)
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: `Need at least ${iopsRequiredForThroughput}IOPS to support ${throughput}MB/s.`,
+ path: ['throughput'],
+ })
+ }
}
+
if (totalSize > DISK_LIMITS[DiskType.GP3].maxStorage) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
@@ -108,6 +156,20 @@ export const CreateDiskStorageSchema = (defaultTotalSize: number) => {
})
}
}
+
+ // const maxIOPSforComputeSize = calculateMaxIopsAllowedForComputeSize(computeSize)
+
+ // // console.log('provisionedIOPS in schame', provisionedIOPS)
+
+ // if (provisionedIOPS > maxIOPSforComputeSize) {
+ // const computeSizeRequiredForIops = calculateComputeSizeRequiredForIops(provisionedIOPS)
+
+ // ctx.addIssue({
+ // code: z.ZodIssueCode.custom,
+ // message: `${computeSizeRequiredForIops} Compute size required for this amount of IOPS.`,
+ // path: ['provisionedIOPS'],
+ // })
+ // }
})
return schema
diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementRestartRequiredSection.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementRestartRequiredSection.tsx
index 04f86c499d2..5f82e54581d 100644
--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementRestartRequiredSection.tsx
+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementRestartRequiredSection.tsx
@@ -1,8 +1,7 @@
import { AnimatePresence, motion } from 'framer-motion'
import { RotateCcw, X } from 'lucide-react'
import React, { useState } from 'react'
-
-import { DialogSection, TableCell, TableRow } from 'ui'
+import { DialogSection } from 'ui'
export const DiskMangementRestartRequiredSection: React.FC = () => {
const [progress, setProgress] = useState(100)