mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
b824acdfd2
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Feature, internal ## What is the current behavior? When creating a project, the worker will use load balancing to decide where to deploy a cluster. ## What is the new behavior? An internal user can choose a specific cluster and even bypass the CORDONED state by forcing deployment. ## Additional context This PR adds kubernetesClusterId and kubernetesClusterForce to the internal-only project creation form for K8S cloud providers, gated by schema validation (provider-restricted; force requires an ID) and cleared automatically on provider change. The override is a one-time creation-time steer, not a persistent pin, and the UI copy reflects that. Includes the matching kubernetes_cluster_id/kubernetes_cluster_force request fields in the generated platform API types. <img width="1620" height="1352" alt="image" src="https://github.com/user-attachments/assets/bd8965a1-cec8-4428-aac1-46d0bf3b89d3" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added Kubernetes cluster ID entry during project creation for supported cloud providers. * Added an option to force deployment to a specified cluster. * Clarified that eligible clusters must meet status and filesystem requirements. * **Bug Fixes** * Prevented invalid or outdated Kubernetes settings from being submitted when the provider or cluster selection changes. * Treated blank or whitespace-only cluster IDs as unset. * Prevented force-deployment requests without a cluster ID or for unsupported providers. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
114 lines
3.6 KiB
TypeScript
114 lines
3.6 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
import { DEFAULT_MINIMUM_PASSWORD_STRENGTH } from '@/lib/constants'
|
|
|
|
export const FormSchema = z
|
|
.object({
|
|
organization: z.string({
|
|
required_error: 'Please select an organization',
|
|
}),
|
|
projectName: z
|
|
.string()
|
|
.trim()
|
|
.min(1, 'Please enter a project name.') // Required field check
|
|
.min(3, 'Project name must be at least 3 characters long.') // Minimum length check
|
|
.max(64, 'Project name must be no longer than 64 characters.'), // Maximum length check
|
|
highAvailability: z.boolean(),
|
|
postgresVersion: z.string({
|
|
required_error: 'Please enter a Postgres version.',
|
|
}),
|
|
instanceType: z.string().optional(),
|
|
kubernetesClusterId: z
|
|
.string()
|
|
.trim()
|
|
.transform((value) => (value === '' ? undefined : value))
|
|
.optional(),
|
|
kubernetesClusterForce: z.boolean().optional(),
|
|
dbRegion: z.string({
|
|
required_error: 'Please select a region.',
|
|
}),
|
|
cloudProvider: z.string({
|
|
required_error: 'Please select a cloud provider.',
|
|
}),
|
|
|
|
dbPass: z
|
|
.string({ required_error: 'Please enter a database password.' })
|
|
.min(1, 'Password is required.'),
|
|
dbPassStrength: z
|
|
.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3), z.literal(4)])
|
|
.default(0),
|
|
dbPassStrengthMessage: z.string().default(''),
|
|
dbPassStrengthWarning: z.string().default(''),
|
|
instanceSize: z.string().optional(),
|
|
githubRepositoryId: z.string().optional().default(''),
|
|
githubInstallationId: z.number().optional(),
|
|
githubRepositoryName: z.string().optional().default(''),
|
|
dataApi: z.boolean(),
|
|
dataApiDefaultPrivileges: z.boolean(),
|
|
enableRlsEventTrigger: z.boolean(),
|
|
postgresVersionSelection: z.string(),
|
|
useOrioleDb: z.boolean(),
|
|
shouldRunMigrations: z.boolean(),
|
|
})
|
|
.superRefine(
|
|
(
|
|
{
|
|
dbPassStrength,
|
|
dbPassStrengthWarning,
|
|
highAvailability,
|
|
cloudProvider,
|
|
useOrioleDb,
|
|
kubernetesClusterId,
|
|
kubernetesClusterForce,
|
|
},
|
|
ctx
|
|
) => {
|
|
if (dbPassStrength < DEFAULT_MINIMUM_PASSWORD_STRENGTH) {
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: ['dbPass'],
|
|
message: dbPassStrengthWarning || 'Password not secure enough',
|
|
})
|
|
}
|
|
if (highAvailability && cloudProvider !== 'AWS_K8S') {
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: ['cloudProvider'],
|
|
message: 'High availability is only supported on AWS (Revamped)',
|
|
})
|
|
}
|
|
|
|
if (highAvailability && useOrioleDb) {
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: ['highAvailability'],
|
|
message: 'High availability is not supported with OrioleDB images',
|
|
})
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: ['useOrioleDb'],
|
|
message: 'High availability is not supported with OrioleDB images',
|
|
})
|
|
}
|
|
|
|
if (kubernetesClusterId && cloudProvider !== 'AWS_K8S' && cloudProvider !== 'AWS_NIMBUS') {
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: ['kubernetesClusterId'],
|
|
message:
|
|
'Kubernetes cluster ID is only supported for Kubernetes-architecture cloud providers',
|
|
})
|
|
}
|
|
|
|
if (kubernetesClusterForce && !kubernetesClusterId) {
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: ['kubernetesClusterForce'],
|
|
message: 'Force-deploy has no effect without a Kubernetes cluster ID',
|
|
})
|
|
}
|
|
}
|
|
)
|
|
|
|
export type CreateProjectForm = z.infer<typeof FormSchema>
|