feat: make regions scheduable by Flo4604 Β· Pull Request #5385 Β· unkeyed/unkey
No actionable comments were generated in the recent review. π
βΉοΈ Recent review info
βοΈ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 31797f2b-e51c-4628-86b1-82f1a0796680
π Files selected for processing (6)
pkg/db/querier_generated.gopkg/db/schema.sqlpkg/mysql/schema.sqlsvc/ctrl/worker/deploy/deploy_handler.goweb/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/regions.tsxweb/internal/db/src/schema/regions.ts
π§ Files skipped from review as they are similar to previous changes (5)
- pkg/db/schema.sql
- pkg/mysql/schema.sql
- web/internal/db/src/schema/regions.ts
- svc/ctrl/worker/deploy/deploy_handler.go
- pkg/db/querier_generated.go
π Walkthrough
Walkthrough
This PR introduces a can_schedule boolean column to the regions table, enabling regions to be marked as unavailable for deployments. The column is propagated through all database schemas, query definitions, and generated code. Backend deployment logic filters out unschedulable regions before topology calculation. Frontend region selection dropdowns exclude unschedulable options and display visual indicators for unavailable regions.
Changes
| Cohort / File(s) | Summary |
|---|---|
Database Schema pkg/db/schema.sql, pkg/mysql/schema.sql |
Added can_schedule column to regions table as boolean NOT NULL DEFAULT true. |
Go Generated Models pkg/db/models_generated.go, svc/frontline/internal/db/models_generated.go |
Added CanSchedule bool field with db:"can_schedule" tag to Region struct. |
SQL Query Definitions pkg/db/queries/app_regional_settings_find_by_app_and_env.sql, pkg/db/queries/cluster_region_list.sql |
Updated SELECT statements to include can_schedule column in result projections. |
Go Generated Query Code pkg/db/app_regional_settings_find_by_app_and_env.sql_generated.go, pkg/db/cluster_region_list.sql_generated.go, pkg/db/cluster_region_find_by_name.sql_generated.go, pkg/db/deployment_topology_find_regions.sql_generated.go, pkg/db/region_find_by_id.sql_generated.go, pkg/db/region_find_by_platform_and_name.sql_generated.go, pkg/db/sentinel_find_by_environment_id.sql_generated.go |
Updated row scanning logic and query comments to include can_schedule column in result mappings. |
Generated SQL Comments pkg/db/querier_generated.go |
Updated generated query documentation comments to reflect can_schedule in SELECT lists. |
TypeScript Schema web/internal/db/src/schema/regions.ts |
Added canSchedule: boolean column definition to Drizzle ORM schema with default true. |
Backend Deployment Logic svc/ctrl/worker/deploy/deploy_handler.go |
Added filtering to exclude regions where RegionCanSchedule is false before topology generation; updated error messages from "no regions configured" to "no schedulable regions configured"; logs warnings for skipped regions. |
Frontend Region Selection web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/settings/components/runtime-settings/regions.tsx |
Filters region options to exclude unschedulable regions; added unschedulableRegions Set derived from regions where canSchedule is false; wrapped tags in TooltipProvider with conditional warning tooltips and styling for unschedulable regions. |
Frontend UI Components web/apps/dashboard/components/ui/combobox.tsx |
Added optional disabled property to ComboboxOption type; prevents selection of disabled options; applies cursor-not-allowed styling to disabled items. |
Frontend Region Query web/apps/dashboard/lib/trpc/routers/deploy/environment-settings/get-available-regions.ts |
Updated query selection to include canSchedule field alongside id and name. |
Sequence Diagram
sequenceDiagram
participant Dashboard as Frontend Dashboard
participant API as Backend Deployment API
participant DB as Database
Dashboard->>API: Deploy to environment (POST /deploy)
API->>DB: Fetch regions for app & environment
DB-->>API: Return regions with can_schedule flags
API->>API: Filter regions (can_schedule = true)<br/>into schedulable list
alt Has Schedulable Regions
API->>API: Calculate deployment topology<br/>over schedulable regions only
API->>API: Generate deployment versions
API-->>Dashboard: β Deployment ready (HTTP 200)
else No Schedulable Regions
API-->>Dashboard: β Error: no schedulable regions<br/>configured (HTTP 400)
end
Dashboard->>Dashboard: Render region selector<br/>Filter out unschedulable regions<br/>Show tooltips on unavailable options
Dashboard-->>User: Display available regions only
Estimated code review effort
π― 4 (Complex) | β±οΈ ~45 minutes
π₯ Pre-merge checks | β 2 | β 3
β Failed checks (2 warnings, 1 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description check | β οΈ Warning | The description is mostly complete with objectives, type of change, testing instructions, and a reference to issue #5382. However, there is a critical discrepancy: the description states the column defaults to 'false', but the PR changes show the column defaults to 'true', and the commit message indicates 'make default true AGAIN'. |
Clarify the actual default value for the can_schedule column. Update the description to accurately reflect whether it defaults to true or false and ensure consistency throughout. |
| Docstring Coverage | β οΈ Warning | Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
| Title check | β Inconclusive | The title 'feat: make regions scheduable' contains a typo ('scheduable' instead of 'schedulable') and is partially related to the changeset, but the core functionality is correctly described. | Correct the typo to 'feat: make regions schedulable' for clarity and professionalism. |
β Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Linked Issues check | β Passed | The PR successfully addresses issue #5382 by adding a boolean column to regions to control visibility/scheduling, filtering regions in FindAppRegionalSettingsByAppAndEnv, and updating the dashboard UI to reflect this field. |
| Out of Scope Changes check | β Passed | All code changes directly support the core objective of adding schedulability control to regions. Changes span schema updates, database queries, backend filtering logic, and frontend UI filteringβall aligned with issue #5382's requirements. |
βοΈ Tip: You can configure your own custom pre-merge checks in the settings.
β¨ Finishing Touches
π Generate docstrings
- Create stacked PR
- Commit on current branch
π§ͺ Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
03-19-feat_make_regions_scheduable
π Coding Plan
- Generate coding plan for human review comments
Warning
There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
π§ golangci-lint (2.11.3)
Command failed
Comment @coderabbitai help to get the list of available commands and usage tips.